Authenticating...

Files API

Copy Page as Markdown

Use the Files API to upload and manage documents for your organization. Files are org-scoped — a file is only visible to the organization that created it.

After upload, reference a file by file_id: a file part on Chat Completions, or an input_file part on the Responses API. See Sending files for the request shapes and for when to upload rather than inline a document.

All requests require a valid API key:

Authorization: Bearer $SUBQ_API_KEY

See Authentication for details.

Endpoints

MethodPathDescription
POST/v1/filesUpload a file (multipart)
GET/v1/filesList the org's files
GET/v1/files/{file_id}Retrieve one file
DELETE/v1/files/{file_id}Delete a file

Limits

  • Max size: 50 MB per file.
  • Purpose: assistants (only value accepted today).
  • Supported types: plain text (.txt, .md, .csv, .tsv), JSON / JSONL, XML, PDF, and Word (.doc, .docx).

File object

FieldTypeDescription
idstringFile identifier (file_…). Use as file_id in Chat Completions or Responses.
objectstringAlways "file".
bytesnumberSize in bytes.
created_atnumberUnix timestamp (seconds) when the file was created.
expires_atnumber or nullExpiration timestamp, if any.
filenamestringOriginal file name.
purposestringIntended purpose (assistants).
statusstring or nullLifecycle status (see below).

Statuses

StatusMeaning
uploadedBytes stored and validated. Non-text files may still be extracting text.
processedContent available for Chat Completions and Responses. Text files reach this immediately.
errorProcessing failed. (Reserved.)

Upload file

POST /v1/files

Upload bytes through the API as multipart/form-data.

FieldRequiredDescription
fileYesThe file part.
purposeYesMust be assistants.

The file part must carry a Content-Type from the supported types. A part sent as application/octet-stream is rejected with unsupported_file_type, so set the type explicitly when your HTTP client does not infer it from the filename — as the TypeScript example below does with toFile().

cURLTypeScriptPython

Response

{
  "id": "file_abc123",
  "object": "file",
  "bytes": 12345,
  "created_at": 1753742400,
  "expires_at": null,
  "filename": "report.pdf",
  "purpose": "assistants",
  "status": "uploaded"
}

List files

GET /v1/files
ParamTypeDefaultDescription
limitinteger20Page size (110000).
orderstringdescSort by creation time: asc or desc.
afterstringKeyset cursor; start after this file id.
purposestringOptional filter (assistants).
cURLTypeScriptPython

Response

{
  "object": "list",
  "data": [
    {
      "id": "file_abc123",
      "object": "file",
      "bytes": 12345,
      "created_at": 1753742400,
      "expires_at": null,
      "filename": "report.pdf",
      "purpose": "assistants",
      "status": "processed"
    }
  ],
  "first_id": "file_abc123",
  "last_id": "file_abc123",
  "has_more": false
}

Paginate with last_id as the next after value until has_more is false.

Retrieve file

GET /v1/files/{file_id}
cURLTypeScriptPython

Returns the File object, or 404 if missing or owned by another org.

Delete file

DELETE /v1/files/{file_id}

Removes stored bytes and metadata.

cURLTypeScriptPython

Response

{
  "id": "file_abc123",
  "object": "file",
  "deleted": true
}

Errors

Errors use the OpenAI shape:

{
  "error": {
    "message": "No such File object: file_abc123",
    "type": "invalid_request_error",
    "code": "not_found",
    "param": null
  }
}
HTTPcodeWhen
400validation_errorMissing or invalid params
400unsupported_file_typeMIME type not in the supported set
401invalid_api_keyMissing or invalid API key
403org_suspendedOrganization is suspended or inactive
404not_foundFile missing or owned by another org
413file_too_largeUpload exceeds 50 MB