---
title: "Send message"
description: "Delivers a message from one session into another with server-stamped session.message provenance, so the receiving agent can tell the sending session apart from its own user."
url: "https://www.thecompany.company/docs/api/sessions/send-message"
---

# Send message

> Delivers a message from one session into another with server-stamped session.message provenance, so the receiving agent can tell the sending session apart from its own user.

- **Surface:** The App API
- **Endpoint:** `POST https://api.thecompany.company/v1/sessions/{id}/messages`
- **Operation ID:** `sessions.sendMessage`
- **Authentication:** `Authorization: Bearer <TOKEN>`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | `path` | `string` | Yes |  |

## Request Body (`application/json`)

**Required:** Yes

Schema: `object`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | `string` | Yes |  |
| `behavior` | `string \| null` | No |  |
| `fileIds` | `array<string>` | No | Uploaded file IDs, resolved from stored records. |
| `senderSessionId` | `string` | Yes | Session the message is sent from. Must be readable by the caller and different from the target; the delivery is stamped with it. |
| `messageId` | `string` | No | Idempotency key for the delivery. Authorized retries with the same key deduplicate; omitted, each request delivers once. |

## Responses

### `204`

<No Content>

### `400` (`application/json`)

SessionSelfSendError

Schema: `SessionSelfSendError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `id` | `string` | Yes | TypeID with prefix "asess_". |

Example:

```json
{
  "_tag": "SessionSelfSendError",
  "id": "asess_01jd8z3k5q0b6f2m4r7t9v1x3c"
}
```

### `401` (`application/json`)

AuthenticationError

Schema: `AuthenticationError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `reason` | `string` | Yes |  |
| `description` | `string` | No |  |

Example:

```json
{
  "_tag": "AuthenticationError",
  "reason": "invalid_session",
  "description": "string"
}
```

### `402` (`application/json`)

OrganizationUnsubscribedError

Schema: `OrganizationUnsubscribedError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `code` | `string` | Yes |  |

Example:

```json
{
  "_tag": "OrganizationUnsubscribedError",
  "code": "ORGANIZATION_UNSUBSCRIBED"
}
```

### `403` (`application/json`)

ActorUnauthorizedError | UnauthorizedError | IdentityMismatchError | RequestedOrganizationError

Schema: `ActorUnauthorizedError | UnauthorizedError | IdentityMismatchError | ...`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `$ (ActorUnauthorizedError)._tag` | `string` | Yes |  |
| `$ (UnauthorizedError)._tag` | `string` | Yes |  |
| `$ (UnauthorizedError).entity` | `string` | Yes |  |
| `$ (UnauthorizedError).action` | `string` | Yes |  |
| `$ (IdentityMismatchError)._tag` | `string` | Yes |  |
| `$ (RequestedOrganizationError)._tag` | `string` | Yes |  |
| `$ (RequestedOrganizationError).reason` | `string \| null` | Yes |  |

Example:

```json
{
  "_tag": "ActorUnauthorizedError"
}
```

### `404` (`application/json`)

FileNotFoundError | SessionNotFoundError

Schema: `FileNotFoundError | SessionNotFoundError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `$ (FileNotFoundError)._tag` | `string` | Yes |  |
| `$ (FileNotFoundError).id` | `string` | Yes | TypeID with prefix "file_". |
| `$ (SessionNotFoundError)._tag` | `string` | Yes |  |
| `$ (SessionNotFoundError).id` | `string` | Yes | TypeID with prefix "asess_". |

Example:

```json
{
  "_tag": "FileNotFoundError",
  "id": "file_01jd8z3k5q0b6f2m4r7t9v1x3c"
}
```

### `409` (`application/json`)

SessionArchivedError | SessionRecipientUnavailableError | SessionQuestionReplyRejectedError

Schema: `SessionArchivedError | SessionRecipientUnavailableError | SessionQuestionReplyRejectedError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `$ (SessionArchivedError)._tag` | `string` | Yes |  |
| `$ (SessionArchivedError).id` | `string` | Yes | TypeID with prefix "asess_". |
| `$ (SessionArchivedError).eventAccepted` | `boolean` | No |  |
| `$ (SessionArchivedError).acceptedOrdinal` | `integer` | No |  |
| `$ (SessionRecipientUnavailableError)._tag` | `string` | Yes |  |
| `$ (SessionRecipientUnavailableError).id` | `string` | Yes | TypeID with prefix "asess_". |
| `$ (SessionQuestionReplyRejectedError)._tag` | `string` | Yes |  |
| `$ (SessionQuestionReplyRejectedError).toolCallId` | `string` | Yes |  |
| `$ (SessionQuestionReplyRejectedError).reason` | `string \| null` | No |  |

Example:

```json
{
  "_tag": "SessionArchivedError",
  "id": "asess_01jd8z3k5q0b6f2m4r7t9v1x3c",
  "eventAccepted": true,
  "acceptedOrdinal": 1
}
```

### `410` (`application/json`)

SessionRuntimeGoneError

Schema: `SessionRuntimeGoneError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `id` | `string` | Yes | TypeID with prefix "asess_". |

Example:

```json
{
  "_tag": "SessionRuntimeGoneError",
  "id": "asess_01jd8z3k5q0b6f2m4r7t9v1x3c"
}
```

### `429` (`application/json`)

RateLimitExceededError

Schema: `RateLimitExceededError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `resource` | `string` | Yes | Rate-limited resource bucket the request was counted against. |
| `retryAfter` | `number` | Yes |  |

Example:

```json
{
  "_tag": "RateLimitExceededError",
  "resource": "string",
  "retryAfter": 1
}
```

### `500` (`application/json`)

InternalError

Schema: `InternalError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |

Example:

```json
{
  "_tag": "InternalError"
}
```

### `502` (`application/json`)

ActorActionError

Schema: `ActorActionError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |
| `code` | `string` | Yes |  |
| `acceptedEvents` | `integer` | No |  |
| `totalEvents` | `integer` | No |  |

Example:

```json
{
  "_tag": "ActorActionError",
  "code": "string",
  "acceptedEvents": -9007199254740991,
  "totalEvents": -9007199254740991
}
```

### `503` (`application/json`)

ActorUnavailableError

Schema: `ActorUnavailableError`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `_tag` | `string` | Yes |  |

Example:

```json
{
  "_tag": "ActorUnavailableError"
}
```

## Example Request

### cURL

```bash
curl -X POST 'https://api.thecompany.company/v1/sessions/{id}/messages' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d @- <<'JSON'
{
  "message": "string",
  "senderSessionId": "string"
}
JSON
```

### TypeScript

```typescript
const response = await fetch('https://api.thecompany.company/v1/sessions/{id}/messages', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "message": "string",
  "senderSessionId": "string"
}),
});
if (!response.ok) {
  throw new Error('HTTP ' + response.status);
}
```
