Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.paybridgenp.com/llms.txt

Use this file to discover all available pages before exploring further.

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.
{
  "error": {
    "message": "Invalid API key. Verify the key in your dashboard at https://dashboard.paybridgenp.com.",
    "type": "authentication_error",
    "code": "api_key_invalid",
    "request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW"
  }
}

Fields

FieldTypeDescription
error.messagestringHuman-readable explanation. Safe to surface in logs; safe to show developers. Not always safe to show end users.
error.typestring (enum)Broad category - SDKs use this to instantiate typed exceptions. See error types.
error.codestringSpecific, stable identifier for programmatic branching. See error codes.
error.request_idstringSame value as the X-Request-Id response header. Quote in support requests for fastest triage.
error.suspensionobjectPresent only on code: "account_suspended" - includes suspended_at and reason.
error.pauseobjectPresent only on code: "token_paused" - includes paused_at and reason.

Error types

Use error.type to route an error to the right handler. Each type maps to a typed exception class in the SDKs.
TypeStatus rangeMeaning
authentication_error401Auth credentials missing or invalid
account_error403, 423Credentials valid but the account or token is not in good standing
permission_error403Action not permitted (missing scope, wrong key type, plan gate)
invalid_request_error400, 404, 409, 422Request was malformed, references something that does not exist, or violates business rules
idempotency_error409Concurrent request with same Idempotency-Key
rate_limit_error429Rate-limit window exhausted - back off and retry
api_error500-599Server-side failure - safe to retry

HTTP status codes

StatusTypical typeNotes
400invalid_request_errorValidation failure
401authentication_errorMissing or invalid API key
403permission_error or account_errorPermission gate or suspended account
404invalid_request_errorResource not found or not visible to your project
409invalid_request_error or idempotency_errorState conflict, or Idempotency-Key collision
422invalid_request_errorRequest is valid but the action cannot be performed
423account_errorMCP token paused for anomalous activity
429rate_limit_errorSee Retry-After, X-RateLimit-Remaining, X-RateLimit-Reset headers
500api_errorServer-side failure - safe to retry with backoff

Error codes

Authentication

CodeStatusDescription
api_key_missing401No Authorization header, or empty key portion
api_key_invalid401Key not recognised - typo, deleted project, or wrong environment
api_key_revoked401Key was explicitly revoked from the dashboard
api_key_expired401Key passed its expiration timestamp
api_key_must_be_secret403Endpoint requires sk_...; a publishable pk_... was sent
account_suspended403Merchant account suspended - see error.suspension
token_paused423MCP token paused due to anomalous activity - see error.pause
forbidden403Key doesn’t have permission for this action
wrong_mode403Sandbox key used on a live resource or vice versa

Resources

CodeStatusDescription
not_found404Resource not found or not visible to your project
already_exists409Resource with that identifier already exists
invalid_state409Resource is in a state that doesn’t allow this action
idempotency_conflict409Concurrent request with same Idempotency-Key is still in flight

Billing

CodeStatusDescription
subscription_not_active422Subscription is not in an active state
trial_already_ended409Trial has already ended and cannot be modified
coupon_inactive422Coupon has been deactivated
promotion_code_invalid422Promotion code is invalid or expired
plan_not_found404Plan does not exist or has been deactivated

Validation + rate limiting

CodeStatusDescription
invalid_request_error400Generic validation failure - read error.message for the specific issue
rate_limited429Public-API rate-limit window exhausted

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.
{
  "error": {
    "message": "This merchant account has been suspended. Contact support@paybridgenp.com to resolve.",
    "type": "account_error",
    "code": "account_suspended",
    "request_id": "req_...",
    "suspension": {
      "suspended_at": "2026-04-20T10:00:00.000Z",
      "reason": "Violation of terms of service"
    }
  }
}
Contact support@paybridgenp.com to appeal or resolve the suspension.

Handling errors in code

import PayBridge, { AuthenticationError, RateLimitError, InvalidRequestError } from "@paybridge-np/sdk";

const client = new PayBridge({ apiKey: process.env.PAYBRIDGE_API_KEY });

try {
  const payment = await client.payments.get("pay_abc123");
} catch (err) {
  if (err instanceof AuthenticationError) {
    // Re-prompt for credentials
  } else if (err instanceof RateLimitError) {
    // Back off and retry after err.retryAfter seconds
  } else if (err instanceof InvalidRequestError) {
    // Bad input - log err.code and err.message
  } else {
    throw err;
  }
}

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

{
  "error": "Invalid API key",
  "code": "unauthorized"
}

New shape

{
  "error": {
    "message": "Invalid API key",
    "type": "authentication_error",
    "code": "api_key_invalid",
    "request_id": "req_..."
  }
}

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:
LanguagePre-envelopePost-envelope
TypeScript (@paybridge-np/sdk)< 3.0.0>= 3.0.0
PHP (paybridge-np/sdk)< 3.0.0>= 3.0.0
Python (paybridge-np)< 1.0.0>= 1.0.0