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

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" }
}
FieldTypeDescriptionRequired
fileNamestringThe name with extension (see formats).✓
contentTypestringThe type, for example application/pdf.✓
byteSizeintegerThe exact size in bytes, from 1 to 52,428,800 (50 MiB).✓
titlestring1 to 200 characters. Without it, it starts with the document's name and then takes one with AI.-
descriptionstringUp to 1024 characters. Empty or omitted, it is generated with AI.-
attachmentobject{ "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:

FieldTypeDescription
upload.methodstringAlways PUT.
upload.sessionUristringThe private address you send the bytes to. It is a secret: do not store it in logs or share it.
upload.admissionExpiresAtstringUntil 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-Type you declared when opening the upload.
  • It answers 200 or 201 when everything arrived. Then the processing moves from awaiting_upload to queued.
  • If the upload is interrupted, resume it using the same URL (Google Cloud Storage resumable upload). Check how many bytes arrived with an empty PUT and Content-Range: bytes */TOTAL, then continue from that point.

Then, read the processing until terminal is true.

Errors

Statusdetails.codeWhen
400INVALID_INPUTA field is missing or a value is not valid. details.fields names them.
403RESOURCE_NOT_ACCESSIBLEWithout attachment: Integrations is missing. With attachment: you cannot edit that agent.
404AGENT_NOT_FOUNDThe agent in attachment does not exist.
413SIZE_LIMIT_EXCEEDEDbyteSize is over 50 MiB.
422INVALID_CONTENT_TYPEThe extension or the type is not supported.
429QUOTA_EXCEEDEDThere are already 30 open processings in the workspace.
429STORAGE_LIMIT_EXCEEDEDThe workspace reached its file or storage limit.
503ACCEPTANCE_INCOMPLETEThe 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 has upload: null: the sessionUri address 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, with upload.