> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prava.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Default Card

> Choose which of a customer's saved cards is preselected at checkout

Set one of a customer's saved cards as their default. The default card is listed first in [List Cards](https://docs.prava.space/api-reference/list-cards.md) with `is_default: true` and is preselected in the payment iframe's saved-card list. The customer can still choose another card at checkout.

`PATCH /v1/cards/{id}/default` · Authenticated with your secret key.

The card identifies the customer, so the card ID is all you need to send. Get card IDs from [List Cards](https://docs.prava.space/api-reference/list-cards.md) or the [`card.saved`](https://docs.prava.space/webhooks/events#card-lifecycle) webhook.

> [!NOTE]
>
> If no default has been set, or the default card is deleted, the customer's oldest active card is preselected until you set a new default.

## Path parameters

**id** `string` *required*

The card to make the default (`card_id` from [List Cards](https://docs.prava.space/api-reference/list-cards.md)). It must be an active card saved through your merchant account.

## Response

**success** `boolean`

Whether the default was set.

**default\_card\_id** `string`

The card that is now the customer's default.

## Error responses

| Status | Code | Cause | Resolution |
| - | - | - | - |
| 401 | `AUTH_1001` | Invalid API key | Check your secret key |
| 404 | `NOT_FOUND` | Card doesn't exist, is deleted, or wasn't saved through your merchant account | Verify `id` via [List Cards](https://docs.prava.space/api-reference/list-cards.md) |

```bash cURL theme={null}
curl -X PATCH https://sandbox.api.prava.space/v1/cards/card_1/default \
  -H "Authorization: Bearer sk_test_..."
```

```python Python theme={null}
import requests

resp = requests.patch(
    "https://sandbox.api.prava.space/v1/cards/card_1/default",
    headers={"Authorization": "Bearer sk_test_..."},
)
```

```javascript JavaScript theme={null}
const resp = await fetch("https://sandbox.api.prava.space/v1/cards/card_1/default", {
  method: "PATCH",
  headers: { Authorization: "Bearer sk_test_..." },
});
```

```json 200 Success theme={null}
{ "success": true, "default_card_id": "card_1" }
```

```json 404 Not Found theme={null}
{
  "error": { "code": "NOT_FOUND", "message": "Card not found or not active" }
}
```


## OpenAPI

````yaml api-reference/openapi.json PATCH /v1/cards/{id}/default
openapi: 3.1.0
info:
  title: Prava Payments API
  description: >-
    Server-side REST API for Prava Payments. All requests are authenticated with
    your secret key (sk_test_* in sandbox, sk_live_* in production).
  version: 1.0.0
servers:
  - url: https://sandbox.api.prava.space
    description: Sandbox
  - url: https://api.prava.space
    description: Production
security:
  - bearerAuth: []
paths:
  /v1/cards/{id}/default:
    patch:
      summary: Set Default Card
      description: >-
        Set one of a customer's saved cards as their default. The card
        identifies the customer, so only the card ID is sent. The default is
        listed first in List Cards and preselected in the payment iframe's
        saved-card list.
      operationId: setDefaultCard
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: >-
            The card to make the default (card_id from List Cards). Must be an
            active card saved through your merchant account.
      responses:
        '200':
          description: Default card set
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  default_card_id:
                    type: string
                    description: The card that is now the customer's default
        '401':
          description: Invalid or missing API key (AUTH_1001)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            Card not found, deleted, or not saved through your merchant account
            (NOT_FOUND)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code (e.g. VAL_2001, AUTH_1001)
            message:
              type: string
              description: Human-readable error message
            details:
              type: object
              description: >-
                Optional — included for validation errors to specify which
                fields failed
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your secret key: sk_test_* (sandbox) or sk_live_* (production).'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.