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
Clé | Type de données | 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 | Message d'erreur |
|---|---|
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 |
|
500, 502, 503, 504 - Server Errors | Something went wrong on Affirm's end. Please check our status page. |
Transactions endpoint status codes
Expanded error handlingThe
TransactionsAPI has specific error codes depending on the API call.
POST Capture Transaction
Status code | Message d'erreur |
|---|---|
403 - Forbidden error |
|
404 - Not found | The transaction could not be found. |
409 - Conflict |
|
POST Refund Transaction
Status code | Message d'erreur |
|---|---|
403 - Forbidden error |
|
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 | Message d'erreur |
|---|---|
403 - Forbidden error |
|
404 - Not found | The transaction could not be found. |
409 - Conflict |
|
Error types
Error types | Description |
|---|---|
| Invalid API keys provided. |
| A generic error that indicates invalid request inputs. |
Codes d’erreur
Codes d’erreur | Description |
|---|---|
| Charge authorization hold declined. |
| Impossible de capturer des frais sur cet instrument pour un montant supérieur au montant de la retenue d'autorisation. |
| Cannot capture charges on this instrument for an amount unequal to the authorization hold amount. |
| Cannot capture voided charge. |
| Cannot partially capture charges on this instrument. |
| Dépassement du remboursement maximal. |
| Cannot refund a charge that hasn't been captured. |
| Cannot refund a voided charge. |
| Charge capture declined. |
| Exceed maximum capture amount on charge. |
| Cannot capture a charge with an expired authorization hold. |
| Les frais liés à cet instrument doivent être remboursés dans les N jours suivant la capture. |
| Un champ de saisie a donné lieu à une demande non valide. |
| Please provide a public API key. |
| Veuillez fournir une clé d'API publique valide. |
| Please provide a live public API key when not using the sandbox environment. |
| Please provide an active public API key. |
| Please provide an API key pair. |
| Veuillez fournir une clé d'API privée valide. |
| Please provide a live API key pair when not using the sandbox environment. |
| Please provide an active API key pair. |
| Impossible de trouver la(les) ressource(s) spécifiée(s) dans la demande. |