invalid_json

The request body is not valid JSON. Nothing was done; serialize the body with a JSON library and send it again.

HTTP 400The request was malformed.

When it fires

The request body could not be parsed as JSON, so the request was refused before anything was done. The usual causes are a body built by string concatenation (an unescaped quote or a trailing comma), shell quoting that ate part of a curl -d body, or a form-encoded body sent where JSON is expected.

Response shape

Every Repull error follows the same envelope. The code is stable and safe to switch on.

{
  "error": {
    "code": "invalid_json",
    "message": "Body must be valid JSON.",
    "fix": "Send `{\"message\": \"…\"}` with `Content-Type: application/json`.",
    "docs_url": "https://repull.dev/docs/errors/invalid_json",
    "request_id": "req_01J5X7Y8Z9ABCDEF12345678"
  }
}

How to fix

  1. Build the body with a JSON serializer (`JSON.stringify`, `json.dumps`) rather than by hand.
  2. Send `Content-Type: application/json`.
  3. With curl, wrap the body in single quotes so the shell leaves the double quotes inside it alone, or use `--data @body.json`.

Common gotchas

  • JSON does not allow trailing commas, comments or single-quoted strings, even though JavaScript object literals do.
  • Nothing was done, so fix the body and send it again. If you used an Idempotency-Key, use a new one for the corrected body.

Examples

curl

# Single quotes around the body keep the JSON intact
curl -X POST https://api.repull.dev/v1/conversations/164743/messages \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "Your check-in details are ready."}'

TypeScript

await fetch('https://api.repull.dev/v1/conversations/164743/messages', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.REPULL_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ message: 'Your check-in details are ready.' }), // never hand-built
})

If you're an AI agent

The request body is not valid JSON. Serialize it with a JSON library, send Content-Type: application/json, and send it again. Nothing was done.

Hit an error that isn't covered? Email hello@repull.dev with the request id from the response headers.

AI