error.code are always consistent. Switch on code, surface message to your end user.
Codes
Plan-limit errors
Plan-limitFORBIDDEN errors carry a localized message such as “You have reached the maximum number of leads for your plan.” — surface it to your end users as-is, since they’re the ones who can take action (upgrade or remove records).
These come from the billing guards on:
POST /leads— whenmaxLeadsis exceeded.POST /projects— whenmaxProjectsis exceeded.POST /webhooks/subscriptions— whenmaxWebhookEndpointsis exceeded.
Validation errors
VALIDATION_ERROR messages list every field that failed in path: reason form, joined by ; :
Idempotency and retries
5xxand429are safe to retry. Use exponential backoff capped at theRetry-Aftervalue when present.4xx(other than429) means the request itself is wrong. Don’t retry without changing it.POST /webhooks/subscriptionsis idempotent when you passexternal_id— see Create a subscription.- Other writes are not idempotent. If you retry a
POST /leadsblindly, you’ll create duplicates. Use Search a lead first to de-dupe.