Skip to content
中文

Upload a File (Extension)

POST/agent/v1/uploads● Supported

Request body

  • agentstringoptional

    The agent to run: an agent ID string, or an object {type, id, version?} (see subfields); the operation description says how the version is chosen and which overrides apply.

  • filenamestringrequired

    The file's name, its extension included; the extension decides which blocked executable and script types are refused. 1 to 255 characters.

  • bytesintegerrequired

    The exact byte length of the file to upload; refused with 413 FILE_TOO_LARGE when it exceeds the agent's uploads.max_file_bytes.

  • content_typestringrequired

    The file's MIME type, such as image/png, stored on the file; not used to refuse the upload. 1 to 255 characters.

Returns

201

Available only on /agent/v1 and only to an embedded end-user token: a grant-bound end_user token, or an organization-level customer token, which must name the agent as agent in the body. Body: filename (1 to 255 characters), bytes (a positive integer, the byte length) and content_type (1 to 255 characters); a customer token also sends agent. Returns the File service signed-upload answer: upload_id, expires_at, and url for a small file, or part_size, parts, complete_url and status_url for a large one. The signed addresses are returned in this response only — never stored or logged; the browser PUTs the bytes straight to the address, which answers the File object and its file_id. Then attach the file_id to the caller's own session as a session resource, and reference it in the message attachments. Checks in order: a missing agent, or uploads turned off on it, returns 403 UPLOADS_DISABLED; bytes above the agent uploads.max_file_bytes returns 413 FILE_TOO_LARGE; a blocked executable or script extension returns 400 FILE_TYPE_REFUSED; the 31st unattached upload from the same user on the same agent within an hour returns 429 UPLOAD_RATE_LIMITED. A member, robot or user_key credential uses /file/v1 instead and gets 404 here.

Errors follow the Anthropic error format (type / message / request_id) — see error codes

Request

curl
curl https://api.deepraxis.com/agent/v1/uploads \
  -H "Authorization: Bearer $CUSTOMER_ACCESS_TOKEN" \
  -H "Origin: https://docs.example.com" \
  -H "Content-Type: application/json" \
  -d '{"filename":"sample.txt","bytes":11,"content_type":"text/plain"}'
Python
import requests

opts = dict(
    base_url="https://api.deepraxis.com/agent",
    api_key="$PRAXIS_API_KEY",
)

# /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
resp = requests.post(
    f"{opts['base_url']}/v1/uploads",
    headers={"Authorization": f"Bearer {customer_access_token}", "Origin": "https://docs.example.com"},
    json={"filename":"sample.txt","bytes":11,"content_type":"text/plain"},
)
print(resp.status_code, resp.json())
TypeScript
const opts = {
  baseURL: "https://api.deepraxis.com/agent",
  apiKey: "$PRAXIS_API_KEY",
};

// /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
const resp = await fetch(`${opts.baseURL}/v1/uploads`, {
  method: "POST",
  headers: { Authorization: `Bearer ${customerAccessToken}`, Origin: "https://docs.example.com", "Content-Type": "application/json" },
  body: JSON.stringify({"filename":"sample.txt","bytes":11,"content_type":"text/plain"}),
});
console.log(resp.status, await resp.json());

Response 201

{
  "url": "<redacted>",
  "upload_id": "su_rbmKmgLWFsksiSOAseui76OW",
  "expires_at": "2026-11-18T11:05:52.000Z"
}

Response

HTTP 201

The upload started; put the file body to the returned signed address.

application/json

Name Type Description
upload_id string Upload id (upl_…) that identifies this upload to the File service; not a file id.
expires_at string RFC 3339 time the signed address stops working; start a new upload after it. / RFC 3339 time the signed addresses stop working; start a new upload after it.
url string Address to PUT the whole file body to in one request; that request finishes the upload.
part_size integer Recommended byte length of each part; PUT every part at this size, except the last.
parts array<object> The part addresses in order; use them instead of url when the file exceeds the single-request limit.
parts[].part_number integer The part's 1-based position, in order.
parts[].url string Address to PUT this part's bytes to; keep the answer's ETag for the complete call.
complete_url string Address to POST the collected part ETags to, which assembles the file and answers the File object.
status_url string Read-only address answering the same shape as the File upload status, for a client with no API key.