---
docId: doc_7ea58febc8ed42ac9a8404296d154994
title: Send a message to the agent
description: "Start or continue a chat with an agent, immediately or on a schedule."
api:
  group: agentes/chat
  auth: bearer
  operations:
    - operationId: sendChatMessage
      method: POST
      path: /v1/chat
      postmanName: Send a message to the agent
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Send a message to the agent

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

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X POST "https://api.platic.ai/v1/chat" \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "agentId": "'"$AGENT_ID"'",
  "message": "Which plan fits a team of 25?"
}'
```

</Ways.Way>
<Ways.Way name="sdk">

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

</Ways.Way>
</Ways>

<Note type="important">

Without scheduling, this endpoint is **synchronous and does not stream**. With `delay` or `scheduleAt`, it accepts the turn with HTTP `202` and runs it later.

</Note>

## Query parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `workspace` | string | Only if the credential covers several workspaces: the workspace of the agent and the conversation. Required in that case | — |

## Request body

To start a conversation:

```json
{
  "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.

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `message` | string | Text the agent receives. Optional when you send `attachments`. | ✓¹ |
| `attachments` | array | Up to 10 images or files referenced by URL; each must be smaller than 20 MB. | ✓¹ |
| `agentId` | string | Main agent of the thread. Required when starting; when continuing, a different ID changes the main agent without creating another thread. | When starting |
| `conversationId` | string | ID returned by a previous turn. Send it to continue that thread. | — |
| `additionalInstructions` | string | Extra instructions for the agent. **They only affect the current turn** and do not change its configuration or later turns. | — |
| `client` | object | The person or contact talking to the agent. If omitted, the user who owns the API key is used automatically. | — |
| `delay` | integer | Delay in milliseconds, from `3000` to `86400000` (24 hours). Cannot be combined with `scheduleAt`. | — |
| `scheduleAt` | string | Future 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.

```json
{
  "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"
    }
  ]
}
```

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `attachments[].url` | string URL | Public or signed `http(s)` URL of the file. | ✓ |
| `attachments[].mimeType` | string | MIME type, for example `image/jpeg` or `application/pdf`. | ✓ |
| `attachments[].filename` | string | File 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:

```json
{
  "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](/help/agents/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:

```json
{
  "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:

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

<Note type="note">

`additionalInstructions` applies only to this request. If you need the same instruction in another turn, send it again.

</Note>

## Schedule a turn

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

```json
{
  "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:

```json
{
  "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`.

<Note type="note">

`scheduleAt` schedules a contact turn with an agent and belongs to the Chat flow. It is not the `scheduleTime` of `POST /v1/messages`, and you cannot read, reschedule or cancel it with [Scheduled messages](/api-reference/messages/scheduled).

</Note>

## 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](/api-reference/conversations/finish) or [Archive a conversation](/api-reference/conversations/archive), 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`:

```json
{
  "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"
  }
}
```

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique, canonical ID of the document. Use it to read or manage the chat. |
| `conversationId` | string | ID of the `chat_*` thread. Save it to continue the conversation; it does not identify the contact. |
| `clientId` | string | Contact the conversation was attributed to. |
| `agentId` | string | Main agent of the thread. |
| `reactivated` | boolean | `true` when the message reopened a closed or expired conversation. |
| `agentChanged` | boolean | `true` when this turn changed the responding agent. |
| `status` | string | `completed` when the turn finished successfully. It is the turn's state, inside `data`; the root `status` is always `success`. |
| `requestMessageId` | string | ID of the message sent by this request. The agent's replies have their own IDs in `messages[].id`. |
| `messages` | array | Messages the agent generated during the turn. |
| `messages[].id` | string | Message ID. |
| `messages[].role` | string | `assistant`. |
| `messages[].content` | string | Content of the reply. |
| `messages[].contentType` | string | Content type of the reply. |
| `timestamp` | string | Completion date and time, ISO 8601. |
| `reason` | string, optional | `outside_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](/api-reference/agents/configuration#schedule).

## Scheduled response

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

```json
{
  "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"
  }
}
```

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Canonical ID pre-assigned to the document the task will create. |
| `conversationId` | string | `chat_*` ID of the thread the task will process; it is not the contact. |
| `clientId` | string | Contact attributed to the turn. |
| `agentId` | string | Agent that will process the turn. |
| `status` | string | Always `scheduled` in the HTTP `202` response (`data.status`). |
| `requestMessageId` | string | ID reserved for the user's message. |
| `messages` | array | Always `[]`; the task has not produced messages yet. |
| `schedule.taskId` | string | ID of the Cloud Task created. |
| `schedule.scheduleAt` | string | Run date, ISO 8601 UTC. |
| `schedule.delayMs` | integer | Configured delay. Only present when you send `delay`. |
| `timestamp` | string | Date the request was accepted, ISO 8601 UTC. |

<Note type="note">

The `202` does not include the agent's reply. After `scheduleAt`, read [`GET /v1/chat/{id}`](/api-reference/chat/get) or use `get_chat` in MCP. `GET /v1/conversations/{conversationId}` keeps a legacy fallback, but it is not the recommended option.

The `id` is pre-assigned before the task runs. The document may not exist yet, so `GET /v1/chat/{id}` can return `404` until the task runs.

</Note>

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | The body fails validation (`details.issues` says what), or the credential covers several workspaces and `workspace` is missing or is not one of them |
| `401` | `UNAUTHENTICATED` | The credential is missing or not valid |
| `404` | `NOT_FOUND` | The agent does not exist or is not active, the `conversationId` is not an API chat in the workspace, or `client.id` does not exist |
| `409` | `CONTACT_BLOCKED` | The contact is blocked (`details.clientId`); the agent does not answer them |
| `409` | `CONFLICT` | You try to change `client.id` in a conversation that already exists |
| `502` | `UPSTREAM_ERROR` | The chat service failed or the turn could not be scheduled. If the conversation already existed or was created, `details.conversationId` identifies it |
| `504` | `UPSTREAM_TIMEOUT` | The agent did not finish in time. Check `details.conversationId` with [Get a chat](/api-reference/chat/get) before retrying |

```json
{
  "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](/api-reference/errors) for the full shape of an error.
