Integration
Error Codes
Complete reference of API error codes, HTTP status mappings, and resolution guidance.
Overview
PaymentHooks uses conventional HTTP status codes to indicate the success or failure of an API request. Every error response follows a consistent JSON envelope so your integration can programmatically inspect the error.code field and take the appropriate action.
Error response format
All API errors return the standard ApiResponse envelope with data: null and a populated error object.
{"data": null,"error": {"code": "VALIDATION_ERROR","message": "transactionLocalCurrencyAmount must be positive","fields": { "transactionLocalCurrencyAmount": "Required" },"details": { ... }}}
| Field | Type | Description |
|---|---|---|
| code | string | Machine-readable error constant (e.g. VALIDATION_ERROR). |
| message | string | Human-readable description of the error. |
| fields | object? | Per-field validation messages. Present on some VALIDATION_ERROR responses. |
| details | object? | Extra context on some errors (e.g. FRAUD_BLOCKED includes the risk score and rules). |
HTTP status codes
HTTP status codes are grouped into client errors (4xx) and server or upstream errors (5xx).
| Status | Label | Description |
|---|---|---|
400 | Bad Request | The body or query parameters are invalid, or the request is not allowed in the current state (e.g. SESSION_CLOSED). |
401 | Unauthorized | No valid API key or session was provided. |
402 | Payment Required | A checkout payment was blocked by fraud screening. |
403 | Forbidden | The caller is not allowed to perform the action, or the API key lacks a required scope. |
404 | Not Found | The resource does not exist or belongs to another account. |
409 | Conflict | The request conflicts with the current state of a resource. |
410 | Gone | The payment link is inactive or the checkout session has expired. |
422 | Unprocessable Entity | The request is valid but the resource's state does not allow it. |
429 | Too Many Requests | Returned by endpoints with their own limiter (sign-in, sign-up, password reset, custom domains, webhook simulation, log submission). |
500 | Internal Server Error | An unexpected error occurred on the server. |
502 | Bad Gateway | A payment gateway, email provider, or other upstream service failed. |
503 | Service Unavailable | A required dependency such as the database is unavailable. |
Error code reference
Each error code maps to a specific HTTP status and carries a fixed meaning. Use the code field for programmatic branching, not the HTTP status alone.
VALIDATION_ERRORHTTP 400One or more request fields failed validation.
- A required field is missing (e.g. customerId or transactionLocalCurrencyAmount on POST /payments).
- A field has the wrong type or is out of range.
- An email is not a valid address, or a phone is not valid for its country (customers, checkout pay endpoints). `error.fields` names the field; a national number without a country needs `country` (customers) or `phoneCountry` (checkout).
- The Idempotency-Key header is longer than 200 characters.
- The request body is not valid JSON.
- A PUT body contains an unknown or server-managed field (e.g. merchantId, transactionAmountUsdCents, status); error.fields names it.
- A checkout session webhookUrl does not use https.
- A gateway connection is created without a required credential, such as the webhook signing secret for Stripe, PayPal, Square, Braintree, Cashfree, or Instamojo (optional for Razorpay).
- itemLocalCurrency is missing while a line is priced inline (an amount without priceId); error.fields.itemLocalCurrency names the line. Send it, or name your prices on every line (see /docs/money-and-currencies).
- A pre-2026-10-28 money name (e.g. `currency`) and its current name (`itemLocalCurrency`) are both sent with different values; error.fields names both.
- An invoice supplyDate (POST /invoices, PUT /invoices/:id) is not a real YYYY-MM-DD day, or is more than 365 days after or 6 years before today; error.fields.supplyDate names the rule.
- A pre-2026-10-28 money name whose current field the endpoint does not take, e.g. `currency` on PUT /payment-links/:id (a link keeps its currency). The message names the rename; see /docs/upgrading-field-names.
Read error.message and, when present, error.fields (per-field messages). Fix the values and retry.
CSRF_INVALIDHTTP 403A dashboard session request sent an X-CSRF-Token header that does not match the session.
- Only applies to cookie-authenticated dashboard requests that include the header. API-key requests are not affected.
Reload the dashboard to obtain a fresh session token.
FORBIDDENHTTP 403The authenticated principal may not perform this action.
- The action is restricted to a different role (e.g. an admin account calling a merchant-only create endpoint).
Call the endpoint with a merchant API key or a merchant account.
INSUFFICIENT_SCOPEHTTP 403The API key is valid but missing the scope this endpoint requires.
- For example, POST /payments requires payments:write.
- Publishable (phk_pub_) keys only carry payments:read, customers:read, and products:read, so every write fails.
- Every merchant endpoint is scope-checked, including routing, payment_links, billing, tax, reports, and account endpoints.
The message names the missing scope. In Developers → API Keys, choose Edit permissions on the key and add it (or choose Full access). The change applies on the next request; the secret key stays the same.
NOT_FOUNDHTTP 404The requested resource does not exist.
- Incorrect ID in the URL or body.
- The resource belongs to a different merchant account.
Verify the ID. List resources first to confirm it exists in your account.
DUPLICATE_EMAILHTTP 409A customer with this email already exists in your account.
- POST /customers with an email already used by one of your customers (compared case-insensitively). The existing customer is not changed.
Look the customer up and use its id, or update it with PUT /customers/:id.
CUSTOMER_ARCHIVEDHTTP 409The customer is archived and cannot be used for new checkouts, payments, subscriptions or invoices.
- POST /checkout-sessions, /subscriptions or /invoices for an archived customer (by customerId or customerEmail).
- Paying a checkout session or payment link with an archived customer's email.
Unarchive the customer with POST /customers/:id/unarchive, then retry.
CUSTOMER_HAS_ACTIVE_SUBSCRIPTIONSHTTP 409The customer cannot be archived while a subscription can still bill them.
- POST /customers/:id/archive while a subscription is active, trialing or past_due. error.details.subscriptions lists them.
Cancel those subscriptions, then archive the customer.
IDEMPOTENCY_CONFLICTHTTP 409The idempotencyKey body field of POST /payments was already used with a different request.
- Re-using an idempotencyKey with a different body.
Use a new idempotencyKey for each distinct payment; reuse a key only for exact retries.
SESSION_ALREADY_COMPLETEDHTTP 409The checkout session has already been paid.
- POST /checkout-sessions/:id/pay was called again for a completed session.
Create a new checkout session for a new payment.
DISPUTE_CLOSEDHTTP 409The dispute is already won or lost; a closed outcome cannot be changed.
- PUT /disputes/:id with a different status for a dispute that is won or lost. Sending the same outcome again returns 200 and changes nothing.
Nothing to do: the outcome and its effect on the payment are final.
PAYMENT_IN_PROGRESSHTTP 409A payment for this checkout session is already being processed.
- Two requests for one checkout session at the same time to POST /checkout-sessions/:id/pay (a charge or a Stripe/Razorpay confirmation), /pi or /razorpay-order: a double click, a second tab, the checkout page and the success page confirming the same payment.
Do not retry straight away. Wait for the other request to answer, then read the session: complete means it is paid. The lock is released when that request ends and expires after 120 seconds at most.
IDEMPOTENCY_IN_PROGRESSHTTP 409A request with this Idempotency-Key is still being processed.
- POST /payments/:id/refund was sent again with the same Idempotency-Key header while the first request was still running.
Retry with the same key after the first request answers: a successful refund is then replayed (24 hours), a failed one can be retried. A claim left by a crashed request expires after 2 minutes.
GATEWAY_NOT_CONNECTEDHTTP 409 / 422No active gateway connection is available for the request.
- 409: the gateway that processed the payment has no active connection to refund through.
- 422: POST /payments set gatewayId, but your account has no enabled, active connection for it in the current mode (test-mode accounts only use sandbox connections).
Connect or re-enable the gateway in the matching mode, or omit gatewayId to use your routing rules.
ENDPOINT_INACTIVEHTTP 409A webhook delivery cannot be redelivered because its endpoint is not active.
- POST /webhooks/logs/:id/replay or /resend for an endpoint whose status is disabled.
Re-enable the endpoint with PUT /webhooks/endpoints/:id, then redeliver.
CONFLICTHTTP 409The request conflicts with the current state of a resource.
- Deleting a business entity that still has active API keys.
- Signing up with an email that already has an account.
- POST /features with a key another of your features already uses (error.fields.key).
- A meter event reached a usage period that closed while it was being recorded; retry it with the same identifier.
Resolve the conflicting state first (e.g. revoke keys), then retry.
SESSION_CLOSEDHTTP 400The checkout session is no longer open for payment.
- The session is not in status open or pending.
Create a new checkout session.
UNSUPPORTED_CURRENCYHTTP 422The selected gateway accepts none of the customer's currency, USD or the session's itemLocalCurrency.
- The chosen gateway connection's supported currencies (narrowed by its currency restrictions) include none of them.
Choose a gateway that supports the currency, or price in a supported currency.
TARGET_CURRENCY_UNSUPPORTEDHTTP 422A routing rule names a gateway connection that cannot charge the currency its conditions require.
- The rule has a currency eq or currency in condition and a target, route or fallback connection's gateway does not support that currency, or the connection's enabled currencies leave it out.
Enable the currency on that connection (Gateways > the gateway > Connection Settings), choose another connection, or change the currency condition. error.fields names the connection field.
PRICE_CHANGEDHTTP 409The checkout price changed after the page loaded, so the charge was not made.
- The live exchange rate for the customer's currency moved by more than 1% between page load and Pay.
Reload the checkout page to see the current price, then pay again.
BILLING_ADDRESS_REQUIREDHTTP 422A charge was started on a checkout session that has no billing country (or no state in India, the United States or Canada when tax follows the address). Tax is calculated from the billing address, so nothing was charged.
- The session was created without customerCountry and the customer had not selected a billing address on the checkout yet.
Send customerCountry (and customerState) when creating the session, or let the customer select the billing address on the hosted checkout (PUT /v1/checkout-sessions/{id}/billing-address).
POSTAL_CODE_PROVINCE_MISMATCHHTTP 400The Canadian postal code sent to PUT /v1/checkout-sessions/{id}/billing-address belongs to another province than the state sent (GST/HST differs by province). Nothing was applied; error.details.postalProvince names the postal code's province.
- The customer picked one province and typed a postal code from another (a typo, or a moved address).
Ask the customer which is right: send the postal code's province as state, or correct the postal code. The hosted checkout shows this choice.
LOCATION_EVIDENCE_MISMATCHHTTP 422The merchant requires two matching pieces of location evidence (Settings > Tax > Require matching location evidence) and the billing country does not match the country of the customer's IP address (or the IP country is unknown). Nothing was charged.
- The customer is travelling or uses a VPN.
- The billing country was selected by mistake.
- The edge proxy in front of PaymentHooks sends no IP country header.
The customer checks the billing country. The merchant can turn the setting off: conflicts are then only listed in Tax report > Location evidence conflicts for review.
EXCEEDS_REFUNDABLEHTTP 400The refund amount (USD cents) is greater than the payment's remaining refundable balance (transactionAmountUsdCents less transactionRefundedAmountUsdCents).
- Previous partial refunds already used part of the balance.
Refund at most the remaining balance.
EXTERNAL_TRANSACTION_CONFLICTHTTP 409An external transaction (or an external refund) with this id is already recorded with different details.
- POST /v1/external-transactions with an externalProvider + externalTransactionId already recorded with another amount, currency, rate, customer, status or invoice.
- POST /v1/external-transactions/:id/refunds with an externalRefundId already recorded with another amount.
Send the same body to replay safely (200, X-Idempotent-Replayed: true). To settle a pending record use PATCH; to correct a wrong one, void it and record it again.
EXTERNAL_TRANSACTION_IMMUTABLEHTTP 422PATCH /v1/external-transactions/:id tried to change a field fixed when the payment was recorded.
- The body carried externalProvider, externalTransactionId, transactionLocalCurrency, transactionLocalCurrencyAmount, the rate, occurredAt, invoiceId, businessEntityId or paymentMethod.
Record a refund for a smaller amount, or void the record (DELETE) and record it again.
EXTERNAL_INVOICE_MISMATCHHTTP 422The invoiceId sent with an external transaction cannot be paid by it.
- The invoice is in another currency or due another amount.
- The invoice belongs to another customer.
Send the invoice's own currency, total and customer, or record the payment without invoiceId.
EXTERNAL_PAYMENT_REFUNDHTTP 422POST /v1/payments/:id/refund was called for a payment recorded from another service; PaymentHooks cannot return money it did not take.
- The payment has source external (recorded through POST /v1/external-transactions).
Refund the customer on the other service, then record it with POST /v1/external-transactions/:id/refunds.
SIGNATURE_INVALIDHTTP 400 / 401A signature check failed.
- 400: the Razorpay payment signature sent to POST /checkout-sessions/:id/pay did not verify.
- 401: an incoming gateway webhook signature did not verify.
Check that the gateway secret configured on the connection matches the gateway dashboard.
FRAUD_BLOCKEDHTTP 402Fraud screening blocked the checkout payment.
- The risk score exceeded your block threshold. error.details lists the score and matching rules.
Review the triggered rules. Adjust them if the payment was legitimate.
LINK_INACTIVEHTTP 410The payment link is not active.
- The link's status was changed from active.
Set the link's status back to active with PUT /payment-links/:id, or share a new link.
EXPIREDHTTP 410The checkout session has passed its expiresAt (24 hours after creation).
- The public checkout page was opened, or a payment was attempted, after expiry. Expired sessions are never charged.
Create a new checkout session.
INVALID_STATEHTTP 422 / 409The resource's current status does not allow the action.
- Refunding a payment that is not success or disputed (a dispute_lost payment was already returned to the customer).
- Pausing a subscription that is not active or trialing, resuming one that is not paused, or cancelling one already cancelled.
- Marking a paid, void or cancelled invoice as paid (422), or a concurrent change while marking it (409).
- Voiding a paid invoice, or paying a paid or void invoice on its hosted page (409).
- Finalising a draft invoice that was voided before it was issued (409), or changing supplyDate on an invoice that is already issued (409; error.fields.supplyDate).
- Issuing a credit note against an unpaid invoice or a payment that took no money (409): void an unpaid invoice instead.
- Changing a quote that is accepted, canceled or expired (409).
- Creating a subscription against a price whose billing interval is not supported.
- Capturing a payment that is not requires_capture (returned with HTTP 400).
Retrieve the resource and check its status before retrying.
CAPTURE_NOT_SUPPORTEDHTTP 422Manual capture through the API is not available for this payment's gateway.
- Only test-mode authorizations can be captured via POST /payments/:id/capture.
Capture the authorization from the gateway dashboard.
NO_RECIPIENTHTTP 422The invoice cannot be sent because the customer has no email address.
- POST /invoices/:id/send for a customer without an email.
Add an email to the customer, then send again.
CONNECTION_FAILEDHTTP 422 / 502A connection test failed.
- 422: gateway marketplace credential test failed (invalid credentials or mode mismatch).
- 502: the EmailHooks connection test could not reach the EmailHooks API.
Double-check the credentials and mode, then test again.
RATE_LIMITEDHTTP 429Too many requests: your plan's per-second API limit, or an endpoint that has its own limiter.
- More API-key requests in one second than your plan allows (per account, across all keys); Retry-After: 1.
- Repeated sign-in, sign-up, password reset, MFA, custom domain, webhook simulation, or log submission requests.
Wait and retry with exponential backoff, honouring Retry-After when present.
API_QUOTA_EXCEEDEDHTTP 429Your plan's monthly API request quota is used and the plan refuses requests beyond it.
- This calendar month's API-key requests reached the quota shown on Settings > Plans & Usage.
Wait until the quota resets (Retry-After, X-RateLimit-Reset: the 1st of next month, UTC) or upgrade your plan.
INTERNAL_ERRORHTTP 500An unexpected server-side error occurred.
- Unhandled exception or database failure.
- Fraud screening was unavailable during a checkout payment. Screening fails closed, so the payment is rejected and no gateway is called.
Retry with exponential backoff. If it persists, contact support with the endpoint, time, and resource IDs.
GATEWAY_REJECTEDHTTP 502The gateway refused the refund.
- The gateway returned an error; the message carries its reason.
Resolve the issue reported by the gateway, then retry.
SCHEDULING_FAILEDHTTP 502 / 503A subscription renewal could not be scheduled, so the change was not applied.
- POST /subscriptions (503 with Retry-After, error.details.retryable true): the subscription is not created.
- POST /subscriptions/:id/resume: the subscription stays paused.
- A plan change from the billing page: the plan is not changed.
Retry the request. If it keeps failing, contact support with the subscription or customer id.
NO_SAVED_PAYMENT_METHODHTTP 422POST /subscriptions asked for collectionMethod "charge_automatically" but the customer has no saved payment method PaymentHooks can debit for this subscription.
- No active automatic-payment authorisation for this customer, or it is in another currency, below the renewal amount, expired, or on a fixed-amount CCAvenue standing instruction.
Omit collectionMethod (renewals are invoiced), send "send_invoice", or have the customer pay a subscription checkout first.
PLAN_CHANGE_PENDINGHTTP 409Another plan change is waiting for the customer to pay its prorated difference.
- POST /subscriptions/:id/change-plan or the billing page change plan, with an unpaid upgrade to a different price.
Wait for the payment, let its link expire, or repeat the same change to get the same payment link.
EMAIL_SEND_FAILEDHTTP 502The invoice email could not be delivered; the invoice stays unsent.
- The email provider returned an error.
Retry POST /invoices/:id/send.
EXTERNAL_API_ERROR / REFRESH_FAILEDHTTP 502The currency rate provider failed while refreshing exchange rates.
- The upstream currency API returned an error or was unreachable.
Retry the refresh later.
Codes by API area
Codes returned by one area of the API, in addition to the general codes above.
Checkout sessions and subscription lines
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
INVALID_MODE | 400 | mode is not "payment" or "subscription". | Send one of the two modes. |
NO_RECURRING_ITEM | 400 | A subscription session has no recurring line and no priceId. | Add recurring to at least one line item, or send a recurring priceId. |
RECURRING_IN_PAYMENT_MODE | 400 | A one-time (mode payment) session sent recurring or priceId. | Use mode "subscription", or drop recurring and priceId. |
CONFLICTING_PRICE | 400 | priceId and metadata.priceId name different prices, or recurring lines were combined with a priceId. | Send either recurring line items or one priceId. |
PRICE_NOT_FOUND | 400 | A priceId is not one of your active prices. | Use an active price id from GET /v1/prices. |
PRICE_NOT_RECURRING | 400 | The price has no billing interval, so it cannot start a subscription. | Use a recurring price, or send the line as recurring inline. |
PRICE_AMOUNT_MISMATCH | 400 | A line's unitPrice differs from its price's amount. | Omit unitPrice to use the price's amount. |
CURRENCY_MISMATCH | 400 | A price is in another currency than the itemLocalCurrency sent, or (with no itemLocalCurrency) the request's prices are in different currencies; the message names each price. Same code on checkout sessions, invoices, quotes, payment links and coupons. | Use prices in one currency, or create the session in the prices' currency. See /docs/money-and-currencies. |
INVALID_STARTS_AT | 400 | recurring.startsAt is not an ISO date or a real calendar day. | Send YYYY-MM-DD or a date-time with a time zone. |
STARTS_AT_IN_PAST | 400 | recurring.startsAt is not in the future. | Omit startsAt to charge the first period now. |
STARTS_AT_TOO_FAR | 400 | recurring.startsAt is more than 3 years away. | Choose a start within 3 years. |
NO_AMOUNT_DUE | 400 | Every recurring line starts later and nothing would be charged today. | Send the first period as a one-time line item: the first payment authorises the renewals. |
TRIAL_MISMATCH | 422 | The checkout's recurring lines do not share one free trial (different trialDays, a trial next to none, a trial with recurring.startsAt, or a trial priceId with first-charge lines). | Use prices with the same trialDays in one checkout, or sell them in separate checkouts. |
TRIAL_UNSUPPORTED_GATEWAY | 422 | No gateway enabled for subscriptions can run this free-trial checkout without charging early. | Enable Stripe or Razorpay for subscriptions (with one-time lines: also Cashfree, PhonePe or PayPal); the message names them. |
TRIAL_SETUP_REQUIRED | 409 | A charge route was called for a free-trial checkout that charges nothing today. | Start the trial with POST /api/v1/checkout-sessions/{id}/trial. |
TRIAL_NOT_APPLICABLE | 409 | POST .../trial was called for a session with an amount due today (or without a trial). | Pay it with POST /api/v1/checkout-sessions/{id}/pay; its trial still starts after the payment. |
QUANTITY_NOT_ADJUSTABLE | 409 | The customer tried to change or remove a line that is not adjustableQuantity. | Set adjustableQuantity: true on lines the customer may change. |
NO_SUBSCRIPTION_GATEWAY | 422 | A subscription checkout was paid but no connected gateway supports automatic renewals. | Connect and enable a gateway with renewals (Stripe, Razorpay, Cashfree, PhonePe, PayPal, CCAvenue). |
TERMS_NOT_ACCEPTED | 400 | Your policies are set, and the customer did not accept the terms. | The customer ticks the terms box on the checkout. |
GATEWAY_NOT_FOUND | 400 | The selected gateway connection does not exist for this session. | Choose one of the session's availableGateways. |
GATEWAY_NOT_CONFIGURED | 400 | The gateway connection is missing its credentials. | Enter the gateway's keys under Gateways > Marketplace (open the gateway). |
GATEWAY_READBACK_FAILED | 502 | The gateway took the payment but its charged amount could not be read back. | Check the payment in the gateway dashboard; the session completes when its webhook arrives. |
PHONE_REQUIRED | 400 | An automatic-payment setup needs the customer's mobile number. | Collect the phone with its country code. |
Coupons at checkout
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
COUPON_NOT_FOUND | 404 | No coupon has this code. | Check the code with the customer. |
COUPON_INACTIVE | 400 | The coupon is switched off. | Activate it under Coupons, or use another. |
COUPON_EXPIRED | 400 | The coupon's expiry date has passed. | Extend it or issue a new coupon. |
COUPON_EXHAUSTED | 400 | The coupon reached its redemption limit. | Raise the limit or issue a new coupon. |
COUPON_MIN_PURCHASE | 400 | The order is below the coupon's minimum purchase. | The message states the minimum. |
Customer email and phone
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
EMAIL_REQUIRED | 400 | An email is needed and none was sent. | Send the customer's email. |
EMAIL_INVALID | 400 | The email is not a valid address. | Send [email protected] form; error.fields.email names the field. |
PHONE_INVALID | 400 | The phone is not a valid number for its country. | Send it international (+91 97461 02494) or national with country. |
PHONE_COUNTRY_REQUIRED | 400 | A national phone number was sent without its country. | Add country (customers) or phoneCountry (checkout), or send +<country code>. |
PHONE_INVALID_CHARACTERS | 400 | The phone contains characters other than digits, spaces, dots, dashes and brackets. | Send digits with optional separators. |
Subscriptions and add-ons
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
MIXED_INTERVALS | 400 | POST /v1/subscriptions items bill on different intervals. | Every item of one subscription bills on the same interval; create a subscription per interval, or use a checkout session (one subscription per billing cycle). |
SUBSCRIPTION_NOT_FOUND | 404 | The subscription does not exist on your account. | Check the subscription id. |
SUBSCRIPTION_CANCELLED | 400 | A plan change was requested on a cancelled subscription. | Create a new subscription. |
PRICE_INACTIVE | 400 | The new plan's price is archived. | Choose an active price. |
BLOCKED_BY_SUBSCRIPTIONS | 409 | The price cannot be deleted while active subscriptions use it. | Archive the price instead (status archived), or move the subscriptions first. |
METER_INACTIVE | 422 | A usage event was sent for an inactive meter. | Reactivate the meter. |
SETUP_NOT_AVAILABLE | 422 | A setup session cannot be opened: automatic payments are already active, or the subscription is past_due, paused, cancelled, ends at period end or renews by invoice. | For past_due, the customer uses Update payment method on the billing page (pay and re-authorise). |
NO_SETUP_GATEWAY | 422 | No gateway enabled for subscriptions can save a payment method without a payment. | Enable Stripe or Razorpay for subscriptions, or let the customer set up automatic payments when the renewal is due. |
SETUP_UNSUPPORTED | 422 | The chosen gateway cannot save a payment method without a payment. | Choose a gateway the setup page marks as available. |
SETUP_NOT_CONFIRMED | 409 | Stripe has not confirmed the SetupIntent. | Finish the card authentication, then confirm again. |
SETUP_SESSION | 409 | A payment route was called with a setup-only session. | Setup sessions take no payment; use the setup page at /checkout/setup/{id}. |
Invoices, credit notes and quotes
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
TAX_STATE_REQUIRED | 422 | US sales tax needs the customer's state or ZIP code. | Add the customer's US address. |
MERCHANT_COUNTRY_REQUIRED | 422 | Tax collection is on but your business profile has no country, so tax cannot be calculated (it is never assumed). | Set your business address in Settings > Profile. |
MERCHANT_STATE_REQUIRED | 422 | A US or Canadian business sells at home but its business profile has no state or province. US sales tax is collected in your home state and the states you registered; Canadian provincial tax (QST, PST, RST) in your home province and the provinces you registered. It is never assumed. | Set your business address state or province in Settings > Profile. |
EXCEEDS_CREDITABLE | 422 | The credit note is larger than what is left to credit on the invoice or payment. | The message states the amount left. |
ALREADY_VOIDED | 409 | The credit note is already voided. | Nothing to do. |
NOT_VOIDABLE | 409 | The credit note cannot be voided in its current state (for example its refund was made). | Issue a new document to correct it. |
CREDIT_ALREADY_SPENT | 409 | The customer already used this credit, so it cannot be taken back. | Invoice the customer for the amount instead. |
QUOTE_EXPIRED | 410 / 422 | The quote passed its expiry date (410 on the customer's quote page, 422 when sending or accepting it). | Create a new quote. |
ALREADY_ANSWERED | 409 | The quote was already accepted, declined or changed. | Reload the quote. |
PRICE_NOT_QUOTABLE | 400 | A quote line names a recurring, tiered or metered price; a quote is billed once. | Use an active one-time, per-unit price, or type the line with unitAmount. |
Features, entitlements and usage
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
ENTITLEMENT_LIMIT_REACHED | 409 | Usage would go above the feature's maximum and the price's overage policy is restrict. Returned by PUT /v1/customers/:id/feature-usage/:key (going up; going down always succeeds) and POST /v1/meter-events; the event is not stored. Also the reason of a failed check. | Ask the customer to upgrade, set an override, reduce usage first (a customer over the maximum after a downgrade must go below it), or turn overage on for the feature on the price (allow or bill). |
ENTITLEMENT_OVERAGE_CAP_REACHED | 409 | A metered feature billing overage reached its overageCap above the maximum. The meter event is not stored. | Raise or remove overageCap on PUT /v1/prices/:id/feature-overage, or give the customer an override. |
NO_ENTITLEMENT | 409 | A quantity in use (PUT /v1/customers/:id/feature-usage/:key) was reported for a feature no active, trialing or past-due subscription of the customer grants (or the plan has it disabled). A meter event without a grant is stored as a meter reading instead. | Check access first with POST /v1/customers/:id/entitlements/:key/check, or include the feature on the customer's product. |
FEATURE_METER_BILLED_BY_PRICE | 409 | PUT /v1/prices/:id/feature-overage set policy bill on a feature whose meter is already billed by one of your metered prices, which would charge the same usage twice. | Use restrict for that feature, or bill the usage with the metered price only. |
FEATURE_METER_AGGREGATION_UNSUPPORTED | 409 | POST /v1/features named a meter whose aggregation is max or last. A metered feature counts usage with a sum or count meter. | Create a sum or count meter for the feature and send its id as meterId. |
Businesses and custom domains
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
BUSINESS_NOT_FOUND | 422 | The businessEntityId is not one of your businesses. | Use an id from GET /v1/business-entities. |
BUSINESS_MISMATCH | 422 | The API key belongs to another business than the one named in the request. On products: a business key created a product for another business, several, or every business ([]), or tried to change a product's businessEntityIds. | Omit businessEntityId / businessEntityIds (the key's business applies), use a key of that business, or change a product's businesses in the dashboard. |
DOMAIN_TAKEN | 409 | The domain is already connected to a PaymentHooks account. | Remove it from the other account first. |
DNS_NOT_READY | 422 | The domain's DNS records are not set up yet; error.details.dnsCheck lists each record. | Add the records shown in Settings > Branding & domains, then verify again. |
HOSTNAME_INVALID | 400 | Not a valid domain name. Related: HOSTNAME_REQUIRED, HOSTNAME_TOO_LONG, HOSTNAME_IS_IP, HOSTNAME_WILDCARD, HOSTNAME_PUBLIC_SUFFIX, HOSTNAME_UNKNOWN_TLD, HOSTNAME_RESERVED, HOSTNAME_PLATFORM. | Use a subdomain you own, such as pay.example.com. |
Plan limits and rate limits
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
PLAN_LIMIT_REACHED | 403 | Your PaymentHooks plan's allowance is used up (for example custom domains or monthly payments). | Upgrade the plan under Settings > Plans & Usage. |
PLAN_FEATURE_UNAVAILABLE | 403 | The feature is not included in your plan (webhooks, analytics, roles, insights, custom domain). | Upgrade the plan. |
Gateways, routing and webhooks
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
CONNECTION_NOT_FOUND | 422 / 404 | A routing rule names a gateway connection that is not yours or does not exist (422); an incoming gateway webhook URL names no connection (404). | Use a connection id from GET /v1/gateways. |
GATEWAY_MISMATCH | 422 | A routing rule's gatewayId does not match its connection's gateway. | Send the connection's catalog gateway id, or omit gatewayId. |
TOKENIZATION_FAILED | 422 | The card could not be tokenized. | The message carries the gateway's reason. |
GATEWAY_SUBMIT_FAILED | 502 | Dispute evidence was saved but the gateway refused it. | Fix what the message reports and submit again. |
ENDPOINT_NOT_FOUND | 404 | A simulated webhook names an endpoint URL you have not registered. | Register the endpoint first. |
ENDPOINT_NO_SECRET | 409 | The endpoint has no signing secret. | Rotate its secret, then send again. |
Handling errors
const res = await fetch('/api/v1/payments', { method: 'POST', ... });const json = await res.json();if (json.error) {switch (json.error.code) {case 'VALIDATION_ERROR':// Inspect json.error.fields for per-field messagesbreak;case 'INVALID_STATE':// Re-fetch the resource and check its statusbreak;case 'UNAUTHORIZED':// Re-authenticate or refresh API keybreak;default:// Log and surface the error}}