GoCardlessDeveloper Docs
Create a sandbox account

Responses and Errors#

View as Markdown

Response codes#

CodeStatusDescription
200OKRequest succeeded.
201CreatedResource created. The URI of the new resource is in the Location header.
204No ContentRequest succeeded with no response body.
400Bad RequestMalformed request syntax. The response body contains details.
401UnauthorizedMissing or invalid Authorization header, or the user has been disabled.
403ForbiddenValid credentials but insufficient permissions for this resource.
404Not FoundResource not found or not accessible to the authenticated user.
405Method Not AllowedHTTP verb not permitted. PATCH is not supported — use PUT.
406Not AcceptableAccept header content type not supported by this endpoint.
409ConflictResource already exists.
410GoneResource existed but has been removed.
415Unsupported Media TypeContent-Type not accepted. See the error for supported types.
422Unprocessable EntityPOST/PUT body was structurally valid but contained invalid data.
426Upgrade RequiredRequest was made over HTTP — upgrade to HTTPS.
429Too Many RequestsRate limit exceeded. Check response headers for reset timing.
500Internal Server ErrorServer-side error. Retry, and report to support with the request_id if it persists.
504Gateway TimeoutRequest timed out. Retry, and report with request_id if it persists.

Error structure#

Every error response includes:

FieldDescription
typeOne of gocardless, invalid_api_usage, invalid_state, validation_failed
codeThe HTTP status code
messageA short human-readable description
documentation_urlLink to the relevant docs section
request_idUnique ID — include this when contacting support
errorsArray of specific errors (see below)

For validation_failed errors, each item in errors has a field and message. For all other types, each item has a reason and message.

Error types#

gocardless — Internal errors

These errors occurred within GoCardless while processing your request. Retry where indicated; report persistent issues to support with the request_id.

ReasonDescription
internal_server_errorAn internal error occurred. Report to support with request_id.
request_timed_outRequest did not complete in time. Retry, report if persistent.
query_timed_outDatabase query timed out, possibly due to complexity. Retry with different parameters.
invalid_api_usage — Request errors

Errors caused by how the request was constructed — invalid URL, missing headers, authentication problems, or bad syntax.

ReasonDescription
invalid_typeJSON was incorrectly typed or contained unknown parameters.
path_not_foundURL path not recognised. Check spelling and formatting.
resource_not_foundThe ID in the request was not found.
link_not_foundA link[resource] ID was not found.
unauthorizedCredentials not recognised.
forbiddenAuthenticated but no permission to access this resource.
feature_disabledFeature not enabled on your account. Contact support to enable.
not_acceptableAccept header content type not supported.
request_entity_too_largeRequest body too large.
unsupported_media_typeUse application/json for Content-Type and Accept.
rate_limit_exceededRate limit reached. Check headers for reset time.
access_token_not_foundNo token found with the specified ID.
access_token_not_activeToken has been disabled.
access_token_revokedToken has been revoked by the user.
missing_authorization_headerNo Authorization header included.
invalid_authorization_headerAuthorization header was malformed.
insufficient_permissionsToken doesn't have the required scope.
insufficient_permissions_continue_on_dashboardAction can only be performed from the GoCardless dashboard.
method_not_allowedHTTP verb not permitted. Use PUT instead of PATCH.
bad_requestRequest syntax was incorrect.
idempotency_key_too_longIdempotency key exceeded 128 characters.
invalid_document_structureJSON was not structured correctly. Parameters must be nested under the resource name.
invalid_content_typeMissing or unsupported Content-Type header on a POST/PUT.
tls_requiredAPI only accessible over HTTPS.
missing_version_headerNo GoCardless-Version header included.
version_not_foundSpecified version does not exist.
invalid_filtersFilter combination not allowed for this endpoint.
request_body_not_allowedRequest body not supported for this HTTP method — use query parameters.
customer_data_removedCustomer has been removed and can no longer be returned.
payout_items_data_archivedPayout items older than 6 months have been archived. Contact support for access.
invalid_state — State errors

The action is invalid given the current state of the resource. Inform the end user — do not allow them to retry.

ReasonDescription
cancellation_failedResource was not in a cancellable state (already cancelled, failed, or too late in submission).
retry_failedPayment could not be retried.
disable_failedBank account is already disabled.
mandate_is_inactivePayment could not be created — mandate is cancelled, failed, or expired.
mandate_replacedMandate has been replaced. Check links[new_mandate] in the error or on the mandate itself.
bank_account_disabledMandate could not be created — linked customer bank account is disabled.
mandate_not_inactiveMandate could not be reinstated — it is already active or being submitted.
refund_is_unreachableRefund could not be created — it would not reach the target bank account.
refund_payment_invalid_statePayment must be confirmed or paid_out before it can be refunded.
total_amount_confirmation_invalidTotal amount refunded does not match the confirmation value.
number_of_refunds_exceededMaximum of 5 refunds per payment already reached.
idempotent_creation_conflictA resource already exists for the supplied idempotency key.
customer_bank_account_token_usedBank account token has already been used.
billing_request_must_be_ready_to_fulfilBilling request has outstanding required actions. Check the actions array.
validation_failed — Validation errors

Request parameters were invalid. Prompt the user to correct their input.

ReasonDescription
bank_account_existsBank account already exists. The existing account is referenced in links[customer_bank_account] or links[creditor_bank_account] in the error response.
available_refund_amount_insufficientCreditor balance is insufficient to cover the refund. The available amount is in metadata.available_refund_amount.

Individual field validation errors are returned in the errors array with a field, message, and request_pointer indicating the exact failing field.

Example error responses#

POST https://api.gocardless.com/customer_bank_accounts HTTP/1.1
Content-Type: application/json
{
  "customer_bank_accounts": {
    "account_number": "55779911",
    "branch_code": "I'm not a sort code",
    "account_holder_name": "Frank Osborne",
    "country_code": "GB",
    "links": { "customer": "CU123" }
  }
}
 
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json
{
  "error": {
    "documentation_url": "/docs/api-reference/responses-and-errors#validation-failed",
    "message": "Validation failed",
    "type": "validation_failed",
    "code": 422,
    "request_id": "dd50eaaf-8213-48fe-90d6-5466872efbc4",
    "errors": [
      {
        "message": "must be a number",
        "field": "branch_code",
        "request_pointer": "/customer_bank_accounts/branch_code"
      },
      {
        "message": "is the wrong length (should be 8 characters)",
        "field": "branch_code",
        "request_pointer": "/customer_bank_accounts/branch_code"
      }
    ]
  }
}
POST https://api.gocardless.com/customer_bank_accounts HTTP/1.1
Content-Type: application/json
{
  "customer_bank_accounts": {
    "account_number": "55779911",
    "branch_code": "200000",
    "account_holder_name": "Frank Osborne",
    "country_code": "GB",
    "links": { "customer": "CU123" }
  }
}
 
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
  "error": {
    "message": "Invalid document structure",
    "documentation_url": "/docs/api-reference/responses-and-errors#invalid-api-usage",
    "type": "invalid_api_usage",
    "request_id": "bd271b37-a2f5-47c8-b461-040dfe0e9cb1",
    "code": 400,
    "errors": [
      {
        "reason": "invalid_document_structure",
        "message": "Invalid document structure"
      }
    ]
  }
}
POST https://api.gocardless.com/creditor_bank_accounts HTTP/1.1
Content-Type: application/json
{
  "creditor_bank_accounts": {
    "account_number": "55779911",
    "branch_code": "200000",
    "country_code": "GB",
    "set_as_default_payout_account": true,
    "account_holder_name": "Nude Wines",
    "links": { "creditor": "CR123" }
  }
}
 
HTTP/1.1 409 Conflict
Content-Type: application/json
{
  "error": {
    "message": "Bank account already exists",
    "documentation_url": "/docs/api-reference/responses-and-errors#validation-failed",
    "type": "validation_failed",
    "request_id": "bd271b37-a2f5-47c8-b461-040dfe0e9cb1",
    "code": 409,
    "errors": [
      {
        "reason": "bank_account_exists",
        "message": "Bank account already exists",
        "links": { "creditor_bank_account": "BA123" }
      }
    ]
  }
}

What's next#