> 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/astro-ai-api/files/upload-deployment-file-content

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: astro-api
  version: 1.0.0
paths:
  /deployments/{deploymentId}/files/{fileKey}/content:
    put:
      operationId: upload-deployment-file-content
      summary: Upload deployment file content
      description: |
        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.
      tags:
        - files
      parameters:
        - name: deploymentId
          in: path
          description: Deployment ID
          required: true
          schema:
            type: string
        - name: fileKey
          in: path
          description: >-
            Opaque Files API key returned at reservation time, or an
            agent-produced filename
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: OAuth 2.0 device flow or platform session token
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Reconciled ready-file metadata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeploymentFile'
        '400':
          description: Invalid request body or parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Insufficient permissions for this account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: Uploaded bytes exceed the reserved size or active upload limit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Service not configured or unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '507':
          description: The deployment volume cannot fit the upload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
servers:
  - url: https://astropods.com/api/v1
    description: Astro AI API server
components:
  schemas:
    DeploymentFile:
      type: object
      properties:
        key:
          type: string
        name:
          type: string
        size:
          type: integer
          format: int64
        content_type:
          type: string
        updated_at:
          type: string
          format: date-time
        uploaded_by:
          type: string
          description: Opaque owner identity. Omitted when not applicable.
      required:
        - key
        - name
        - size
        - content_type
        - updated_at
      title: DeploymentFile
    Error:
      type: object
      properties:
        error:
          type: string
        details:
          type: string
      title: Error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: OAuth 2.0 device flow or platform session token

```

## Examples



**Request**

```json
"VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg=="
```

**Response**

```json
{
  "key": "file-9a8b7c6d5e4f3a2b1c0d",
  "name": "agent-config.yaml",
  "size": 2048,
  "content_type": "application/x-yaml",
  "updated_at": "2024-01-15T09:30:00Z",
  "uploaded_by": "user-12345"
}
```

**SDK Code**

```python
import requests

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

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

response = requests.put(url, data=payload, 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'},
  body: '"VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg=="'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

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

	payload := strings.NewReader("\"VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg==\"")

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

	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'
request.body = "\"VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg==\""

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")
  .body("\"VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg==\"")
  .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', [
  'body' => '"VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg=="',
  '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");
request.AddParameter("application/octet-stream", "\"VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg==\"", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

let postData = NSData(data: ""VGhpcyBpcyBhIHRlc3QgZmlsZSBjb250ZW50Lg=="".data(using: String.Encoding.utf8)!)

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
request.httpBody = postData as Data

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()
```