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

# Get Wallet Balance

> Retrieve your current wallet balance

## Endpoint

```
GET /api/wallet/balance
```

## Description

This endpoint returns the current balance in your Vellosim wallet. Your wallet balance is used to purchase eSIM packages.

## Authentication

This endpoint requires authentication using your API key in the `X-API-Key` header.

**Production:**

```
X-API-Key: vls_live_YOUR_API_KEY
```

**Testing/Sandbox:**

```
X-API-Key: vls_test_YOUR_API_KEY
```

## Request

### Headers

| Header        | Value            | Required |
| ------------- | ---------------- | -------- |
| Authorization | YOUR\_API\_KEY   | Yes      |
| Content-Type  | application/json | Yes      |

### Parameters

This endpoint does not require any parameters.

## Response

### Success Response (200 OK)

```json theme={null}
{
  "success": true,
  "data": {
    "balance": 1250.50,
    "currency": "USD",
    "lastUpdated": "2024-11-10T10:30:00Z"
  }
}
```

### Response Fields

| Field       | Type   | Description                               |
| ----------- | ------ | ----------------------------------------- |
| balance     | number | Current wallet balance                    |
| currency    | string | Currency code (USD, EUR, etc.)            |
| lastUpdated | string | ISO 8601 timestamp of last balance update |

## Error Responses

### 401 Unauthorized

```json theme={null}
{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing API key"
  },
  "statusCode": 401
}
```

### 500 Internal Server Error

```json theme={null}
{
  "success": false,
  "error": {
    "code": "INTERNAL_ERROR",
    "message": "An internal error occurred"
  },
  "statusCode": 500
}
```

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.vellosim.com/api/wallet/balance \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json'
  ```

  ```javascript JavaScript theme={null}
  const getBalance = async () => {
    const response = await fetch('https://api.vellosim.com/api/wallet/balance', {
      method: 'GET',
      headers: {
        'X-API-Key': `YOUR_API_KEY}`,
        'Content-Type': 'application/json'
      }
    });

    const data = await response.json();
    console.log('Current balance:', data.data.balance);
    return data;
  };
  ```

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

  headers = {
      'X-API-Key': f' {YOUR_API_KEY}',
      'Content-Type': 'application/json'
  }

  response = requests.get(
      'https://api.vellosim.com/api/wallet/balance',
      headers=headers
  )

  data = response.json()
  print(f"Current balance: {data['data']['balance']}")
  ```

  ```php PHP theme={null}
  <?php
  $apiKey = 'YOUR_API_KEY';

  $ch = curl_init('https://api.vellosim.com/api/wallet/balance');
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'X-API-Key: ' . $apiKey,
      'Content-Type: application/json'
  ]);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($ch);
  $data = json_decode($response, true);

  echo "Current balance: " . $data['data']['balance'];
  curl_close($ch);
  ?>
  ```
</CodeGroup>

## Notes

<Note>
  Check your wallet balance before attempting to purchase eSIM packages to ensure you have sufficient funds.
</Note>

<Tip>
  You can top up your wallet balance from your [Vellosim dashboard](https://vellosim.com/dashboard/wallet).
</Tip>
