Wocha Docs

validation_error

Validation failures — field-level errors and payload fixes

HTTP status: 400 / 422
Category: API client errors

What this error means

The request body or query parameters failed server-side validation. The API returns field-level details when available.

Related codes: invalid_request, missing_tenant, and billing_not_configured.

Common causes

  • Required fields omitted from the request body
  • Invalid format (slug, email, URL, enum value)
  • Value out of allowed range or length
  • Tenant context missing (X-Tenant-ID or tenant claim in token)
  • Calling billing endpoints before Stripe is configured

How to fix it

  1. Inspect fieldErrors on WochaValidationError (maps from the API errors object).
  2. Compare your payload against the OpenAPI spec.
  3. Ensure Content-Type: application/json and valid JSON syntax.
  4. Pass X-Tenant-ID when using tokens without an embedded tenant claim.
  5. Fix the payload before retrying — validation errors are not transient.

Example

import { WochaValidationError } from "@wocha/sdk";
 
try {
  await wocha.organisations.create({ slug: "Bad Slug!", display_name: "Engineering" });
} catch (err) {
  if (err instanceof WochaValidationError && err.fieldErrors) {
    for (const [field, messages] of Object.entries(err.fieldErrors)) {
      console.error(`${field}: ${messages[0]}`);
    }
  } else if (err instanceof WochaValidationError) {
    console.error(err.message, err.docsUrl);
  }
}

See also

On this page