Affirm's APIs use conventional HTTP status codes to indicate the success or failure of API requests.

API calls successfully made to Affirm use codes in the 2xx range while codes in the 4xx range indicate failure and codes in the 5xx range internal server issues.

When an API call fails, the response body contains the error code, an error object, as well as additional information about the error to help you identify and resolve the issue.

Some 4xx errors that could be handled programmatically (e.g., a capture declined) include an error code that briefly explains the error reported.

Field names

Key

Data type

Description

status_code

string

The returned HTTP status code.

message

string

A friendly and human-readable message providing more details about the error.

code

string

A short code reference for the specific error that can be used programmatically.

type

string

The type of error being returned that can be used programmatically.

field

string

An incorrect or invalid value.


Status codes

Charges endpoint status codes

Status codes

Error message

200 - success

The API call worked as expected.

400 - Bad request

The request was improper. This is often due to missing information in the request fields.

401 - Unauthorized

No valid API key provided

402 - Request failed

The parameters were valid but the request failed.

404 - Not found

The requested resource could not be found.

409 - Conflict

  • Charges on this instrument cannot be captured for an amount that is greater than the total capturable balance.
  • Charges on this instrument cannot be captured for an amount unequal to authorization hold amount.
  • Charges on this instrument cannot be captured for an amount that is not equal to the total capturable balance.
    -The transaction with this idempotency key is processing. Please wait to retry or use a different idempotency key.

500, 502, 503, 504 - Server Errors

Something went wrong on Affirm's end. Please check our status page.


Transactions endpoint status codes

📘

Expanded error handling

The Transactions API has specific error codes depending on the API call.

POST Capture Transaction

Status code

Error message

403 - Forbidden error

  • The transaction cannot be captured or refunded while it is disputed.
  • The idempotency key provided has already been used
  • The transaction is past its capturable period and cannot be captured. Please contact [email protected] for assistance.
  • The transaction has been voided and may no longer be captured.
  • The transaction has already been voided.
  • The transaction must be authorized before it may be captured.

404 - Not found

The transaction could not be found.

409 - Conflict

  • Charges on this instrument cannot be captured for an amount that is greater than the total capturable balance.
  • Charges on this instrument cannot be captured for an amount unequal to authorization hold amount.
  • Charges on this instrument cannot be captured for an amount that is not equal to the total capturable balance.
    -The transaction with this idempotency key is processing. Please wait to retry or use a different idempotency key.

POST Refund Transaction

Status code

Error message

403 - Forbidden error

  • The transaction cannot be captured or refunded while it is disputed.
  • Refund amount is required for a partially refunded transaction.
  • The refund amount exceeds the remaining loan balance
  • The idempotency key provided has already been used.
  • This transaction cannot be refunded while the refund amount is negative.
  • The transaction is on the Virtual Card Network and may not be refunded by the Transaction API.
  • The transaction is authorized and may not be refunded. Try voiding the transaction instead.
  • The transaction has been voided and cannot be refunded.
  • The transaction is past its refundable period and cannot be refunded. Please contact [email protected] for assistance.

404 - Not found

The transaction could not be found.

409 - Conflict

The transaction with this idempotency key is processing. Please wait to retry or use a different idempotency key.

POST Void Transaction

Status code

Error message

403 - Forbidden error

  • The transaction cannot be captured or refunded while it is disputed.
  • Refund amount is required for a partially refunded transaction.
  • The refund amount exceeds the remaining loan balance
  • The idempotency key provided has already been used.
  • This transaction cannot be refunded while the refund amount is negative.
  • The transaction is on the Virtual Card Network and may not be refunded by the Transaction API.
  • The transaction is authorized and may not be refunded. Try voiding the transaction instead.
  • The transaction has been voided and cannot be refunded.
  • The transaction is past its refundable period and cannot be refunded. Please contact [email protected] for assistance.

404 - Not found

The transaction could not be found.

409 - Conflict

  • Void amount is not allowed for a merchant not supporting split capture.
  • The total amount to be voided cannot be greater than the total capturable balance.
  • The transaction with this idempotency key is processing. Please wait to retry or use a different idempotency key.

Error types

Error types

Description

unauthorized

Invalid API keys provided.

invalid_request

A generic error that indicates invalid request inputs.


Error codes

Error codes

Description

auth-declined

Charge authorization hold declined.

capture-greater-instrument

Cannot capture charges on this instrument for more than the authorization hold amount.

capture-unequal-instrument

Cannot capture charges on this instrument for an amount unequal to the authorization hold amount.

capture-voided

Cannot capture voided charge.

partial-capture-instrument

Cannot partially capture charges on this instrument.

refund-exceeded

Exceeded maximum refund.

refund-uncaptured

Cannot refund a charge that hasn't been captured.

refund-voided

Cannot refund a voided charge.

capture-declined

Charge capture declined.

capture-limit-exceeded

Exceed maximum capture amount on charge.

expired-authorization

Cannot capture a charge with an expired authorization hold.

refund-expired

Charges on this instrument must be refunded within N days of capture.

invalid_field

An input field resulted in invalid request.

public-api-key-not-specified

Please provide a public API key.

public-api-key-invalid

Please provide a valid public API key.

public-api-key-wrong-environment

Please provide a live public API key when not using the sandbox environment.

public-api-key-inactive

Please provide an active public API key.

api-key-pair-not-specified

Please provide an API key pair.

private-api-key-invalid

Please provide a valid private API key.

api-key-pair-wrong-environment

Please provide a live API key pair when not using the sandbox environment.

api-key-pair-inactive

Please provide an active API key pair.

not_found

Could not find the resource(s) specified in the request.