Skip to main content

invalid_request

The body never got as far as being read as fields, so nothing was created, sent or charged. This is distinct from validation_error, where the JSON parsed and a field was then rejected.

Status: 400

{
"status": 400,
"type": "invalid_request",
"message": "Invalid JSON in request body: unexpected end of JSON input",
"request_id": "req_01J8K2P...",
"doc_url": "https://docs.epostix.com/errors/invalid_request"
}

message varies and names the parse failure.

Why you got this

  • The body is empty on an endpoint that expects JSON.
  • The JSON is truncated, usually a missing closing brace or a connection that closed mid-write.
  • A trailing comma, a single-quoted string or an unquoted key. JSON allows none of these.
  • The body was assembled by string concatenation and a value contains an unescaped quote or newline.

How to fix it

Serialise the body with your language's JSON encoder instead of building the string by hand, and log the exact bytes you sent when this happens. message is the whole story here, because no field was ever inspected.

If Content-Type is anything other than application/json, the request fails earlier as unsupported_media_type.

Is it safe to retry

No, not unchanged. Fix the body first, then send it.

Reusing the Idempotency-Key from a rejected request is safe, because a request that failed to parse was never stored.