Skip to main content
All errors return a single nested envelope. The flat {error, code} shape used in earlier docs has been replaced. See the migration note below if you have older code.

Fields

Error types

Use error.type to route an error to the right handler. Each type maps to a typed exception class in the SDKs.

HTTP status codes

Error codes

Authentication

Resources

Billing

Other billing rule violations return a descriptive error.message with error.type set to invalid_request_error and the HTTP status shown, without a dedicated error.code today. This covers a missing plan, coupon, promotion code, or customer (404), an inactive coupon or expired promotion code, and a subscription that is not in an active state (409 or 422). Branch on error.type and the HTTP status, and read error.message. Dedicated billing codes are being added incrementally.

Plans, quotas, and availability

These are the gates paying merchants hit as they grow. Each carries extra fields for programmatic handling.

Validation + rate limiting

The account_suspended error

When your account is suspended, every API request returns 403 account_suspended - including read-only endpoints. Hosted checkout pages and payment links also stop working.
Contact support@paybridgenp.com to appeal or resolve the suspension.

Handling errors in code

Migrating from the flat envelope

If you have integration code written before the new envelope, here is the upgrade path. The change is breaking - upgrade your SDK and any direct error parsing in lockstep.

Old shape

New shape

What changed

  • error is now an object instead of a string. Reading response.error directly will give you [object Object] instead of the message.
  • Read response.error.message for the human-readable string, response.error.type for the broad category, response.error.code for the specific identifier.
  • code: "unauthorized" was generic - it has been split into api_key_missing, api_key_invalid, api_key_revoked, api_key_expired so you can branch by failure mode.
  • Suspension fields previously at the top level (suspended_at, suspended_reason) are now nested under error.suspension.
  • All errors now include error.request_id matching the X-Request-Id response header. Quote it in support requests.

SDK versions

The TypeScript, PHP, and Python SDKs handle this transparently when you upgrade: