Skip to main content

Errors

Every failed request gets the same JSON response: an HTTP status that names the kind of failure, and a body with one error object. Read the status first, then the type and code in the body.

One address answers a refusal in another body: the token address, POST /v1/oauth/token, follows the OAuth 2.0 standard. See Read a refusal of the token address.

Read the error shape​

The error object has five fields, and no others.

  • type: the group the error belongs to, such as invalid_request_error.
  • code: the stable, snake_case name of the failure, such as resource_not_found. Branch on code in your own code.
  • message: a sentence that says what went wrong. Show it to a developer, not as a fixed string to match.
  • param: the name of the field or header that caused the error, or null when no single one did.
  • request_id: the ID of the request, the same as its Request-Id header. See Request IDs.

A failed request always answers with Content-Type: application/json, whether or not it sends an Accept header.

Handle each status​

Each failure has one status, one type and one code. The table lists every code of the API, with its meaning.

StatusTypeCodeMeaning
401authentication_erroraccess_token_invalidThe access token is unknown or has expired. Request a new one.
403permission_erroraccount_not_accessibleThe Black-Account header names no account the caller may act in, whether that account exists or not; the answer is the same in every case, so it tells nothing about which accounts exist.
403permission_erroraccount_requiredThe request names no account this endpoint reaches: a vendor's API client names one of its sub-accounts in the Black-Account header, and a person signed in to the console names one of their accounts there; a vendor's home account is named only on the routes that reach it.
409invalid_request_erroralready_memberThe customer already holds a subscription that is unpaid, running or in its grace period, and a customer holds one at a time. Find it in the list of the customer's subscriptions; a new one can be created once it has ended.
409invalid_request_erroralready_team_memberThis email is already on the account's team, active or turned off.
409invalid_request_errorapi_client_already_revokedThis API client is already revoked. A revoked API client cannot be restored; create a new one instead.
409invalid_request_errorapi_client_limit_reachedThis environment already has the most active API clients it may hold. Revoke one before creating another.
401authentication_errorapi_client_revokedThe API client this access token was issued to has been revoked.
409invalid_request_errorapp_already_archivedThis app is archived. An archived app is archived for good and takes no change; register a new app instead.
401authentication_errorapp_archivedThe app of this publishable key is archived, so its keys are refused for good. Register a new app and use its key.
401authentication_errorauthentication_requiredThe request carried no access token; send one in the Authorization header as "Bearer" followed by the token.
401authentication_errorauthorization_header_malformedThe Authorization header must be "Bearer" followed by an access token.
503api_errorbilling_engine_unavailableBilling is unavailable for a moment and nothing was saved. Retry the request later.
409invalid_request_errorblockedThis customer is blocked, so they cannot subscribe, pay, or resume or change a membership until the block is removed.
409invalid_request_errorcancel_not_pendingThis subscription is not set to cancel at the end of its period, so there is no cancel to undo.
409invalid_request_errorcancel_pendingThis subscription is already set to cancel at the end of its period, so it takes no other cancel and no change of plan at the end of its period. Undo the cancel first.
402card_errorcard_declinedThe card was declined, and it was not saved. decline_reason says why. Ask the customer for another card, then try again.
422invalid_request_errorcard_payment_not_supportedBlack charges a card in this environment, and a card payment is not supported here. Subscribe with a card through a hosted checkout, POST /v1/client/checkout-sessions; the account changes the plan of a subscription Black charges.
401authentication_errorcheckout_secret_invalidThe Black-Checkout-Secret header must carry the secret of this checkout session, from the fragment of its url.
409invalid_request_errorcheckout_session_completeThis checkout session is complete: its payment is recorded, and it takes no other. Send the customer to its success address.
409invalid_request_errorcheckout_session_expiredThis checkout session has expired and takes no payment. Create a new checkout session.
409invalid_request_errorcheckout_session_not_confirmedThis checkout session has not been confirmed, so there is no declined payment to pay again. Confirm it first.
409invalid_request_errorcollection_method_mismatchThe account collects this invoice itself, so Black does not charge it. Report the payment with mark-paid instead.
409invalid_request_errorcommand_set_asideThis request could not be saved and has been set aside for our team to look at. Repeating it gives this answer until they have cleared it.
409invalid_request_errorconfirmation_requiredSubscriptions charged by Black are still running in this environment, and their renewals fail while no gateway is connected. Send confirm set to true to disconnect anyway.
400invalid_request_errorcredentials_in_query_stringThe address carried access_token, client_secret, api_key or refresh_token in its query string, which param names, so the request was refused before any credential was checked and nothing ran, even with a valid credential in its header; credentials go in a header or the request body, never the address.
409invalid_request_errorcredit_exceeds_chargeThe credit for the days left of the paid period is larger than the new plan's price, so the plan cannot be changed now. Change it at the end of the period instead.
422invalid_request_errorcurrency_not_supportedThe currency asked for is not one Black knows, is not written in capital letters, or is not on the environment's list of the currencies its prices may be shown and charged in; param names currency, and nothing was converted. A price asked for in its own currency is always shown unchanged.
409invalid_request_errorcustomer_already_blockedThis customer is already blocked. To give another reason, remove the block, then block the customer again.
409invalid_request_errorcustomer_already_flaggedThis customer is already flagged. To give another reason, remove the flag, then flag the customer again.
409invalid_request_errorcustomer_block_in_progressThis customer's block is still ending their subscriptions. Remove the block once every one has ended.
422invalid_request_errorcustomer_country_requiredThe environment takes its tax from a tax service, which needs the country to tax. Set the customer's address country, or send customer_country.
409invalid_request_errorcustomer_deletedThe customer of this subscription was deleted, so its first invoice takes no payment.
409invalid_request_errorcustomer_not_blockedThis customer is not blocked, so there is no block to remove.
409invalid_request_errorcustomer_not_flaggedThis customer is not flagged, so there is no flag to remove.
409invalid_request_errorcustomer_reference_in_useAnother customer in this environment has this reference. Send another reference, or first remove it from that customer.
401authentication_errorcustomer_session_expiredThe customer's access token has lapsed, or their session has ended. Exchange the refresh token for a new pair; when the refresh is refused too, sign the customer in again.
401authentication_errorcustomer_session_invalidThe customer's token is unknown, or was made for another app or another environment. Sign the customer in again with this app's publishable key.
401authentication_errorcustomer_session_requiredThis Client API call needs the customer's session as well as the publishable key.
409invalid_request_erroremail_in_useA sign-up, or a signed-in customer's change of email, was refused because another customer of the environment who signs in with Black's own sign-in already uses the email, an email identity or a proved one; param names email (none when the change is being confirmed), nothing was made or changed, and the customer signs in, asks for a link to set a new password, or keeps their email.
409invalid_request_errorexchange_rate_expiredThe exchange rate set named is no longer honoured: a newer set replaced it longer ago than the environment holds a shown price. Read the plans again and use the price they show.
503api_errorexchange_rate_unavailableNo exchange rate is in force: the newest rates Black holds are more than 48 hours old, or none has been fetched yet. Retry the request later.
409invalid_request_errorexport_too_largeMore customers match these filters than one export may hold. Narrow the filters, for example by a date range, and export each part.
409invalid_request_errorfeature_already_attachedThis feature is already attached to this product.
409invalid_request_errorfeature_inactiveThe feature is inactive and cannot be attached to a product. Make it active again, or attach another feature.
409invalid_request_errorfeature_lookup_key_in_useAnother feature in this environment, active or not, has this lookup key. Send another key.
409invalid_request_errorgateway_already_connectedThis environment already has a gateway connection. Replace its credentials, or disconnect it before connecting another.
422invalid_request_errorgateway_credentials_invalidThe gateway refused these credentials, and nothing was stored. Check the secret key, the prefix, the processing channel and the public key, then connect again.
422invalid_request_errorgateway_credentials_missing_permissionThe gateway accepted the secret key, but it lacks a permission Black uses, and nothing was stored. Give the key every permission Black needs, then connect again.
422invalid_request_errorgateway_credentials_wrong_environmentThese credentials belong to the gateway's other environment, and nothing was stored. A test environment takes the gateway's sandbox credentials, and a live environment its live ones.
409invalid_request_errorgateway_not_connectedThis environment has no active gateway connection, so Black cannot charge through one. Connect a gateway first, or replace the credentials of a failing one.
503api_errorgateway_unavailableThe payment gateway did not answer, and nothing was stored. Retry the request later.
503api_errorgoogle_keys_unavailableGoogle's signing keys could not be fetched with certainty, so the Google ID token was not checked and no session was made. Retry the request later.
401authentication_errorgoogle_token_invalidThis Google ID token is malformed, not signed by Google, issued for another client ID or by another issuer, expired, or names no account. Sign the customer in with Google again for a new one.
403permission_errorgrant_by_vendorOnly the account's vendor grants a subscription for free, naming the account in the Black-Account header.
400invalid_request_erroridempotency_key_invalidThe Idempotency-Key header must be between 1 and 255 characters of UTF-8 text.
409invalid_request_erroridempotency_key_reusedThe Idempotency-Key was already used in this environment for a different request, or by a caller its kept answer may not go to: an answer made for an API client is given again to any API client of the environment and never to a person or a publishable key, and one made for a person or a page's publishable key to that person or key alone. Send a new key for a new request.
409invalid_request_erroridempotency_request_in_progressA request with this Idempotency-Key is still being processed. Retry once it has finished.
503api_erroridentity_keys_unavailableThe key set of the account's own sign-in could not be fetched with certainty, so no identity token was checked and no session was made. Retry the request later.
401authentication_erroridentity_token_audience_invalidThis identity token names another audience than the one the environment set. Sign it for that audience.
401authentication_erroridentity_token_expiredThis identity token has expired: its end has passed, beyond 60 seconds of leeway. Sign the customer in again for a new token.
401authentication_erroridentity_token_invalidThis identity token is malformed, names another issuer, lacks a subject, a token ID, an issue time or an end, is not yet valid, or lasts more than 10 minutes. Sign the customer in again for a new token.
401authentication_erroridentity_token_replayedThis identity token was already exchanged, and each is used once. Sign the customer in again for a new token.
401authentication_erroridentity_token_signature_invalidThis identity token is not signed with RS256 or ES256 by a key of the key set the environment names, or its signature does not match. Sign it with a key of that set.
500api_errorinternal_errorSomething went wrong on our side. Retry the request later.
400invalid_request_errorinvalid_api_versionThe Black-Version header does not name a supported API version.
400invalid_request_errorinvalid_requestThe request was refused as a whole rather than for one parameter, for example for a method the address does not take, and the HTTP status says which kind of refusal it is.
404invalid_request_errorinvitation_invalidThe invitation's link is unknown, used, revoked or expired; the answer is the same in every case, so it tells nothing about which invitations exist, and the person asks for a new invitation.
409invalid_request_errorinvitation_not_pendingOnly a pending invitation can be resent or revoked; this one is accepted, revoked or expired.
409invalid_request_errorinvitation_pendingThis email already has a pending invitation to the account. Resend it instead.
409invalid_request_errorinvoice_already_paidThis invoice is already paid, so it takes no other payment.
409invalid_request_errorinvoice_not_paidThis invoice is not paid, so there is no payment to refund or dispute.
409invalid_request_errorinvoice_openAn invoice of this subscription is open. Report it paid before changing the plan.
409invalid_request_errorinvoice_voidThis invoice is void and takes no payment.
409invalid_request_errorlast_ownerThis is the account's last active owner, and an account always keeps one. Make another team member an owner first.
409invalid_request_errorlast_payment_methodThis is the customer's only card, and a subscription of theirs is charged automatically. Add another card first, then remove this one.
401authentication_errorlink_expiredThis sign-in link has expired: it works for 15 minutes. Ask for a new one.
422invalid_request_errorlink_invalidThe token of a link Black emailed, to prove an email, to set a new password or to confirm a new email, is wrong, used, expired, superseded or sent in another customer's session, or the token of a sign-in link is malformed, unknown or of another environment; or the code a mobile app's customer typed in its place is wrong, used, expired, superseded or tried too often, or its email is no customer's; so nothing changed. param names token or code, and the customer asks for a new link or code.
401authentication_errorlink_usedThis sign-in link was already used, and each works once. Ask for a new one.
409invalid_request_errorlookup_key_in_useAnother price in this environment has this lookup key. Send another key; a new price may take it over with transfer_lookup_key: true.
400invalid_request_errormode_header_invalidSend Black-Mode: live or Black-Mode: test to choose the environment to act in.
401authentication_errornotification_signature_invalidA notification reached a connection's address with no signature, or one its body does not match under the connection's signing key; nothing of it was kept or acted on.
413invalid_request_errornotification_too_largeA notification reached a connection's address with a body over 256 KB; nothing of it was kept or acted on.
403permission_errororigin_not_allowedThis publishable key's app does not take requests from this caller: a website's key only from one of its allowed origins, and a mobile app's key only with its bundle ID or package name in the Black-App header and no Origin header.
403permission_errorowner_requiredGiving or taking away the owner role, and turning off, turning on or removing an owner, needs the person acting to be an owner of the account, or of the vendor's team when acting for one of its sub-accounts; nothing changed.
409invalid_request_errorowner_role_fixedThe owner role cannot be renamed, changed or deleted. It always holds every permission.
422invalid_request_errorparameter_invalidA parameter is missing or does not meet its rule; param names it and message says what it must be.
422invalid_request_errorpassword_reset_invalidThe token of the link to set a password is wrong, used, expired or another email's, so nothing changed; param names token, and the person needs a new link.
409invalid_request_errorpayment_at_former_clientA refund was refused because the invoice's payment went through another gateway connection, or under another Checkout.com client, than the one now active: the client that holds the payment is the only one that can give it back, so nothing was sent to the new one and nothing was recorded as refunded. A refund the client changed under before its first send is failed connection_changed, as nothing was sent; one already sent stays pending, held, and invoice.refund_outcome_unknown is sent once. Refund the payment at its former client, then record that refund by POST /v1/invoices/{invoice}/refunds with the former client's action ID for it as gateway_action, or settle a held refund with POST /v1/invoices/{invoice}/refund-outcome.
402card_errorpayment_declinedThe card was declined, and nothing was paid. decline_reason says why. Ask the customer for another card, then pay again.
409invalid_request_errorpayment_in_progressA payment of this invoice is in progress. Wait for its result before paying or reporting it again.
409invalid_request_errorpayment_method_removal_in_progressAnother of this customer's cards is being removed at this moment. Try again in a few seconds.
422invalid_request_errorpayment_method_type_unsupportedOnly cards are accepted, including Apple Pay and Google Pay. Send the single-use card token that the gateway's own fields returned.
409invalid_request_errorpayment_outcome_knownThe outcome of this payment is already recorded, or was already reported, so there is nothing to settle.
409invalid_request_errorpayment_reference_in_useAnother invoice in this environment was paid under this payment reference. Send the reference of this payment.
403permission_errorpermission_deniedThe access token is valid, but its holder may not perform this action: for a person signed in to the console, their role in the account does not hold the permission the request needs, which the message names, and nothing was read or changed.
409invalid_request_errorprice_archivedThe price is archived and takes no new subscriptions. Make it active again, or subscribe to another price.
409invalid_request_errorprice_change_not_pendingNo change of this subscription's plan at the end of its period is pending, so there is none to undo. An upgrade whose invoice is open cannot be undone; it expires when its invoice is not paid in time.
409invalid_request_errorprice_change_pendingA change of this subscription's plan is already pending: an upgrade whose invoice is open, or a change at the end of the period. Report the invoice paid, let it expire, or undo the change first, then send the request again with the same Idempotency-Key.
409invalid_request_errorprice_move_in_progressA move of the subscriptions on this price is still running. Send the request again once every subscription it reaches has been moved.
422invalid_request_errorprice_not_recurringA checkout session sells a recurring price, as a subscription, and this price is charged once. Choose a recurring price.
409invalid_request_errorprice_unchangedThe subscription is already on this price, so there is no plan to change to.
409invalid_request_errorproduct_archivedThe product is archived and takes no new prices or subscriptions. Make it active again, or use another product.
409invalid_request_errorproduct_has_pricesThis product has prices, so it cannot be deleted. Archive it instead by setting active to false.
422invalid_request_errorpromotion_codes_not_supportedA checkout session takes no promotion code. Leave out promotion_code, and send allow_promotion_codes as false or not at all.
409invalid_request_errorpublishable_key_already_revokedThis publishable key is already revoked. A revoked key cannot be restored; create a new one instead.
401authentication_errorpublishable_key_invalidThe Black-Publishable-Key header must carry a publishable key of one of the environment's apps. Copy the key from the app's keys.
409invalid_request_errorpublishable_key_limit_reachedThis app already has the most active publishable keys it may hold, two. Revoke one before creating another.
401authentication_errorpublishable_key_not_allowedA publishable key opens only the Client API, under /v1/client. Call this endpoint from your server with an API client's access token.
401authentication_errorpublishable_key_revokedThis publishable key has been revoked. Use the app's other active key, or create a new one.
429rate_limit_errorrate_limit_exceededThe API client sent more reads or more writes in one second than its environment allows; wait the number of seconds in the Retry-After header, then retry.
429rate_limit_errorrate_limitedToo many requests reached this address in a short time; wait the number of seconds in the Retry-After header, then retry.
409invalid_request_errorrefund_outcome_knownThis refund has already succeeded or failed, so there is nothing to settle.
409invalid_request_errorrenewal_deferredThe subscription's renewal waits until the service is on again.
409invalid_request_errorrenewal_dueThis subscription's period has ended and its renewal is about to run, so it cannot be set to cancel or have its plan changed yet. Send the request again in a moment, with the same Idempotency-Key.
409invalid_request_errorresource_already_existsAn object with this ID already exists. Send another ID, or none to have one made.
404invalid_request_errorresource_not_foundThe object or address asked for does not exist in the environment of the access token; when param is set, it names the parameter that refers to the missing object.
409invalid_request_errorrole_in_useA team member holds this role, or a pending invitation gives it, so it cannot be deleted. Give the team member another role, or revoke the invitation, first.
409invalid_request_errorsales_closedSales are closed in this environment, so it takes no new subscription. The plans read gives the reasons; sales open again once none applies.
401authentication_errorserver_credential_not_allowedThe Client API takes no server credential. Never put an access token or a client secret in a page or an app; send the app's publishable key in the Black-Publishable-Key header.
403permission_errorsetting_set_by_vendorOnly the account's vendor changes this setting, naming the account in the Black-Account header; the data-processing agreement is changed only with the vendor's live API client.
401authentication_errorsign_in_again_requiredA signed-in customer with no password asked to change their email in a session that started more than 10 minutes ago, so nothing changed and nothing was sent; the customer signs in again, by an email link or Google, and asks again in the new session.
401authentication_errorsign_in_failedThe sign-in was refused: the email or the password is wrong, or a field is missing; the answer is the same in every case, so it tells nothing about which email exists.
403permission_errorsign_in_method_disabledThis way of signing in is off, or not set up, in the environment's sign-in settings. For email and password, turn on sign_in.password; for a link sent by email, sign_in.email_link; for Google, sign_in.google with sign_in.google_client_id; for identity tokens, set sign_in.identity_keys_url, sign_in.identity_issuer and sign_in.identity_audience.
401authentication_errorsign_in_token_expiredThis sign-in token has expired: it is valid for 5 minutes. Ask the account's server for a new one.
401authentication_errorsign_in_token_invalidThis sign-in token is unknown, malformed or of another environment. Ask the account's server for a new one, and exchange it with a publishable key of the same environment.
401authentication_errorsign_in_token_usedThis sign-in token was already exchanged, and each is used once. Ask the account's server for a new one.
409invalid_request_errorsubscription_busyThe subscription was changed by another request while this one was decided, and nothing was saved. Repeat the request with the same Idempotency-Key.
409invalid_request_errorsubscription_endedThis subscription has ended, so it can no longer be cancelled, set to cancel, have a cancel undone or have its plan changed.
409invalid_request_errorsubscription_grantedThis subscription was granted for free for one term and ends at the end of it, so its end cannot be undone.
409invalid_request_errorsubscription_has_several_itemsThis subscription has more than one item, and only a subscription of one item can have its plan changed.
409invalid_request_errorsubscription_incompleteThis subscription is incomplete: its first invoice is not paid yet, so it cannot be set to cancel at the end of its period, which a cancel now can do instead, or have its plan changed.
409invalid_request_errortax_not_determinedThe environment's tax service gave no rate for the country taxed, for example because the seller is not registered there, and the account has no rate of its own for it, so nothing was saved. Set a rate for the country, or its default rate.
503api_errortax_service_unavailableThe environment's tax service did not answer, and the account has no rate of its own for the country taxed, so nothing was saved. Retry the request later.
409invalid_request_errorteam_member_already_activeThis team member is already active.
409invalid_request_errorteam_member_already_inactiveThis team member is already turned off.
403permission_errorteam_member_inactiveThe email and the password are right, but every membership of the person is turned off, so no session is made; an administrator of one of their teams turns it on again.
403permission_errorteam_member_requiredThe team's routes are for people signed in to the console, acting within their role; an API client's token is refused on every one of them.
409invalid_request_errortest_clock_advancingThe test clock is advancing, and nothing was saved. Wait until its status is ready, then repeat the request.
409invalid_request_errortest_clock_internal_failureThe test clock stopped with an internal failure while it advanced, and nothing was saved. Its customers can no longer be changed; delete the test clock and start with a new one.
409invalid_request_errortest_clock_limit_reachedA limit of test clocks is reached: on the test clocks of an environment, on the customers of a test clock, or on the subscriptions of a customer on a test clock. Delete a test clock, or use another one.
403permission_errortest_mode_requiredThis exists only in a test environment, as test clocks, test exchange rates and the practice gateway's notices do. Use the access token of a test API client.
422invalid_request_errortrial_not_supportedA checkout session takes no trial: its subscription starts when it is paid. Leave out trial_days.
403permission_errorvendor_client_requiredThis endpoint is for vendors: it takes a vendor's API client, or a person on the vendor's team naming the vendor's home account in the Black-Account header.
409invalid_request_errorwebhook_endpoint_disabled_by_operatorThis webhook endpoint was disabled by Black, and only Black can enable it. Contact support.
409invalid_request_errorwebhook_endpoint_limit_reachedThis environment already has the most webhook endpoints it may hold. Delete one before creating another.

A failure with any other 4xx status keeps its status and answers with invalid_request.

Fix each failure by its cause:

  • 400. Correct the request, then send it again. Sending the same request again gives the same answer. For idempotency_key_invalid, send a key of 1 to 255 characters. See Idempotency.
  • 401. Send Authorization: Bearer <access token> with a valid access token of the environment you call. When the code is access_token_invalid, get a new access token. When it is api_client_revoked, use an active client ID and secret, or ask Black for a new pair. See Authentication.
  • 403. Use an API key that may perform the action.
  • 404. Check the address and the ID in it.
  • 409. For idempotency_key_reused, send a new key for a new request, or send the first request again unchanged. For idempotency_request_in_progress, wait a moment, then send the request again with the same key. See Idempotency.
  • 422. Correct the field that param names, following message, then send the request again.
  • 429. Wait the number of seconds in the Retry-After header, then send the request again.
  • 500. Wait, then send the request again. If it fails again, contact support with the request_id. The message never carries a stack trace, a class name or a query.
  • 503. Wait, then send the request again. Nothing was saved, so sending it again is safe. If it keeps failing, contact support with the request_id.

Read a refusal of the token address​

The token address, POST /v1/oauth/token, refuses in the body the OAuth 2.0 standard gives for a token endpoint (RFC 6749, section 5.2), so an OAuth client library can read it. The body has two fields and no others: error, the code, and error_description, a sentence for a developer. It has no type, no param and no request_id field: read the ID from the Request-Id header.

StatusCodeCause
401invalid_clientThe client ID or the secret is not valid, or the pair is revoked. The description says so when the pair is revoked and the secret is right.
400invalid_requestThe request has no client_id or no client_secret.
400unsupported_grant_typeThe request has no grant_type, or one that Black does not issue tokens for.
400unauthorized_clientThe grant_type is one the client ID may not use.

A request over a limit of the token address answers 429 rate_limited in the error shape above, and a failure on the Black side answers 500 internal_error in it too. See Authentication for the fix of each refusal.

A token request with a client secret that is not valid answers like this:

curl --request POST https://api.black.example/v1/oauth/token \
--data grant_type=client_credentials \
--data client_id=PLACEHOLDER_CLIENT_ID \
--data client_secret=not-the-client-secret
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Cache-Control: no-store, private
Pragma: no-cache
Request-Id: req_01m77ecgd8e4mzqea9tdav22hn

{"error":"invalid_client","error_description":"Client authentication failed"}