Card Authorization API

Implement the authorize and settle endpoints Wirex calls for card transactions of your Master Account corporations.

Before You Start

Read the following guides before proceeding:

GuideWhy
OverviewUnderstand Master Account mode
Cardholders and CardsHow card transactions settle against the Master Account

How It Works

When a cardholder pays with a card, Wirex first checks the Master Account, then calls your authorize
endpoint. At settlement, Wirex debits the Master Account and calls your settle endpoint.

The contract is the one retail External Authorization uses — see
Authorization API. This page gives it in full, with the differences that apply
to corporations.

sequenceDiagram
    participant Cardholder
    participant Network as Card Network
    participant Wirex as Wirex
    participant Master as Master Account
    participant Partner as Your API

    Cardholder->>Network: Card transaction
    Network->>Wirex: Authorization request
    Wirex->>Master: Check balance against threshold + amount
    alt Below threshold + amount
        Wirex-->>Network: Declined
    else Enough balance
        Wirex->>Partner: POST .../external/authorize
        Partner-->>Wirex: { is_allowed: true }
        Wirex-->>Network: Authorized
    end

    Network->>Wirex: Settlement request
    par
        Wirex->>Master: Debit Master Account
    and
        Wirex->>Partner: POST .../external/settle
        Partner-->>Wirex: { is_processed: true }
    end
    Wirex-->>Network: Settled

When the Master Account balance is below the threshold plus the amount, Wirex declines the authorization
without calling you.


Endpoints

EndpointPurpose
POST {your_base_url}/external-authorization/on-chain/card-transaction/external/authorizeAuthorize a card transaction
POST {your_base_url}/external-authorization/on-chain/card-transaction/external/settleApprove or reject a previously authorized transaction

{your_base_url} and the API version are configured by Wirex when Master Account mode is enabled. When
the agreed API version is 2, the path is prefixed with /v2:

POST {your_base_url}/v2/external-authorization/on-chain/card-transaction/external/authorize
POST {your_base_url}/v2/external-authorization/on-chain/card-transaction/external/settle

Authentication

Wirex sends no credentials on these calls. Protect the endpoints at network level.


Performance Requirements

MetricRequirement
Target response time< 300ms
Maximum round trip500ms
Timeout behaviorDeclined (for non-mandatory transactions)

[!IMPORTANT] Deploy your API in the same region as Wirex (AWS eu-central-1 / Azure west-europe) for optimal latency.


Identity in the Requests

FieldIn Master Account mode
user_idThe corporation id — the corporation_id returned by POST /api/v1/corporations
card_idThe card. No employee id is sent, so map card_id to the cardholder yourself
unique_operation_idThe operation. Use it for idempotency

Authorization Endpoint

Authorize a card transaction before processing.

POST {your_base_url}/external-authorization/on-chain/card-transaction/external/authorize

Request

{
  "transaction_type": "POS",
  "user_id": "6f1c2b0e-3a5d-4c7e-9b8a-2d4f6e8a1c3b",
  "transaction_id": "a7b2a4b3-2f61-41a7-9f5a-3f3f0b1a3d22",
  "operation_type": "Debit",
  "card_id": "c0b2c7b1-1d2e-4d7a-9a5d-2b7e3c4d5f66",
  "currency": "USD",
  "amount": 123.45,
  "unique_operation_id": "3e1f6a98-6b0a-4c8c-93e5-0b9c6d2a7f31",
  "correlation_id": "7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d",
  "rates_by_assets": [
      {
          "ticker": "WUSD/EUR",
          "buy": 0.8802942779763089356326414065,
          "sell": 0.8503191839136152834498511802
      },
      {
          "ticker": "WEUR/EUR",
          "buy": 1.005500000000000000000000,
          "sell": 0.994500000000000000000000
      }
  ],
  "is_mandatory": false,
  "related_external_operation_status": "None",
  "transaction_reason": "Authorization",
  "mcc": "5411"
}
FieldTypeRequiredDescription
transaction_typestringYesChannel type: POS, ATM, ePOS, MoneyTransfer
user_idUUIDYesCorporation id — the corporation_id of the corporation the card belongs to
transaction_idUUIDYesCard transaction identifier
operation_typestringYesDebit (purchase/withdrawal) or Credit (refund)
card_idUUIDYesCard identifier. Map it to the cardholder yourself — no employee id is sent
currencystringYesISO 4217 currency code
amountdecimalYesTransaction amount
unique_operation_idUUIDYesUnique operation identifier. Use it for idempotency
correlation_idUUIDNoTracing identifier. Do not require it — treat it as absent when missing
preferred_payment_currencystringYesISO 4217 code Wirex prefers to settle in. Empty string when there is no preference
rates_by_assetsarrayYesExchange rates as currency pairs (see below)
is_mandatorybooleanYesIf true, processed regardless of response
related_external_operation_statusstringYesStatus of related operation (see below)
transaction_reasonstringYesTransaction reason (see below)
mccstringNoMerchant category code (4-digit string)

rates_by_assets Values

ValueDescription
tickerCurrency pair in the format BASE/QUOTE
buyBuy rate for the pair
sellSell rate for the pair

related_external_operation_status Values

ValueDescription
NoneFirst transaction in the chain
RejectedPrevious transaction was rejected by partner
ApprovedPrevious transaction was approved by partner

transaction_reason Values

ValueDescription
AuthorizationAuthorization operation (single or incremental)
ClearingCapture operation (direct, single, or multiple)
RefundRefund operation (partial or full)
ReversalCancel authorizations/clearings (partial or full)
OriginalCreditCredit operation
RepresentmentCancel refunds/chargebacks
MoneySendCredit operation
DelayAuthorizationFuel dispenser scenarios or chargebacks

Response

{
  "transaction_id": "a7b2a4b3-2f61-41a7-9f5a-3f3f0b1a3d22",
  "is_allowed": true,
  "decline_reason": null
}
FieldTypeRequiredDescription
transaction_idUUIDYesCard transaction ID (echo back). Must be a GUID — any other format fails the call and declines the transaction
is_allowedbooleanYestrue to approve, false to decline
decline_reasonstringNoInsufficientFunds or GeneralError

Settlement Endpoint

Approve or reject a previously authorized transaction.

POST {your_base_url}/external-authorization/on-chain/card-transaction/external/settle

Request

{
  "transaction_type": "POS",
  "user_id": "6f1c2b0e-3a5d-4c7e-9b8a-2d4f6e8a1c3b",
  "transaction_id": "a7b2a4b3-2f61-41a7-9f5a-3f3f0b1a3d22",
  "operation_type": "Debit",
  "card_id": "c0b2c7b1-1d2e-4d7a-9a5d-2b7e3c4d5f66",
  "currency": "USD",
  "amount": 123.45,
  "unique_operation_id": "3e1f6a98-6b0a-4c8c-93e5-0b9c6d2a7f31",
  "correlation_id": "7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d",
  "settlement_currency": "USD",
  "settlement_amount": 123.45,
  "settlement_decision": 0,
  "reject_reason": null
}
FieldTypeRequiredDescription
transaction_typestringYesChannel type
user_idUUIDYesCorporation id — the corporation_id of the corporation the card belongs to
transaction_idUUIDYesCard transaction identifier
operation_typestringYesDebit or Credit
card_idUUIDYesCard identifier. Map it to the cardholder yourself
currencystringYesOriginal transaction currency
amountdecimalYesOriginal transaction amount
unique_operation_idUUIDYesUnique operation identifier. Use it for idempotency
correlation_idUUIDNoTracing identifier. Do not require it — treat it as absent when missing
settlement_currencystringYesSettlement currency
settlement_amountdecimalYesSettlement amount
settlement_decisionintYes0 Approve or 1 Reject
reject_reasonstringNoReason for rejection (if rejecting)

Response

{
  "is_processed": true,
  "error_reason": null,
  "transaction_id": "a7b2a4b3-2f61-41a7-9f5a-3f3f0b1a3d22"
}
FieldTypeRequiredDescription
is_processedbooleanYesWhether settlement was processed
error_reasonstringNoInsufficientFunds or GeneralError
transaction_idUUIDYesRelated transaction ID (echo back). Must be a GUID — any other format fails the call

Mandatory vs Non-Mandatory Transactions

Field ValueAuthorization BehaviorSettlement Behavior
is_mandatory: falseRequires is_allowed: trueNormal processing
is_mandatory: trueProcessed regardless of responseProcessed regardless of response

Mandatory transactions include refunds, chargebacks, and network corrections. You are notified but cannot
decline them.


Authorization Behavior Summary

ScenarioNon-MandatoryMandatory
is_allowed: trueProcessedProcessed
is_allowed: falseDeclinedProcessed
Timeout (>500ms)DeclinedProcessed
5xx errorDeclinedProcessed

Implementation Example

The handlers keep one ledger per corporation, keyed by user_id, and one record per operation, keyed by
unique_operation_id.

const basePath = '/external-authorization/on-chain/card-transaction/external';

// Authorization endpoint
app.post(`${basePath}/authorize`, async (req, res) => {
  const {
    user_id: corporationId,
    card_id,
    transaction_id,
    amount,
    currency,
    is_mandatory,
    unique_operation_id
  } = req.body;

  // Check idempotency
  const existing = await ledger.findOperation(unique_operation_id);
  if (existing) {
    return res.json({
      transaction_id, // echo back unchanged
      is_allowed: existing.allowed,
      decline_reason: existing.allowed ? null : 'InsufficientFunds'
    });
  }

  // No employee id is sent: resolve the cardholder from your own card_id mapping
  const cardholder = await ledger.cardholderByCard(card_id);

  // For mandatory transactions, always allow
  if (is_mandatory) {
    await ledger.recordOperation(unique_operation_id, corporationId, cardholder, amount, currency, true);
    return res.json({ transaction_id, is_allowed: true });
  }

  // Check the corporation's balance in your ledger
  const balance = await ledger.getCorporationBalance(corporationId, currency);
  const allowed = balance >= amount;

  if (allowed) {
    await ledger.holdBalance(corporationId, amount, currency, unique_operation_id);
  }

  await ledger.recordOperation(unique_operation_id, corporationId, cardholder, amount, currency, allowed);

  res.json({
    transaction_id,
    is_allowed: allowed,
    decline_reason: allowed ? null : 'InsufficientFunds'
  });
});

// Settlement endpoint
app.post(`${basePath}/settle`, async (req, res) => {
  const {
    transaction_id,
    user_id: corporationId,
    unique_operation_id,
    settlement_amount,
    settlement_currency,
    settlement_decision
  } = req.body;

  const operation = await ledger.findOperation(unique_operation_id);
  if (!operation) {
    return res.json({
      is_processed: false,
      error_reason: 'GeneralError',
      transaction_id
    });
  }

  if (settlement_decision === 0) { // 0 = Approve: book the debit
    await ledger.finalizeDebit(corporationId, settlement_amount, settlement_currency, unique_operation_id);
  } else { // 1 = Reject: release your hold
    await ledger.releaseHold(corporationId, unique_operation_id);
  }

  res.json({
    is_processed: true,
    transaction_id
  });
});

Book the debit only when settlement_decision is 0, and release the hold when it is 1. Store the
booking under unique_operation_id: the activities webhook later carries the same value as
operations[].operation_id, so the movement is not booked twice — see
Cardholders and Cards.


Error Handling

Your API Unavailable

  • Non-mandatory transactions: Declined
  • Mandatory transactions: Processed anyway

Master Account Below the Threshold

  • Wirex declines the authorization without calling your authorize endpoint when the Master Account balance
    is below the threshold plus the amount.
  • Authorization reserves no funds on the Master Account, so the threshold is the only buffer against
    concurrent spend. Bank transfers, OCT and FX do not check it — see
    Overview.

Did this page help you?