# Upload streams one or more files.


[API catalog](/reference/api/) · [Docker Sandboxes overview](/reference/api/sandboxes/latest/) · [Product manual](https://docs.docker.com/ai/sandboxes-api/) · [OpenAPI specification](/reference/api/sandboxes/api.yaml)

API version: v1


> This API is experimental. Features, interfaces,
> and behavior may change.




`POST /v1/files/upload`

Upload streams one or more files. The first frame must be FileHeader.
Writing through a symlink that leaves the jail, or onto an existing
non-regular object, refuses with FAILED_PRECONDITION and a error reason.

## Connection and access

[API connection and authentication guidance](/reference/api/sandboxes/latest/#authentication)


Server: `{endpoint}`

`endpoint`: The sandbox API base URL from Sandbox.core.endpoint.uri; preserve its path prefix when appending /v1 routes. HTTP endpoints require a scoped endpoint bearer; direct Unix sockets use socket access control.

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
[
  {
    "sandboxBearer": []
  }
]
```

## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request POST \
  --header "Authorization: Bearer ${TOKEN}" \
  --header 'Accept: application/json' \
  --header 'Content-Type: multipart/form-data' \
  --data-binary @request-body \
  'https://sandbox.invalid/v1/files/upload'
```


Prepare request-body using the selected media type and schema.


## Parameters

## Request and responses

### Request  multipart/form-data

Send ordered metadata/content pairs. Each metadata part is application/json; the following content part is application/octet-stream containing raw bytes, including an empty file. Content-Disposition is form-data with the corresponding part name. Content-Transfer-Encoding is refused. A clean closing multipart delimiter is required; truncated content never completes the current item. Malformed occurrences report invalidArgument with a BadRequest detail identifying the occurrence index and path.



Stream item schema:

```json
{
  "oneOf": [
    {
      "additionalProperties": false,
      "properties": {
        "metadata": {
          "$ref": "#/components/schemas/FileHeader"
        }
      },
      "required": [
        "metadata"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "properties": {
        "content": {
          "contentMediaType": "application/octet-stream"
        }
      },
      "required": [
        "content"
      ],
      "type": "object"
    }
  ]
}
```






itemEncoding:

```json
{
  "contentType": "application/json, application/octet-stream"
}
```




### Response 200 application/json

Success


Schema:

```json
{
  "$ref": "#/components/schemas/FilesUploadResponse"
}
```










### Response 409 application/json

The path resolves through a symlink that does not resolve to a target inside the sandbox jail.

The path names an existing socket, FIFO, device, or other non-regular object where a regular file is required.


Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```









path_authority_nonregular_object:
```json
{
  "code": "failedPrecondition",
  "message": "path_authority_nonregular_object: The path names an existing socket, FIFO, device, or other non-regular object where a regular file is required."
}
```

path_authority_symlink_escape:
```json
{
  "code": "failedPrecondition",
  "message": "path_authority_symlink_escape: The path resolves through a symlink that does not resolve to a target inside the sandbox jail."
}
```


### Response default application/json

The structured Error body identifies the failure with a stable code and optional typed details.


Schema:

```json
{
  "$ref": "#/components/schemas/Error"
}
```









Schema example:
```json
{
  "code": "notFound",
  "details": [],
  "message": "sandbox not found"
}
```


## Complete operation contract

```json
{
  "description": "Upload streams one or more files. The first frame must be FileHeader.\nWriting through a symlink that leaves the jail, or onto an existing\nnon-regular object, refuses with FAILED_PRECONDITION and a error reason.",
  "operationId": "upload",
  "requestBody": {
    "content": {
      "multipart/form-data": {
        "itemEncoding": {
          "contentType": "application/json, application/octet-stream"
        },
        "itemSchema": {
          "oneOf": [
            {
              "additionalProperties": false,
              "properties": {
                "metadata": {
                  "$ref": "#/components/schemas/FileHeader"
                }
              },
              "required": [
                "metadata"
              ],
              "type": "object"
            },
            {
              "additionalProperties": false,
              "properties": {
                "content": {
                  "contentMediaType": "application/octet-stream"
                }
              },
              "required": [
                "content"
              ],
              "type": "object"
            }
          ]
        },
        "x-sbx-framing": {
          "description": "Send ordered metadata/content pairs. Each metadata part is application/json; the following content part is application/octet-stream containing raw bytes, including an empty file. Content-Disposition is form-data with the corresponding part name. Content-Transfer-Encoding is refused. A clean closing multipart delimiter is required; truncated content never completes the current item. Malformed occurrences report invalidArgument with a BadRequest detail identifying the occurrence index and path.",
          "partOrder": [
            "metadata",
            "content"
          ],
          "repeatedItems": true,
          "requiresClosingDelimiter": true
        }
      }
    },
    "description": "Send ordered metadata/content pairs. Each metadata part is application/json; the following content part is application/octet-stream containing raw bytes, including an empty file. Content-Disposition is form-data with the corresponding part name. Content-Transfer-Encoding is refused. A clean closing multipart delimiter is required; truncated content never completes the current item. Malformed occurrences report invalidArgument with a BadRequest detail identifying the occurrence index and path.",
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/FilesUploadResponse"
          }
        }
      },
      "description": "Success"
    },
    "409": {
      "content": {
        "application/json": {
          "examples": {
            "path_authority_nonregular_object": {
              "summary": "The path names an existing socket, FIFO, device, or other non-regular object where a regular file is required.",
              "value": {
                "code": "failedPrecondition",
                "message": "path_authority_nonregular_object: The path names an existing socket, FIFO, device, or other non-regular object where a regular file is required."
              }
            },
            "path_authority_symlink_escape": {
              "summary": "The path resolves through a symlink that does not resolve to a target inside the sandbox jail.",
              "value": {
                "code": "failedPrecondition",
                "message": "path_authority_symlink_escape: The path resolves through a symlink that does not resolve to a target inside the sandbox jail."
              }
            }
          },
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "description": "The path resolves through a symlink that does not resolve to a target inside the sandbox jail.\n\nThe path names an existing socket, FIFO, device, or other non-regular object where a regular file is required."
    },
    "default": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "description": "The structured Error body identifies the failure with a stable code and optional typed details."
    }
  },
  "security": [
    {
      "sandboxBearer": []
    }
  ],
  "servers": [
    {
      "url": "{endpoint}",
      "variables": {
        "endpoint": {
          "default": "https://sandbox.invalid",
          "description": "The sandbox API base URL from Sandbox.core.endpoint.uri; preserve its path prefix when appending /v1 routes. HTTP endpoints require a scoped endpoint bearer; direct Unix sockets use socket access control."
        }
      }
    }
  ],
  "summary": "Upload streams one or more files.",
  "tags": [
    "Files"
  ],
  "x-sbx-authenticated-only": false,
  "x-sbx-conditional-permissions": [],
  "x-sbx-error-responses": [
    {
      "code": "FAILED_PRECONDITION",
      "description": "The path resolves through a symlink that does not resolve to a target inside the sandbox jail.",
      "reason": "path_authority_symlink_escape"
    },
    {
      "code": "FAILED_PRECONDITION",
      "description": "The path names an existing socket, FIFO, device, or other non-regular object where a regular file is required.",
      "reason": "path_authority_nonregular_object"
    }
  ],
  "x-sbx-http-transfer": {
    "request": {
      "bytesField": "data",
      "itemPathField": "header.path",
      "mediaType": "multipart/form-data",
      "metadataField": "header",
      "repeatedItems": true
    }
  },
  "x-sbx-plane": "data",
  "x-sbx-request-schema": {
    "$ref": "#/components/schemas/FilesUploadRequest"
  },
  "x-sbx-required-permissions": [
    "sandboxesFilesWrite"
  ],
  "x-sbx-response-schema": {
    "$ref": "#/components/schemas/FilesUploadResponse"
  },
  "x-sbx-serving-surface": "sandboxEndpoint"
}
```

## Referenced schemas

- [#/components/schemas/Error](/reference/api/sandboxes/latest/schemas/Error/)

- [#/components/schemas/FileHeader](/reference/api/sandboxes/latest/schemas/FileHeader/)

- [#/components/schemas/FilesUploadRequest](/reference/api/sandboxes/latest/schemas/FilesUploadRequest/)

- [#/components/schemas/FilesUploadResponse](/reference/api/sandboxes/latest/schemas/FilesUploadResponse/)




