invalid_cursor

HTTP 400 Don’t retry REST and MCP

The cursor you sent is not one this endpoint can resume from, either because it does not decode or because it was minted against a different set of filters.

How to fix it

  1. Restart the listing without a cursor. The first page is always reachable, and the cursor you were holding cannot be repaired.
  2. Keep the query parameters identical across a pagination run. A cursor is bound to the filter it was issued under, so changing the search term or the inbox mid-run invalidates it.
  3. Pass the cursor back exactly as received. Do not URL-decode it twice, trim it, or store it somewhere that truncates.
  4. For event polling, persist the cursor as a string. Some JSON parsers round a 19-digit sequence number through a double and corrupt the low digits.

Which rule fired

A mail cursor is not an opaque offset. It carries a version, a binding that identifies the query it was created for, a sort point and an expiry, and all four are checked on the way back in. Changing the filter between pages therefore invalidates the cursor rather than silently paginating a different result set. The event cursor is a separate, simpler thing: a decimal sequence number that must be a positive integer inside the signed 64-bit range.

In error.messageMeans
Cursor is invalid, expired, or belongs to another filter. A thread or message cursor fails to decode, has expired, or its binding does not match the filter on the current request.
Event cursor is not valid for this filter. An event cursor is not 1 to 19 decimal digits, or its value exceeds 9223372036854775807.

Why it works this way: Binding the cursor to the filter is the reason this error exists at all. The alternative is to accept the cursor and paginate the new filter from an offset that means nothing in it, which returns a plausible page that silently skips or repeats records.

Example

GET /v1/projects/{project_id}/inboxes/{inbox_id}/threads?cursor=… → 400
{
  "error": {
    "code": "invalid_cursor",
    "message": "Cursor is invalid, expired, or belongs to another filter.",
    "request_id": "req_8Kd2x91",
    "retryable": false,
    "details": {}
  }
}

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

Where it appears

  • GET /projects/{project_id}/inboxes/{inbox_id}/threads
  • GET /projects/{project_id}/inboxes/{inbox_id}/messages
  • GET /projects/{project_id}/events
  • MCP tool: list_threads
  • MCP tool: list_messages

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

View as Markdown

Search docs