Error Handling

Our API uses conventional HTTP response codes to indicate success or failure of requests. This guide covers all error codes and how to handle them.

Error Response Format

All error responses follow a consistent JSON format:

{
  "code": "invalid_consent",
  "message": "Consent not found or has expired"
}

Fields

FieldTypeDescription
codestringMachine-readable error code
messagestringHuman-readable error description

HTTP Status Codes

2xx Success

CodeNameDescription
200OKRequest succeeded
201CreatedResource created (payments, consents)
204No ContentRequest succeeded, no content to return

4xx Client Errors

CodeNameDescription
400Bad RequestInvalid request format or parameters
401UnauthorizedMissing or invalid authentication
403ForbiddenValid auth but insufficient permissions
404Not FoundResource does not exist
405Method Not AllowedHTTP method not supported for endpoint
409ConflictRequest conflicts with current state
422Unprocessable EntityRequest valid but cannot be processed
429Too Many RequestsRate limit exceeded

5xx Server Errors

CodeNameDescription
500Internal Server ErrorUnexpected server error
502Bad GatewayUpstream service unavailable
503Service UnavailableService temporarily unavailable
504Gateway TimeoutUpstream service timeout

Error Codes Reference

Authentication Errors

Errors related to OAuth 2.0 and token handling.

Error CodeHTTPDescription
invalid_token401Access token is invalid, expired, or revoked
invalid_client401Client authentication failed
invalid_grant400Authorization grant is invalid or expired
invalid_request400Request is missing required parameters
unauthorized_client403Client not authorized for this grant type
unsupported_grant_type400Grant type not supported
invalid_scope400Requested scope is invalid or unknown

Consent Errors

Errors related to consent management.

Error CodeHTTPDescription
missing_consent400X-Consent-ID header is required
invalid_consent401Consent not found
wrong_consent_type403Endpoint requires different consent type
consent_invalid403Consent is not active or has expired
consent_not_active403Consent has not been authorized by customer
consent_expired403Consent has passed its expiration date
consent_revoked403Consent was revoked by customer or TPP
permission_denied403Consent does not include required permission

Account Errors

Errors related to account access.

Error CodeHTTPDescription
account_not_found404Account does not exist
account_not_consented403Account not covered by consent
account_not_owned403Account not owned by authenticated customer
account_locked403Account is locked and cannot be accessed

Payment Errors

Errors related to payment initiation.

Error CodeHTTPDescription
payment_not_found404Payment does not exist
invalid_amount400Amount format is invalid
amount_exceeded400Amount exceeds scheme or account limits
insufficient_funds422Insufficient funds for payment
invalid_creditor400Creditor account details are invalid
invalid_debtor400Debtor account details are invalid
duplicate_payment409Payment with this instruction_id already exists
payment_failed500Payment processing failed

Funds Confirmation Errors

Errors related to funds confirmation.

Error CodeHTTPDescription
no_account400Consent does not specify an account
balance_error500Failed to retrieve account balance

Rate Limiting Errors

Errors related to rate limiting.

Error CodeHTTPDescription
rate_limit_exceeded429Too many requests, try again later
quota_exceeded429Monthly API quota exceeded

Troubleshooting Guide

Getting 401 Unauthorized

  1. Check that your access token is included in the Authorization header
  2. Verify the token has not expired (tokens last 5 minutes)
  3. Ensure you're using the correct token for the environment (sandbox vs production)
  4. For client credentials, verify your client_assertion JWT is correctly signed

Getting 403 Forbidden

  1. Verify the consent includes the required permissions
  2. Check that the consent status is 'authorized'
  3. For account endpoints, ensure the account is covered by the consent
  4. Confirm the consent has not expired

Getting 429 Too Many Requests

  1. Implement exponential backoff for retries
  2. Check the Retry-After header for when to retry
  3. Consider caching responses where appropriate
  4. Contact support if you need higher rate limits

Payment Stuck in 'pending'

  1. Some payments take longer to process (BACS: 3 days)
  2. Poll the payment status endpoint periodically
  3. Check for any error messages in the payment details
  4. For Faster Payments, status should update within minutes

Consent Authorization Failing

  1. Verify redirect_uris match exactly what was registered
  2. Check that state parameter is being correctly handled
  3. Ensure PKCE code_verifier matches the original code_challenge
  4. Review the error parameter in the callback URL

Retry Logic

Implement appropriate retry logic for transient errors:

Status CodeRetry?Strategy
400-499NoFix the request and try again
429YesWait for Retry-After duration
500MaybeRetry with exponential backoff (max 3 attempts)
502, 503, 504YesRetry with exponential backoff

Idempotency for Payments

Always use idempotency keys (instruction_id) when retrying payment requests to avoid duplicate payments.

Getting Help

If you're still experiencing issues after following this guide:

  • Check our status page at status.hamsterbank.ai
  • Review the API changelog for recent changes
  • Search our developer forum for similar issues
  • Contact developer support with your request_id for investigation