payload_too_large

HTTP 413 Don’t retry REST and MCP

The request carried more bytes than the limit for that kind of request, and it was stopped at the size check rather than being partially processed.

How to fix it

  1. Check which limit you hit before shrinking anything. A 1 MiB JSON cap and a 15 MiB attachment aggregate are different problems with different fixes.
  2. Declare the real byte length when reserving an upload. The completion check compares measured bytes against your declaration, so an understated declaration fails at the end rather than at the start.
  3. Keep text and html at or under 512,000 characters each. The send schema enforces that and reports it as invalid_request, not as this code.
  4. Link large files rather than attaching them. A send allows at most 10 attachments, each at most 10 MiB, totalling at most 15 MiB.

Which rule fired

Size is counted as the body streams, not taken from Content-Length, because Content-Length can be absent, understated or simply wrong and a limit that trusts it is not a limit. The cap applied depends on the route: 1 MiB for a JSON body, 10 MiB for the binary upload route. Attachments are checked again later, both individually at 10 MiB and in aggregate at 15 MiB, and again at completion against the size that was actually declared and reserved, because the only number worth trusting is the one measured server-side.

In error.messageMeans
Request body exceeds the allowed size. The streamed request body exceeds 1 MiB for a JSON route, or 10 MiB for the binary upload content route.
Upload exceeds the attachment size limit. An upload PUT carries more than 10 MiB of bytes.
Declared upload exceeds the attachment size limit. A declared upload size at reservation exceeds 10 MiB, is not a safe integer, or is not positive.
Upload exceeds its reservation. Uploaded bytes exceed the size the upload reserved, even when under the 10 MiB ceiling.
Verified size exceeds the reserved declaration. The verified stored size at completion is larger than the reserved declaration.
An attachment exceeds the file limit. A single attachment on a send exceeds 10 MiB.
Total attachments must be at most 15 MiB. The attachments on one send total more than 15 MiB.

Why it works this way: Counting streamed bytes rather than reading Content-Length is the load-bearing detail. A client that omits the header, or understates it, would otherwise walk straight past a check that looks correct in the code.

Example

PUT /v1/projects/{project_id}/uploads/{upload_id}/content → 413
{
  "error": {
    "code": "payload_too_large",
    "message": "Request body exceeds the allowed size.",
    "request_id": "req_8Kd2x91",
    "retryable": false,
    "details": {}
  }
}

Over MCP, send_message and create_draft return it as text in a result marked isError: true, not as this body.

Where it appears

  • POST /projects/{project_id}/uploads
  • PUT /projects/{project_id}/uploads/{upload_id}/content
  • POST /projects/{project_id}/uploads/{upload_id}/complete
  • POST /projects/{project_id}/inboxes/{inbox_id}/messages

Paths are relative to https://api.emailforagents.ai/v1.

View as Markdown

Search docs