invalid_body

A field in the request body failed validation.

HTTP 400The request was malformed.

When it fires

A field in the JSON request body did not pass validation. Common triggers:

  • A required field is missing (e.g. checkIn on a booking create).
  • A field has the wrong type (sending a string where a number is expected).
  • A nested object is malformed — for example, primaryGuest is present but does not include email.
  • The body is not valid JSON — a trailing comma, unquoted key, or unescaped newline.
  • The Content-Type header is missing or not application/json.

Response shape

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

{
  "error": {
    "code": "invalid_body",
    "message": "<human-readable explanation of what went wrong>",
    "docs_url": "https://repull.dev/docs/errors/invalid_body"
  }
}

How to fix

  1. Set `Content-Type: application/json` on every POST / PATCH / PUT request.
  2. Read err.message — it names the field and the rule (e.g. "primaryGuest.email is required").
  3. Pretty-print the body you sent and compare against the schema on the endpoint's API Reference page.
  4. If you are constructing the body from user input, run it through `JSON.parse(JSON.stringify(body))` first — this will surface non-serializable values (Date, undefined) before the request goes out.
  5. For deeply nested errors, look at err.field if your SDK exposes it — it includes the dotted path to the offending value.

Common gotchas

  • Empty body on a POST is invalid_body, not invalid_params. The two are separated so you can route them differently in your error handler.
  • undefined values in JavaScript objects are dropped by JSON.stringify. If a required field reads as missing on the server, double-check the value you are sending is not undefined.
  • For idempotent retries, fix the body and retry with the same Idempotency-Key. Repull will treat it as a new attempt because the previous one never reached business logic — see Idempotency.

Examples

curl

# Bad: missing required field
curl -X POST https://api.repull.dev/v1/reservations \
  -H "Authorization: Bearer sk_test_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"checkIn": "2026-06-01"}'

# {
#   "error": {
#     "code": "invalid_body",
#     "message": "checkOut is required"
#   }
# }

# Good
curl -X POST https://api.repull.dev/v1/reservations \
  -H "Authorization: Bearer sk_test_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"checkIn": "2026-06-01", "checkOut": "2026-06-05", "propertyId": "123"}'

TypeScript

import { Repull } from '@repull/sdk'

const repull = new Repull({ apiKey: process.env.REPULL_KEY! })

try {
  await repull.reservations.create({ checkIn: '2026-06-01' } as any)
} catch (err: any) {
  if (err.code === 'invalid_body') {
    // The SDK throws before the network call when it can — but server-side
    // validation always wins. err.message names the missing/invalid field.
    console.error('Bad request body:', err.message)
  }
  throw err
}

If you're an AI agent

A field in the body was rejected. Read err.message — it names the field. Patch THAT field, do not regenerate the whole body from scratch unless you also have new context. Then retry.

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

AI