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

# Upload the bytes of a reserved document

PUT https://api.pyramid-ai.com/api/v1/documents/{id}/upload
Content-Type: application/octet-stream

The `upload.url` returned by POST /documents. Send the raw file bytes with a
Content-Length. The signed `token` in the URL authorizes this one document, so
no API key header is needed. Then call POST /documents/process.


Reference: https://doc.pyramid-ai.com/api-reference/api-explorer/documents/upload-document-bytes

## Servers

- `https://api.pyramid-ai.com` (Production, default)
- `https://api-staging.pyramid-ai.com` (Staging (sandbox): use pai_test_* keys)

## Request

### Path parameters

- `id` (string, required)

### Query parameters

- `token` (string, required)

### Body (application/octet-stream)

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

- Binary request body.

## Response

### 200

Bytes stored

## Errors

### 400 Bad Request Error

Validation error

- `success` (any, required)
- `error` (ApiErrorError, required)
- `request_id` (string, required)

### 401 Unauthorized Error

Unauthorized

- `success` (any, required)
- `error` (ApiErrorError, required)
- `request_id` (string, required)

### 404 Not Found Error

Resource not found

- `success` (any, required)
- `error` (ApiErrorError, required)
- `request_id` (string, required)

## Types

### ApiErrorError

- `code` (enum, required)
  - Allowed values: `VALIDATION_ERROR`, `UNAUTHORIZED`, `FORBIDDEN`, `FEATURE_NOT_ENABLED`, `AGENT_NOT_ENABLED`, `QUOTA_EXCEEDED`, `NOT_FOUND`, `CONFLICT`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `UPLOAD_NOT_FOUND`, `UPLOAD_SIZE_MISMATCH`, `RATE_LIMITED`, `INTERNAL_ERROR`
- `message` (string, required) — Human-readable description. May be shown to end users; keep stable across minor changes.
- `docs_url` (string, optional) — Link to the error's documentation section.
- `field` (string, optional) — Only for `VALIDATION_ERROR`. JSONPath-ish reference to the offending field (e.g. `body.project_id`).
- `feature` (string, optional) — Only for `FEATURE_NOT_ENABLED`. The feature key the request required.

## Examples

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.pyramid-ai.com/api/v1/documents/id/upload"

querystring = {"token":"token"}

headers = {"Content-Type": "application/octet-stream"}

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

print(response.json())
```

```javascript
const url = 'https://api.pyramid-ai.com/api/v1/documents/id/upload?token=token';
const options = {method: 'PUT', headers: {'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://api.pyramid-ai.com/api/v1/documents/id/upload?token=token"

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

	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://api.pyramid-ai.com/api/v1/documents/id/upload?token=token")

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

request = Net::HTTP::Put.new(url)
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://api.pyramid-ai.com/api/v1/documents/id/upload?token=token")
  .header("Content-Type", "application/octet-stream")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.pyramid-ai.com/api/v1/documents/id/upload?token=token', [
  'headers' => [
    'Content-Type' => 'application/octet-stream',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.pyramid-ai.com/api/v1/documents/id/upload?token=token");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/octet-stream");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/octet-stream"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.pyramid-ai.com/api/v1/documents/id/upload?token=token")! 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()
```