Upload a file
SDK platic.files.createFile()
Upload a document up to 50 MiB: first send fileName, contentType and byteSize to get upload.sessionUri, then send the bytes to that private URL with PUT. For documents up to 1 MiB, text or web pages, use Create a file.
Example
curl -X POST "https://api.platic.ai/v1/files/upload" \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Returns manual",
"fileName": "returns-manual.pdf",
"contentType": "application/pdf",
"byteSize": 7340032
}' await platic.files.createFile({ data: new Uint8Array(2_000_000), fileName: "catalog.pdf" }); Request body
{
"title": "Returns manual",
"fileName": "returns-manual.pdf",
"contentType": "application/pdf",
"byteSize": 7340032,
"attachment": { "agentId": "Xq8mTe2LwP4kZ1aB9cDf" }
} | Field | Type | Description | Required |
|---|---|---|---|
fileName | string | The name with extension (see formats). | ✓ |
contentType | string | The type, for example application/pdf. | ✓ |
byteSize | integer | The exact size in bytes, from 1 to 52,428,800 (50 MiB). | ✓ |
title | string | 1 to 200 characters. Without it, it starts with the document's name and then takes one with AI. | - |
description | string | Up to 1024 characters. Empty or omitted, it is generated with AI. | - |
attachment | object | { "agentId": "..." } connects the file to that agent; the connection activates by itself when it finishes. | - |
Response
202 Accepted. It has upload next to data:
{
"status": "success",
"data": {
"accepted": true,
"fileId": "kP7wQ2sN5tY1",
"uploadId": "up_9Rf3Jd6Hx2",
"link": {
"agentId": "Xq8mTe2LwP4kZ1aB9cDf",
"fileId": "kP7wQ2sN5tY1",
"state": "paused",
"attachedAt": "2026-11-01T10:00:00.000Z",
"activateOnReady": true,
"schedule": null
},
"statusUrl": "/v1/agents/Xq8mTe2LwP4kZ1aB9cDf/files/kP7wQ2sN5tY1/jobs/up_9Rf3Jd6Hx2"
},
"upload": {
"method": "PUT",
"sessionUri": "https://storage.googleapis.com/upload/storage/v1/b/...",
"admissionExpiresAt": "2026-11-01T11:00:00.000Z"
}
} Response fields
data has the fields of Create a file. Also:
| Field | Type | Description |
|---|---|---|
upload.method | string | Always PUT. |
upload.sessionUri | string | The private address you send the bytes to. It is a secret: do not store it in logs or share it. |
upload.admissionExpiresAt | string | Until when you can send the bytes: one hour. After that, processing fails with UPLOAD_EXPIRED. |
Send the bytes
curl -X PUT "$SESSION_URI" \
-H "Content-Type: application/pdf" \
--data-binary @returns-manual.pdf - Without
Authorization: the address already grants permission. Do not send your API key to another server. - Use the same
Content-Typeyou declared when opening the upload. - It answers
200or201when everything arrived. Then the processing moves fromawaiting_uploadtoqueued. - If the upload is interrupted, resume it using the same URL (Google Cloud Storage resumable upload). Check how many bytes arrived with an empty
PUTandContent-Range: bytes */TOTAL, then continue from that point.
Then, read the processing until terminal is true.
Warning
upload only comes in this response. Keep sessionUri until you finish uploading.
Errors
| Status | details.code | When |
|---|---|---|
400 | INVALID_INPUT | A field is missing or a value is not valid. details.fields names them. |
403 | RESOURCE_NOT_ACCESSIBLE | Without attachment: Integrations is missing. With attachment: you cannot edit that agent. |
404 | AGENT_NOT_FOUND | The agent in attachment does not exist. |
413 | SIZE_LIMIT_EXCEEDED | byteSize is over 50 MiB. |
422 | INVALID_CONTENT_TYPE | The extension or the type is not supported. |
429 | QUOTA_EXCEEDED | There are already 30 open processings in the workspace. |
429 | STORAGE_LIMIT_EXCEEDED | The workspace reached its file or storage limit. |
503 | ACCEPTANCE_INCOMPLETE | The upload could not finish opening. Repeat the request. |
If the bytes do not match what you declared (another size, another type), the request was already accepted: the processing fails with its reason in error. The errors that apply to all operations are in common errors.
Notes
- With the SDK you do not have to open the session manually:
platic.files.createFile({ data, fileName })decides by itself whether to send inline (up to 1 MiB) or open an upload session (1 to 50 MiB) and upload the bytes. - If you repeat this call with the same
Idempotency-Key, the second response hasupload: null: thesessionUriaddress is only delivered once. - This operation is not in Platica's MCP: over MCP a file goes in base64 inside
create_file, up to 1 MB. - To replace a file's content with another large document, use Update a file with
replacement.type: "upload": it answers the same way, withupload.