Skip to content

Recharge a card ​

Add funds to an existing active card. Recharge uses the same two-step x402 flow as issuance: initiate, sign the payment with a mandate, then complete.

CLI

bash
fluxa-wallet card recharge --id card_7Hq2LmX9pRt4 --amount 10.00 --mandate <mandate_id>
# continue the same recharge later (card is inferred):
fluxa-wallet card recharge --request-id <pendingRequestId> --mandate <mandate_id>

You need a signed USDC mandate whose remaining budget covers amountUsd + feeUsd.


Initiate a recharge ​

POST/api/v2/cards/{cardId}/recharge/initiateBearer agent-vc
bash
curl -X POST https://agentcard.fluxapay.xyz/api/v2/cards/card_7Hq2LmX9pRt4/recharge/initiate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AGENT_VC" \
  -d '{ "amountUsd": "10.00" }'
FieldTypeRequiredDescription
amountUsdstringyesAmount to add, in USD with up to two decimals. On 400 invalid_amount the error message states the allowed range. The resulting balance must also stay within the per-card balance cap.

Response 200:

json
{
  "pendingRequestId": "9d3e1f7a-2c4b-4a8e-b6d0-1e5f7a9c3b21",
  "status": "pending_payment",
  "amountUsd": "10.00",
  "feeUsd": "0.00",
  "totalUsd": "10.00",
  "expiresAt": "2026-10-27T11:05:00.000Z",
  "paymentRequest": { "x402Version": 1, "accepts": [ { "…": "…" } ] },
  "paymentLinkId": "…",
  "checkoutUrl": null
}

feeUsd is the recharge fee you will pay on top of amountUsd. Sign paymentRequest with your mandate as described in Sign the payment with a mandate.

Only one recharge can be open per card. If one is already in progress you get 409 recharge_in_progress with details.pendingRequestId; continue that request instead.


Complete a recharge ​

POST/api/v2/cards/{cardId}/recharge/completeBearer agent-vc
bash
curl -X POST https://agentcard.fluxapay.xyz/api/v2/cards/card_7Hq2LmX9pRt4/recharge/complete \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AGENT_VC" \
  -d '{
    "pendingRequestId": "9d3e1f7a-2c4b-4a8e-b6d0-1e5f7a9c3b21",
    "paymentPayloadB64": "<xPaymentB64>"
  }'

Response 200 — funds added:

json
{
  "success": true,
  "card": { "id": "card_7Hq2LmX9pRt4", "remainingAmountUsd": "28.40", "…": "see Card object" },
  "recharge": { "amountUsd": "10.00", "feeUsd": "0.00" }
}

Response 202 — payment received, funds still being added:

json
{
  "success": false,
  "status": "payment_submitted",
  "pendingRequestId": "9d3e1f7a-2c4b-4a8e-b6d0-1e5f7a9c3b21",
  "message": "Payment submitted; recharge will complete automatically once settlement is confirmed"
}

On 202, do not pay again. Poll GET /api/v2/cards/requests/{pendingRequestId} until status is completed, then read the balance.


Errors ​

StatuscodeWhat to do
400invalid_amountUse an amount within the range in the error message.
400card_balance_limit_exceededThe card would exceed its balance cap. Use a smaller amount.
400pending_request_card_mismatchThe request belongs to another card. Use the matching cardId.
400recharge_not_supportedThis card cannot be recharged.
404card_not_found, pending_request_not_foundCheck the IDs.
409card_not_activeOnly active cards can be recharged.
409recharge_in_progressContinue the request in details.pendingRequestId.
409pending_request_invalid_statusThe request is no longer payable. Check its status.
410pending_request_expiredThe payment window passed. Start a new recharge.

See Errors for the full list.

Released under the MIT License.