# Upload File to Sandbox

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

`POST /workspaces/:workspace/sandboxes/:sandbox_id/content/upload/:path`

Upload a file to a sandbox

**Required Scopes:** `SANDBOX_WRITE`

## URL Parameters

```typescript
interface URLParameters {
  /** The human-readable ID of the workspace */
  workspace: string; // Example: "my-company"
  /** The ID of the sandbox */
  sandbox_id: string; // Example: "sb-1234567890abcdef"
  /** Absolute path where the file should be uploaded. Recommended directory is `/buddy` */
  path: string; // Example: "buddy/example.txt"
}
```

## Query Parameters

```typescript
interface QueryParameters {
  /** Owner of the uploaded file inside the sandbox. Defaults to `buddy`. Any user that exists in the sandbox is accepted. */
  userName?: string; // Example: "buddy"
}
```

## Response Body

```typescript
interface ResponseBody {
  /** The content type (FILE or DIR) */
  type?: "FILE" | "DIR";
  /** API endpoint to GET this object */
  url?: string;
  /** Web URL to view this object in Buddy.works */
  html_url?: string;
  /** The name of the file or directory */
  name?: string;
  /** The path to the file or directory */
  path?: string;
  /** The size of the file in bytes */
  size?: number;
}
```

## Request Example

```bash
curl -X POST "https://api.buddy.works/workspaces/:workspace/sandboxes/:sandbox_id/content/upload/:path" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "Content-Type: application/json"
```

## Response Example

**Status:** `201 File uploaded successfully`

```json
{
  "url": "https://api.buddy.works/workspaces/my-workspace/sandboxes/sb-12345/content/buddy/src/index.js",
  "html_url": "https://app.buddy.works/my-project/sandboxes/sb-12345",
  "type": "FILE",
  "name": "index.js",
  "path": "/buddy/src/index.js",
  "size": 1024
}
```

---
Original source: https://buddy.works/docs/api/sandboxes/upload-file