> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.rray.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.rray.app/_mcp/server.

# Send Message Batch

POST https://api.rray.app/v1/messages/batch
Content-Type: application/json

Send 1 to 100 messages in one request. Results are positional: the i-th
element of `items` is the outcome of the i-th message you sent.

`RRay-Batch-Validation: strict` (the default) rejects the whole batch with `422` if any
message is invalid and sends nothing; `permissive` sends the valid messages and returns a
per-position error object for each invalid one. Allowance rejections are positional too:
all accepted is `202`, some turned away for allowance is `207`, and a batch refused in
full is one top-level `402`, `403` or `429` naming the ceiling that stopped it.

`207 Multi-Status` means exactly one thing: part of the batch was turned away by an
allowance ceiling. A delivery failure on an otherwise-sent batch is not a `207` — that
position carries `message.injection_failed` and the batch stays `202`, because the
request itself was accepted.

Reference: https://docs.rray.app/api/api-reference/messages/batch

## Authentication

- `Authorization` header (bearer token, required) — A workspace key (`rray_live_…`, bound to one workspace) or the account's platform key. Platform keys name the target workspace with `RRay-Workspace-Id`. See [Credentials](https://docs.rray.app/docs/concepts/authentication).

## Request

### Headers

- `RRay-Batch-Validation` (string, optional, default: strict) — `strict` (the default) rejects the whole batch with `422` if any message is invalid and sends nothing; `permissive` sends the valid messages and returns a per-position error object for each invalid one.
- `Idempotency-Key` (string, optional, nullable) — Makes a retry safe. The first request with a key performs the batch; a retry with the same key and the same body replays the whole positional result, sending nothing again. The same key with a different body is `409 idempotency.body_mismatch`. Claims are kept for 24 hours, then the key is free to reuse. Omit the header and every attempt sends.
- `RRay-Workspace-Id` (string, optional, nullable) — The workspace to act on. Required with a platform key; rejected with a workspace key, which already carries its workspace — a matching value is rejected too, rather than silently ignored. An id that is not yours returns `404 workspace.not_found`.

### Body (application/json)

This endpoint expects a list of SendMessageRequest.

- `list of SendMessageRequest`

## Response

### 202

Successful Response

- `summary` (BatchSummary, required) — Per-request tally so the caller can branch without scanning ``items``. Endpoint- agnostic (``total`` / ``success_count`` / ``error_count`` mirror the ``result`` discriminator) so every batch response across the API reuses this one model.
- `items` (list of BatchResponseItemsItems, required)

## Errors

### 400 Bad Request Error

Bad Request

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 401 Unauthorized Error

Unauthorized

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 402 Payment Required Error

Payment Required

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 403 Forbidden Error

Forbidden

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 404 Not Found Error

Not Found

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 409 Conflict Error

Conflict

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 413 Content Too Large Error

Request Entity Too Large

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 422 Unprocessable Entity Error

Unprocessable Entity

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 429 Too Many Requests Error

Too Many Requests

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 500 Internal Server Error

Internal Server Error

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 502 Bad Gateway Error

Bad Gateway

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

## Types

### SendMessageRequest

One outgoing message. Each address across ``to``/``cc``/``bcc`` becomes its own delivery, tracked and counted separately.

- `from` (string, required) — Sender address, optionally with a display name (`Acme Receipts <receipts@mail.rray.app>`). Use an address on a sending domain you have added, so the message can be signed — unsigned mail is very likely to be refused by the recipient's provider.
- `to` (list of string, required) — Primary recipients, at least one. An address may not repeat anywhere across `to`, `cc` and `bcc`.
- `cc` (list of string, optional, nullable) — Carbon-copy recipients. Visible to every recipient.
- `bcc` (list of string, optional, nullable) — Blind carbon-copy recipients. Not visible to other recipients, but each one is a delivery you can track like any other.
- `reply_to` (SendMessageRequestReplyTo, optional, nullable) — Where replies should go instead of `from` — one address or several.
- `subject` (string, optional, nullable) — Subject line. Single-line text.
- `html` (string, optional, nullable) — HTML body. Send `html`, `text`, or both; with both, the recipient's client picks the part it prefers.
- `text` (string, optional, nullable) — Plain-text body.
- `attachments` (list of Attachment, optional, nullable) — Files to attach, totalling at most 10 MiB once decoded.

### BatchSummary

Per-request tally so the caller can branch without scanning ``items``. Endpoint- agnostic (``total`` / ``success_count`` / ``error_count`` mirror the ``result`` discriminator) so every batch response across the API reuses this one model.

- `total` (integer, required) — Number of items in the request.
- `success_count` (integer, required) — Items with `result` `success`.
- `error_count` (integer, required) — Items with `result` `error`.

### BatchResponseItemsItems

- `result`: `error` (BatchItemFailure)
  - `error` (BatchItemProblem, required) — The error for one failed item in a batch — a trimmed ``Problem``: the request-wide ``status``/``instance``/``request_id`` live on the envelope, so only the per-item identity + structured cause is carried.
- `result`: `success` (BatchItemSuccess)
  - `id` (string, required) — Identifier of the accepted message (see `GET /v1/messages/{id}`).

### ValidationIssue

One failed field — an entry of the ``invalid_params`` array (a request field the caller can fix). Shared by schema-validation failures (pydantic) and field-scoped business rules (e.g. a duplicate recipient), so the two cannot drift in shape.

- `field` (string, required) — Path of the request field that failed, e.g. `to`, `attachments[0]`.
- `message` (string, required) — Human-readable explanation of this field error (safe to surface in a UI).
- `kind` (string, required) — Machine-readable CAUSE token (finer than the error `code`): a pydantic type (`missing`, `string_too_long`, `value_error`) for a schema failure, or a business cause — `duplicate`, `invalid_base64`, `unsupported_scheme`, `missing_host`, `unresolvable_host`, `private_address`, `size_exceeded`, `plan_restricted`. Branch on this, not `message`.

### StateError

One failed resource-state precondition — an entry of the ``state_errors`` array. Unlike ``invalid_params`` it points at a resource/account state (not a request field), e.g. an unverified sender domain or insufficient credits.

- `resource` (string, required) — The resource whose state blocked the request, e.g. `sender_domain`.
- `message` (string, required) — Human-readable explanation of the state problem (safe to surface in a UI).
- `kind` (string, required) — Machine-readable CAUSE token (finer than the error `code`), e.g. `unverified`.
- `resource_id` (string, optional, nullable) — Identifier of that resource, e.g. `example.com`.

### SendMessageRequestReplyTo

Where replies should go instead of `from` — one address or several.

- string
- list of string

### Attachment

One outgoing attachment. Bytes come from exactly one source — `content` (base64) OR `url` (we fetch it). Set `content_id` to make it an inline part an HTML body can reference via `cid:<content_id>`.

- `filename` (string, required) — Name the recipient sees. No path separators and no executable extension (`.exe`, `.js`, `.bat`, … are refused outright).
- `content` (string, optional, nullable) — The file as base64. Set this OR `url`, never both. All attachments on one message must total at most 10 MiB once decoded.
- `url` (string, optional, nullable) — Public `http(s)` URL to fetch the file from. Set this OR `content`, never both. The target must resolve to a public address, and the fetch counts against the same 10 MiB per-message budget.
- `content_type` (string, optional, nullable) — MIME type. Guessed from `filename` when omitted, falling back to `application/octet-stream`.
- `content_id` (string, optional, nullable) — Set this to make the file an inline part your `html` can reference as `cid:<content_id>`. A simple token: no angle brackets, no newlines.

### BatchItemProblem

The error for one failed item in a batch — a trimmed ``Problem``: the request-wide ``status``/``instance``/``request_id`` live on the envelope, so only the per-item identity + structured cause is carried.

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `billing.daily_cap_reached`, `billing.overage_cap_reached`, `billing.plan_quota_exhausted`, `billing.workspace_limit_exceeded`, `message.injection_failed`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.duplicate_recipient`, `validation.invalid_attachment`, `validation.request_invalid`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`).
  - Allowed values: `authorization`, `billing`, `rate_limit`, `upstream`, `validation`
- `detail` (string, optional, nullable) — Human-readable explanation of this error; omitted when `title` says it all.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; else omitted.

## Examples

**Request**

```json
[
  {
    "from": "Acme Receipts <receipts@mail.rray.app>",
    "to": [
      "billing@rray.app"
    ],
    "subject": "Your receipt for order 1042",
    "html": "<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>",
    "text": "Thanks! Order 1042 is confirmed."
  },
  {
    "from": "Acme Receipts <receipts@mail.rray.app>",
    "to": [
      "billing@rray.app"
    ],
    "cc": [
      "records@rray.app"
    ],
    "bcc": [
      "archive@rray.app"
    ],
    "reply_to": "support@rray.app",
    "subject": "Invoice 1042",
    "text": "Your invoice is attached.",
    "attachments": [
      {
        "filename": "invoice-1042.pdf",
        "content": "JVBERi0xLjQKJcTl8uXrp3Mg==",
        "content_type": "application/pdf"
      }
    ]
  }
]
```

**Response**

```json
{
  "summary": {
    "total": 1,
    "success_count": 1,
    "error_count": 1
  },
  "items": [
    {
      "result": "success",
      "id": "string"
    }
  ]
}
```

**SDK Code**

```python Two messages in one request
import requests

url = "https://api.rray.app/v1/messages/batch"

payload = [
    {
        "from": "Acme Receipts <receipts@mail.rray.app>",
        "to": ["billing@rray.app"],
        "subject": "Your receipt for order 1042",
        "html": "<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>",
        "text": "Thanks! Order 1042 is confirmed."
    },
    {
        "from": "Acme Receipts <receipts@mail.rray.app>",
        "to": ["billing@rray.app"],
        "cc": ["records@rray.app"],
        "bcc": ["archive@rray.app"],
        "reply_to": "support@rray.app",
        "subject": "Invoice 1042",
        "text": "Your invoice is attached.",
        "attachments": [
            {
                "filename": "invoice-1042.pdf",
                "content": "JVBERi0xLjQKJcTl8uXrp3Mg==",
                "content_type": "application/pdf"
            }
        ]
    }
]
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Two messages in one request
const url = 'https://api.rray.app/v1/messages/batch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '[{"from":"Acme Receipts <receipts@mail.rray.app>","to":["billing@rray.app"],"subject":"Your receipt for order 1042","html":"<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>","text":"Thanks! Order 1042 is confirmed."},{"from":"Acme Receipts <receipts@mail.rray.app>","to":["billing@rray.app"],"cc":["records@rray.app"],"bcc":["archive@rray.app"],"reply_to":"support@rray.app","subject":"Invoice 1042","text":"Your invoice is attached.","attachments":[{"filename":"invoice-1042.pdf","content":"JVBERi0xLjQKJcTl8uXrp3Mg==","content_type":"application/pdf"}]}]'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Two messages in one request
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.rray.app/v1/messages/batch"

	payload := strings.NewReader("[\n  {\n    \"from\": \"Acme Receipts <receipts@mail.rray.app>\",\n    \"to\": [\n      \"billing@rray.app\"\n    ],\n    \"subject\": \"Your receipt for order 1042\",\n    \"html\": \"<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>\",\n    \"text\": \"Thanks! Order 1042 is confirmed.\"\n  },\n  {\n    \"from\": \"Acme Receipts <receipts@mail.rray.app>\",\n    \"to\": [\n      \"billing@rray.app\"\n    ],\n    \"cc\": [\n      \"records@rray.app\"\n    ],\n    \"bcc\": [\n      \"archive@rray.app\"\n    ],\n    \"reply_to\": \"support@rray.app\",\n    \"subject\": \"Invoice 1042\",\n    \"text\": \"Your invoice is attached.\",\n    \"attachments\": [\n      {\n        \"filename\": \"invoice-1042.pdf\",\n        \"content\": \"JVBERi0xLjQKJcTl8uXrp3Mg==\",\n        \"content_type\": \"application/pdf\"\n      }\n    ]\n  }\n]")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Two messages in one request
require 'uri'
require 'net/http'

url = URI("https://api.rray.app/v1/messages/batch")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n  {\n    \"from\": \"Acme Receipts <receipts@mail.rray.app>\",\n    \"to\": [\n      \"billing@rray.app\"\n    ],\n    \"subject\": \"Your receipt for order 1042\",\n    \"html\": \"<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>\",\n    \"text\": \"Thanks! Order 1042 is confirmed.\"\n  },\n  {\n    \"from\": \"Acme Receipts <receipts@mail.rray.app>\",\n    \"to\": [\n      \"billing@rray.app\"\n    ],\n    \"cc\": [\n      \"records@rray.app\"\n    ],\n    \"bcc\": [\n      \"archive@rray.app\"\n    ],\n    \"reply_to\": \"support@rray.app\",\n    \"subject\": \"Invoice 1042\",\n    \"text\": \"Your invoice is attached.\",\n    \"attachments\": [\n      {\n        \"filename\": \"invoice-1042.pdf\",\n        \"content\": \"JVBERi0xLjQKJcTl8uXrp3Mg==\",\n        \"content_type\": \"application/pdf\"\n      }\n    ]\n  }\n]"

response = http.request(request)
puts response.read_body
```

```java Two messages in one request
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.rray.app/v1/messages/batch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("[\n  {\n    \"from\": \"Acme Receipts <receipts@mail.rray.app>\",\n    \"to\": [\n      \"billing@rray.app\"\n    ],\n    \"subject\": \"Your receipt for order 1042\",\n    \"html\": \"<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>\",\n    \"text\": \"Thanks! Order 1042 is confirmed.\"\n  },\n  {\n    \"from\": \"Acme Receipts <receipts@mail.rray.app>\",\n    \"to\": [\n      \"billing@rray.app\"\n    ],\n    \"cc\": [\n      \"records@rray.app\"\n    ],\n    \"bcc\": [\n      \"archive@rray.app\"\n    ],\n    \"reply_to\": \"support@rray.app\",\n    \"subject\": \"Invoice 1042\",\n    \"text\": \"Your invoice is attached.\",\n    \"attachments\": [\n      {\n        \"filename\": \"invoice-1042.pdf\",\n        \"content\": \"JVBERi0xLjQKJcTl8uXrp3Mg==\",\n        \"content_type\": \"application/pdf\"\n      }\n    ]\n  }\n]")
  .asString();
```

```php Two messages in one request
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.rray.app/v1/messages/batch', [
  'body' => '[
  {
    "from": "Acme Receipts <receipts@mail.rray.app>",
    "to": [
      "billing@rray.app"
    ],
    "subject": "Your receipt for order 1042",
    "html": "<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>",
    "text": "Thanks! Order 1042 is confirmed."
  },
  {
    "from": "Acme Receipts <receipts@mail.rray.app>",
    "to": [
      "billing@rray.app"
    ],
    "cc": [
      "records@rray.app"
    ],
    "bcc": [
      "archive@rray.app"
    ],
    "reply_to": "support@rray.app",
    "subject": "Invoice 1042",
    "text": "Your invoice is attached.",
    "attachments": [
      {
        "filename": "invoice-1042.pdf",
        "content": "JVBERi0xLjQKJcTl8uXrp3Mg==",
        "content_type": "application/pdf"
      }
    ]
  }
]',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Two messages in one request
using RestSharp;

var client = new RestClient("https://api.rray.app/v1/messages/batch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n  {\n    \"from\": \"Acme Receipts <receipts@mail.rray.app>\",\n    \"to\": [\n      \"billing@rray.app\"\n    ],\n    \"subject\": \"Your receipt for order 1042\",\n    \"html\": \"<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>\",\n    \"text\": \"Thanks! Order 1042 is confirmed.\"\n  },\n  {\n    \"from\": \"Acme Receipts <receipts@mail.rray.app>\",\n    \"to\": [\n      \"billing@rray.app\"\n    ],\n    \"cc\": [\n      \"records@rray.app\"\n    ],\n    \"bcc\": [\n      \"archive@rray.app\"\n    ],\n    \"reply_to\": \"support@rray.app\",\n    \"subject\": \"Invoice 1042\",\n    \"text\": \"Your invoice is attached.\",\n    \"attachments\": [\n      {\n        \"filename\": \"invoice-1042.pdf\",\n        \"content\": \"JVBERi0xLjQKJcTl8uXrp3Mg==\",\n        \"content_type\": \"application/pdf\"\n      }\n    ]\n  }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Two messages in one request
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  [
    "from": "Acme Receipts <receipts@mail.rray.app>",
    "to": ["billing@rray.app"],
    "subject": "Your receipt for order 1042",
    "html": "<h1>Thanks!</h1><p>Order 1042 is confirmed.</p>",
    "text": "Thanks! Order 1042 is confirmed."
  ],
  [
    "from": "Acme Receipts <receipts@mail.rray.app>",
    "to": ["billing@rray.app"],
    "cc": ["records@rray.app"],
    "bcc": ["archive@rray.app"],
    "reply_to": "support@rray.app",
    "subject": "Invoice 1042",
    "text": "Your invoice is attached.",
    "attachments": [
      [
        "filename": "invoice-1042.pdf",
        "content": "JVBERi0xLjQKJcTl8uXrp3Mg==",
        "content_type": "application/pdf"
      ]
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.rray.app/v1/messages/batch")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```