Send a message to the agent

SDK platic.chat.send()

Send a message to an agent to start or continue a conversation. Run it immediately or schedule it for later.

Example

await platic.chat.send({ agentId: "agent_123", message: "Which plan fits a team of 25?" });

Query parameters

ParameterTypeDescriptionRequired
workspacestringOnly if the credential covers several workspaces: the workspace of the agent and the conversation. Required in that case—

Request body

To start a conversation:

{
  "message": "Help me choose the right plan for my team.",
  "agentId": "agent_01JABCDEF23456789"
}

Every new request without conversationId creates an independent thread with a chat_<uuid> conversationId, even if it reuses the same contact. clientId identifies the contact, not the thread.

FieldTypeDescriptionRequired
messagestringText the agent receives. Optional when you send attachments.✓¹
attachmentsarrayUp to 10 images or files referenced by URL; each must be smaller than 20 MB.✓¹
agentIdstringMain agent of the thread. Required when starting; when continuing, a different ID changes the main agent without creating another thread.When starting
conversationIdstringID returned by a previous turn. Send it to continue that thread.—
additionalInstructionsstringExtra instructions for the agent. They only affect the current turn and do not change its configuration or later turns.—
clientobjectThe person or contact talking to the agent. If omitted, the user who owns the API key is used automatically.—
delayintegerDelay in milliseconds, from 3000 to 86400000 (24 hours). Cannot be combined with scheduleAt.—
scheduleAtstringFuture date in ISO 8601 format, at most 30 days after the request. Cannot be combined with delay.—

¹ You must send message, attachments or both.

Attachments

Send each attachment as a public or signed URL the agent can open. This endpoint does not receive the file itself.

{
  "agentId": "agent_01JABCDEF23456789",
  "message": "Analyze these documents",
  "attachments": [
    {
      "url": "https://cdn.example.com/front-photo.jpg",
      "mimeType": "image/jpeg",
      "filename": "front-photo.jpg"
    },
    {
      "url": "https://cdn.example.com/policy.pdf",
      "mimeType": "application/pdf",
      "filename": "policy.pdf"
    }
  ]
}
FieldTypeDescriptionRequired
attachments[].urlstring URLPublic or signed http(s) URL of the file.✓
attachments[].mimeTypestringMIME type, for example image/jpeg or application/pdf.✓
attachments[].filenamestringFile name. If omitted, it is derived from the URL.—

Rules:

  • At most 10 attachments per message.
  • Each URL must point to a file smaller than 20 MB.
  • Images are sent as visual content; other MIME types are treated as files.
  • Several attachments are processed together as a single multimedia message.

Identify the contact

To attribute the chat to a specific contact, send a stable ID and their details:

{
  "message": "I want to review my policy.",
  "agentId": "agent_01JABCDEF23456789",
  "client": {
    "id": "client_123",
    "name": "Ana López",
    "firstname": "Ana",
    "lastname": "López",
    "email": "ana@example.com",
    "phoneNumber": "5215512345678",
    "customFields": {
      "policy_number": "GNP-123456",
      "policy_type": "medical_expenses"
    }
  }
}

When you start a conversation, client must include id, email or phoneNumber:

  • With id, that is the contact. Platica creates it if it does not exist and does not look anyone else up by email or phoneNumber; those fields are only saved on its profile.
  • Without id, Platica looks for an existing contact with that phoneNumber or email and continues as that contact, or creates a new one if there is none. If they point to different contacts, it stops the request with 409. So send phoneNumber or email without id only when your application has verified them.

In later turns you can omit client. If you include it again, the fields you send update the original contact; you cannot replace it with a different client.id.

The agent's memory is per contact. For it to remember a person's earlier chats, use the same client.id in every new chat. Without client, all chats belong to the API key's owner and share their memory.

client.customFields accepts the workspace's active custom fields. Values are merged with the existing ones and only replace the keys you send.

Continue a conversation

Save the conversationId from the first response and send it in the next turn:

{
  "message": "We are 25 people and we need WhatsApp.",
  "conversationId": "chat_01JCHAT23456789"
}

You can change the main agent by sending a different agentId. The conversation keeps its history and its internal channel; the active delegation resets and later subagents start from the new main agent:

{
  "message": "Compare the two best options.",
  "agentId": "agent_01JOTHERAGENT1234",
  "conversationId": "chat_01JCHAT23456789",
  "additionalInstructions": "Answer with a short table."
}

Schedule a turn

Use delay to run the turn between 3 seconds and 24 hours later:

{
  "message": "Remind me of the plan options.",
  "agentId": "agent_01JABCDEF23456789",
  "delay": 5000
}

Use scheduleAt to give a future date, up to 30 days after the request:

{
  "message": "Prepare a summary before the meeting.",
  "agentId": "agent_01JABCDEF23456789",
  "scheduleAt": "2026-08-01T15:00:00-06:00"
}

delay and scheduleAt are mutually exclusive. You can also schedule turns with attachments, client and additionalInstructions.

Reactivate a closed or expired thread

Any closed or expired thread is reactivated automatically when you send it a message with its conversationId: the conversation keeps its history and the response returns reactivated: true. There is no endpoint to close chats from this API; closing is done as the business with Finish a conversation or Archive a conversation, using the chat's id.

Immediate response

Without delay or scheduleAt, the response arrives when the agent finishes the turn. The turn is in data; its state is data.status:

{
  "status": "success",
  "data": {
    "id": "conversation_doc_01JCHAT",
    "conversationId": "chat_01JCHAT23456789",
    "clientId": "client_123",
    "agentId": "agent_01JOTHERAGENT1234",
    "status": "completed",
    "requestMessageId": "msg_user_01JCHAT98765432",
    "messages": [
      {
        "id": "msg_assistant_01JCHAT98765433",
        "role": "assistant",
        "content": "For a team of 25 people using WhatsApp, these are the best options...",
        "contentType": "text"
      }
    ],
    "reactivated": false,
    "agentChanged": true,
    "timestamp": "2026-07-20T18:30:00.000Z"
  }
}
FieldTypeDescription
idstringUnique, canonical ID of the document. Use it to read or manage the chat.
conversationIdstringID of the chat_* thread. Save it to continue the conversation; it does not identify the contact.
clientIdstringContact the conversation was attributed to.
agentIdstringMain agent of the thread.
reactivatedbooleantrue when the message reopened a closed or expired conversation.
agentChangedbooleantrue when this turn changed the responding agent.
statusstringcompleted when the turn finished successfully. It is the turn's state, inside data; the root status is always success.
requestMessageIdstringID of the message sent by this request. The agent's replies have their own IDs in messages[].id.
messagesarrayMessages the agent generated during the turn.
messages[].idstringMessage ID.
messages[].rolestringassistant.
messages[].contentstringContent of the reply.
messages[].contentTypestringContent type of the reply.
timestampstringCompletion date and time, ISO 8601.
reasonstring, optionaloutside_service_hours when the message was received without a reply because service cannot start yet. In that case status is completed and messages is [].

Silence due to service hours is not a service error. Opening does not reply automatically to that message; a new message within service hours may start service in the same conversation. See Agent service hours.

Scheduled response

With delay or scheduleAt, the turn runs later. You immediately receive HTTP 202, message: "Chat turn scheduled", and the turn in data:

{
  "status": "success",
  "message": "Chat turn scheduled",
  "data": {
    "id": "conversation_doc_01JCHAT",
    "conversationId": "chat_01JCHAT23456789",
    "clientId": "client_123",
    "agentId": "agent_01JABCDEF23456789",
    "status": "scheduled",
    "requestMessageId": "msg_user_01JCHAT98765432",
    "messages": [],
    "schedule": {
      "taskId": "task_01JTASK23456789",
      "scheduleAt": "2026-07-20T18:30:05.000Z",
      "delayMs": 5000
    },
    "timestamp": "2026-07-20T18:30:00.000Z"
  }
}
FieldTypeDescription
idstringCanonical ID pre-assigned to the document the task will create.
conversationIdstringchat_* ID of the thread the task will process; it is not the contact.
clientIdstringContact attributed to the turn.
agentIdstringAgent that will process the turn.
statusstringAlways scheduled in the HTTP 202 response (data.status).
requestMessageIdstringID reserved for the user's message.
messagesarrayAlways []; the task has not produced messages yet.
schedule.taskIdstringID of the Cloud Task created.
schedule.scheduleAtstringRun date, ISO 8601 UTC.
schedule.delayMsintegerConfigured delay. Only present when you send delay.
timestampstringDate the request was accepted, ISO 8601 UTC.

Errors

Statusdetails.codeWhen
400INVALID_REQUESTThe body fails validation (details.issues says what), or the credential covers several workspaces and workspace is missing or is not one of them
401UNAUTHENTICATEDThe credential is missing or not valid
404NOT_FOUNDThe agent does not exist or is not active, the conversationId is not an API chat in the workspace, or client.id does not exist
409CONTACT_BLOCKEDThe contact is blocked (details.clientId); the agent does not answer them
409CONFLICTYou try to change client.id in a conversation that already exists
502UPSTREAM_ERRORThe chat service failed or the turn could not be scheduled. If the conversation already existed or was created, details.conversationId identifies it
504UPSTREAM_TIMEOUTThe agent did not finish in time. Check details.conversationId with Get a chat before retrying
{
  "code": 409,
  "error": "Conflict - The resource state conflicts with this request",
  "details": {
    "code": "CONTACT_BLOCKED",
    "message": "Contact is blocked",
    "clientId": "client_123",
    "status": "blocked"
  }
}

See Errors for the full shape of an error.