# WriteFile accepts raw content with path and mode query parameters.


[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.




`PUT /v1/files/content`

WriteFile accepts raw content with path and mode query parameters.
It replaces the complete target state and carries no request_id.

## 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 PUT \
  --header "Authorization: Bearer ${TOKEN}" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/octet-stream' \
  --data-binary @request-body \
  'https://sandbox.invalid/v1/files/content?path=%3CPATH%3E'
```


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


## Parameters

### path

Location: query. Required: yes.

path is the sandbox path.

```json
{
  "description": "path is the sandbox path.",
  "in": "query",
  "name": "path",
  "pointer": "/paths/~1v1~1files~1content/put/parameters/0",
  "required": true,
  "schema": {
    "minLength": 1,
    "title": "path",
    "type": "string"
  }
}
```

### mode

Location: query. Required: no.

mode carries Unix permission bits. Upload applies mode & 0777, or 0644 when
that value is zero, without subtracting umask; Download reports stored bits.

```json
{
  "description": "mode carries Unix permission bits. Upload applies mode \u0026 0777, or 0644 when\nthat value is zero, without subtracting umask; Download reports stored bits.",
  "in": "query",
  "name": "mode",
  "pointer": "/paths/~1v1~1files~1content/put/parameters/1",
  "required": false,
  "schema": {
    "title": "mode",
    "type": "integer"
  }
}
```

## Request and responses

### Request  application/octet-stream




Schema:

```json
{
  "contentMediaType": "application/octet-stream"
}
```










### Response 200 application/json

Success


Schema:

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










### 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": "WriteFile accepts raw content with path and mode query parameters.\nIt replaces the complete target state and carries no request_id.",
  "operationId": "writeFile",
  "parameters": [
    {
      "description": "path is the sandbox path.",
      "in": "query",
      "name": "path",
      "required": true,
      "schema": {
        "minLength": 1,
        "title": "path",
        "type": "string"
      }
    },
    {
      "description": "mode carries Unix permission bits. Upload applies mode \u0026 0777, or 0644 when\nthat value is zero, without subtracting umask; Download reports stored bits.",
      "in": "query",
      "name": "mode",
      "required": false,
      "schema": {
        "title": "mode",
        "type": "integer"
      }
    }
  ],
  "requestBody": {
    "content": {
      "application/octet-stream": {
        "schema": {
          "contentMediaType": "application/octet-stream"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/FilesWriteFileResponse"
          }
        }
      },
      "description": "Success"
    },
    "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": "WriteFile accepts raw content with path and mode query parameters.",
  "tags": [
    "Files"
  ],
  "x-sbx-authenticated-only": false,
  "x-sbx-conditional-permissions": [],
  "x-sbx-http-transfer": {
    "request": {
      "bytesField": "data",
      "mediaType": "application/octet-stream"
    }
  },
  "x-sbx-plane": "data",
  "x-sbx-request-schema": {
    "$ref": "#/components/schemas/FilesWriteFileRequest"
  },
  "x-sbx-required-permissions": [
    "sandboxesFilesWrite"
  ],
  "x-sbx-response-schema": {
    "$ref": "#/components/schemas/FilesWriteFileResponse"
  },
  "x-sbx-serving-surface": "sandboxEndpoint"
}
```

## Referenced schemas

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

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

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




