Create a file

SDK platic.files.createText()

Add content by sending type and the fields for that type: text, a web page or a base64 document up to 1 MiB. For larger documents, use Upload a file.

With attachment.agentId the file is connected to that agent and activates by itself when its content is ready. Without attachment, it stays in the workspace with no agents.

Example

await platic.files.createText({ text: "We ship in five business days." });

Request body

From text, connected to an agent:

{
  "type": "text",
  "title": "Service hours",
  "text": "We are open Monday to Friday from 9:00 to 18:00 and on Saturdays from 10:00 to 14:00.",
  "attachment": { "agentId": "Xq8mTe2LwP4kZ1aB9cDf" }
}

From a web page, without a title (Platica sets one with AI) and checking it every day:

{
  "type": "url",
  "url": "https://acme.com/policies/returns",
  "refresh": { "intervalHours": 24 },
  "attachment": { "agentId": "Xq8mTe2LwP4kZ1aB9cDf" }
}

From a small document:

{
  "type": "file",
  "title": "Price list",
  "fileName": "prices.pdf",
  "contentType": "application/pdf",
  "contentBase64": "JVBERi0xLjcKJcfsj6IK..."
}
FieldTypeDescriptionRequired
typestringtext, url or file✓
titlestring1 to 200 characters. Without it, Platica sets a provisional one and then one with AI (see automatic names).-
descriptionstringUp to 1024 characters: what it is about and when to consult it. Empty or omitted, it is generated with AI.-
textstringWith text: the content, up to 1 MiB.*
urlstringWith url: the page, public, http or https, up to 4096 characters.*
refreshobject | nullWith url: { "intervalHours": 24 } re-reads it every that many hours (6, 12, 24, 48, 72, 168, 336 or 720). Without it, it does not update by itself.-
fileNamestringWith file: the name with extension, for example prices.pdf.*
contentTypestringWith file: the type, for example application/pdf.*
contentBase64stringWith file: the bytes in base64, up to 1 MiB.*
attachmentobject{ "agentId": "..." } connects the file to that agent.-
attachment.activateOnReadybooleanIf you send it, true. The connection always activates when processing finishes; false answers 422.-

* Depending on type, only its fields go and all of them are required: sending fields of another type answers 400.

Response

202 Accepted. Processing continues in the background:

{
  "status": "success",
  "data": {
    "accepted": true,
    "fileId": "fH3kL9mQ2xR7",
    "uploadId": "up_4Tn8Vb2Kc1",
    "link": {
      "agentId": "Xq8mTe2LwP4kZ1aB9cDf",
      "fileId": "fH3kL9mQ2xR7",
      "state": "paused",
      "attachedAt": "2026-11-01T10:00:00.000Z",
      "activateOnReady": true,
      "schedule": null
    },
    "statusUrl": "/v1/agents/Xq8mTe2LwP4kZ1aB9cDf/files/fH3kL9mQ2xR7/jobs/up_4Tn8Vb2Kc1"
  }
}

Response fields

FieldTypeDescription
acceptedbooleanAlways true: the request was accepted. It does not say it is already processed.
fileIdstringThe new file.
uploadIdstringThis processing.
linkobject | nullWith attachment: the connection just created, paused, with the fields of List agent files. Without attachment, null.
statusUrlstringWhere to read the processing: the agent's route with attachment, the file's route without it.

Afterwards

  1. Read the processing (or the statusUrl) every few seconds until terminal is true.
  2. With status: "ready" the content is ready and, if you connected it to an agent, the connection is already active.
  3. With status: "failed", error says why. The connection stays paused; fix the source and replace it or retry.

Errors

Statusdetails.codeWhen
400INVALID_INPUTA field is missing, one of another type is extra or a value is not valid; for example, a text or a base64 over 1 MiB. 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_EXCEEDEDThe request is too large. For documents over 1 MiB, use Upload a file.
422ACTIVATION_POLICY_MISMATCHYou sent attachment.activateOnReady: false.
422INVALID_CONTENT_TYPEThe type is not supported or does not match the document.
429QUOTA_EXCEEDEDThere are already 30 open processings in the workspace. Wait a few minutes.
429STORAGE_LIMIT_EXCEEDEDThe workspace reached its file or storage limit.

The ones that apply to all operations are in common errors.

Notes

  • In the SDK there is one method per type: platic.files.createText(...), platic.files.createUrl(...) and platic.files.createFile(...) (the last one also handles documents over 1 MiB automatically).
  • If you send the Idempotency-Key header and repeat the same request after a network cut, the API returns the same fileId and uploadId without duplicating the file.