> For the complete documentation index, see [llms.txt](https://switchng.gitbook.io/switch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://switchng.gitbook.io/switch/cards.md).

# Cards

```
STAGING_URL: https://switchapi3.azurewebsites.net
LIVE_URL: https://switchapi.azurewebsites.net
```

## Get card list

<mark style="color:blue;">`GET`</mark> `https://switchapi3.azurewebsites.net/user/cards/`

Retrieve user's cards.

#### Headers

| Name          | Type   | Description                                          |
| ------------- | ------ | ---------------------------------------------------- |
| SWI-CID       | string | Client ID                                            |
| Authorization | string | Format for ***Authorization*** is ***Bearer token*** |

{% tabs %}
{% tab title="200 " %}

```
{
    "message": "Cards retrieved successfully",
    "data": [
        {
            "id": "63",
            "card_type": "visa DEBIT",
            "expiry_month": "12",
            "expiry_year": "2020",
            "country_code": "NG",
            "last_4": "4081",
            "bin": "408408",
            "authorization_code": "AUTH_ifhxo8mr0c"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Get card

<mark style="color:blue;">`GET`</mark> `https://switchapi3.azurewebsites.net/user/cards/:id`

Retrieve card by id.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | Card id     |

#### Headers

| Name          | Type   | Description                                          |
| ------------- | ------ | ---------------------------------------------------- |
| SWI-CID       | string | Client ID                                            |
| Authorization | string | Format for ***Authorization*** is ***Bearer token*** |

{% tabs %}
{% tab title="200 " %}

```
{
    "message": "Card retrieved successfully",
    "data": {
        "id": 63,
        "authorization_code": "AUTH_ifhxo8mr0c",
        "bin": "408408",
        "card_type": "visa DEBIT",
        "country_code": "NG",
        "expiry_month": "12",
        "expiry_year": "2020",
        "last_4": "4081"
    }
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "message": "Card does not belong to this user"
}
```

{% endtab %}
{% endtabs %}

## Fund with saved card

<mark style="color:green;">`POST`</mark> `https://switchapi3.azurewebsites.net/user/cards/charge/:id`

This endpoint funds the user's wallet or account.

#### Path Parameters

| Name | Type   | Description        |
| ---- | ------ | ------------------ |
| id   | string | The id of the card |

#### Headers

| Name          | Type   | Description                  |
| ------------- | ------ | ---------------------------- |
| SWI-CS        | string | Payload checksum             |
| SWI-CID       | string | Client ID                    |
| Authorization | string | Format is ***Bearer token*** |

#### Request Body

| Name                 | Type   | Description                                                                          |
| -------------------- | ------ | ------------------------------------------------------------------------------------ |
| pin                  | string | Authenticate transaction. Required if user's set 2fa is pin.                         |
| otp                  | string | Authenticate transaction. Required if user's set 2fa is otp or google authenticator. |
| funding\_destination | string | wallet or account. Defaults to wallet.                                               |
| amount\_kobo         | string | The amount in kobo.                                                                  |

{% tabs %}
{% tab title="200 " %}

```
{
  "message": "Funding successful"
}
```

{% endtab %}

{% tab title="400 " %}

```
{
  "message": "Invalid pin"
}
```

{% endtab %}
{% endtabs %}

## Delete saved card

<mark style="color:red;">`DELETE`</mark> `https://switchapi3.azurewebsites.net/user/cards/:id`

This endpoint deletes a user's saved card.

#### Path Parameters

| Name | Type   | Description         |
| ---- | ------ | ------------------- |
| id   | string | The id of the card. |

#### Headers

| Name          | Type   | Description                                     |
| ------------- | ------ | ----------------------------------------------- |
| SWI-CID       | string | Client ID                                       |
| Authorization | string | Format for Authorization is ***Bearer token***. |

{% tabs %}
{% tab title="200 " %}

```
{
  "message": "Card deleted successfully"
}
```

{% endtab %}

{% tab title="400 " %}

```
{
  "message": "Card does not belong to this user"
}
```

{% endtab %}
{% endtabs %}
