Skip to content

Set the default card

POST /api/v2/billing/cards/{id}/actions/set-default

Makes a saved card the account’s default card. Automatic charges use the default card. Paying an invoice with a saved card also uses it when you choose no other card. Send no body. Calling it on the current default changes nothing and still returns 200. The response is the full card list, with isPrimary: true on the new default.

Authentication: An API key with the scope write:payment_methods. About keys and scopes

Request

Path parameters

idstringrequired
The card ID (card_…).

Example

POST /api/v2/billing/cards/{id}/actions/set-default
curl -X POST "https://cloud.hostup.se/api/v2/billing/cards/card_01hxa3b4c5d6e7f8g9h0j1k2m3/actions/set-default" \
-H "Authorization: Bearer $HOSTUP_API_KEY" \
-H "Content-Type: application/json"

Responses

200 The full saved-card list with the new default.

Response 200
[
{
"id": "card_01hxa3b4c5d6e7f8g9h0j1k2m3",
"brand": "visa",
"last4": "4242",
"expMonth": 12,
"expYear": 2028,
"cardholderName": "Alex Example",
"isPrimary": true,
"addedAt": "2026-04-27T12:00:00.000Z"
},
{
"id": "card_01hxa3b4c5d6e7f8g9h0j1k2m4",
"brand": "mastercard",
"last4": "4444",
"expMonth": 3,
"expYear": 2027,
"cardholderName": "Alex Example",
"isPrimary": false,
"addedAt": "2025-11-02T09:30:00.000Z"
}
]

Errors

Errors are Problem Details with a stable code. Branch on the code, not on the text.

400Invalid request. The response body is an RFC 7807 Problem Details document.
401Unauthorized. Authentication is required.
403The API key lacks write:payment_methods. A session that is not the account owner gets it too.
404No saved card with this ID on the account.
429Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
500Internal error. Retry later or contact support if the issue persists.
502The default card could not be changed. Try again shortly.