> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.astropods.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.astropods.com/_mcp/server.

# Upload deployment file content

PUT https://astropods.com/api/v1/deployments/{deploymentId}/files/{fileKey}/content
Content-Type: application/octet-stream

Streams bytes into a previously reserved key. The declared reservation
size is a hard ceiling. The file becomes ready and attachable only after
this request succeeds.


Reference: https://docs.astropods.com/api-reference/astropods-api/files/upload-deployment-file-content

## Authentication

- `Authorization` header (bearer token, required) — OAuth 2.0 device flow or platform session token

## Request

### Path parameters

- `deploymentId` (string, required) — Deployment ID
- `fileKey` (string, required) — Opaque Files API key returned at reservation time, or an agent-produced filename

### Body (application/octet-stream)

This endpoint expects binary data of type application/octet-stream.

- Binary request body.

## Response

### 200

Reconciled ready-file metadata

- `key` (string, required)
- `name` (string, required)
- `size` (long, required)
- `content_type` (string, required)
- `updated_at` (datetime, required)
- `uploaded_by` (string, optional) — Opaque owner identity. Omitted when not applicable.

## Errors

### 400 Bad Request Error

Invalid request body or parameters

- `error` (string, optional)
- `details` (string, optional)

### 401 Unauthorized Error

Authentication required

- `error` (string, optional)
- `details` (string, optional)

### 403 Forbidden Error

Insufficient permissions for this account

- `error` (string, optional)
- `details` (string, optional)

### 404 Not Found Error

Resource not found

- `error` (string, optional)
- `details` (string, optional)

### 413 Content Too Large Error

Uploaded bytes exceed the reserved size or active upload limit

- `error` (string, optional)
- `details` (string, optional)

### 500 Internal Server Error

Server error

- `error` (string, optional)
- `details` (string, optional)

### 503 Service Unavailable Error

Service not configured or unavailable

- `error` (string, optional)
- `details` (string, optional)

### 507 Insufficient Storage Error

The deployment volume cannot fit the upload

- `error` (string, optional)
- `details` (string, optional)

## Examples

**Response**

```json
{
  "key": "string",
  "name": "string",
  "size": 1,
  "content_type": "string",
  "updated_at": "2024-01-15T09:30:00Z",
  "uploaded_by": "string"
}
```

**SDK Code**

```python
import requests

url = "https://astropods.com/api/v1/deployments/deploymentId/files/fileKey/content"

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/octet-stream"
}

response = requests.put(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://astropods.com/api/v1/deployments/deploymentId/files/fileKey/content';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/octet-stream'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://astropods.com/api/v1/deployments/deploymentId/files/fileKey/content"

	req, _ := http.NewRequest("PUT", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/octet-stream")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://astropods.com/api/v1/deployments/deploymentId/files/fileKey/content")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/octet-stream'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://astropods.com/api/v1/deployments/deploymentId/files/fileKey/content")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/octet-stream")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://astropods.com/api/v1/deployments/deploymentId/files/fileKey/content', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/octet-stream',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://astropods.com/api/v1/deployments/deploymentId/files/fileKey/content");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/octet-stream");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/octet-stream"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://astropods.com/api/v1/deployments/deploymentId/files/fileKey/content")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```