Skip to main content
Every non-2xx response from the Brew Public API v1 returns the same JSON envelope. Branch on error.code (stable), not on error.message (human-readable, can change).

The Error Envelope

details Shape: PUBLISH_VALIDATION_FAILED (409)

When PATCH /v1/automations/{automationId} with { published: true } is blocked, details.blockers[] enumerates every node-level reason so callers can render a fix-it list.

details Shape: AUTOMATION_GRAPH_INVALID (400)

When POST /v1/automations (or PATCH with new nodes/connections) fails the server-side FK + structural resolver, details.issues[] enumerates every problem. Each carries a kind you can branch on:

Foundational Error Codes (Every Endpoint)

These can appear on any v1 endpoint:

Resource-Specific Codes

Triggers (/v1/automations/triggers)

Automations (/v1/automations)

Automation Runs (/v1/automations/runs)

Emails (/v1/emails)

Sends (/v1/sends)

Domains Lifecycle (/v1/domains)

Audiences (/v1/audiences)

Contacts + Fields (/v1/contacts, /v1/fields)

SDK Error Handling (TypeScript)

The official @brew.new/sdk throws a typed BrewApiError on every non-2xx response, exposing the full envelope:

Branching Agent / SDK Logic on code

Three rules:
  1. code is stable. It’s part of our public contract. We will not change the spelling of a code; we may add new ones.
  2. type is a coarse bucket for default UX. Use type === 'rate_limit' to gate a retry; use type === 'authentication_error' to ask the user to re-issue the key.
  3. Never branch on message. Operator-facing copy may change between releases.

See Also

Need help?

Our team is ready to support you at every step of your journey with Brew. Choose the option that works best for you:

Search Documentation

Type in the “Ask any question” search bar at the top left to instantly find relevant documentation pages.

ChatGPT/Claude Integration

Click “Open in ChatGPT” at the top right of any page to analyze documentation with ChatGPT or Claude for deeper insights.