<!-- ZenPays documentation · https://docs.zenpayz.com/docs/rest-api/endpoints/accounting/get-currency-balance -->

# Get Currency Balance

Retrieve wallet balance for a specific currency. Also used to create a new currency wallet if one does not exist.

## Get Balance

<EndpointHeader verb="GET" path="/merchant/api/v1/wallet/currency/{currency}" />

### Path Parameters

<ParamTable
  rows={[
    { name: "currency", type: "string", required: true, desc: "ISO 4217 currency code" },
  ]}
/>

### Headers

<ParamTable
  label="Header"
  rows={[
    { name: "Authorization", required: true, desc: "`Bearer {api_key}`" },
    { name: "X-Signature", required: true, desc: "HMAC-SHA256 signature" },
    { name: "X-Timestamp", required: true, desc: "ISO 8601 timestamp" },
    { name: "X-Secret-Salt", required: true, desc: "Secret salt for HMAC validation" },
  ]}
/>

### Response (200 OK)

```json
{
  "success": true,
  "data": {
    "wallet_id": "wal_xxxxx",
    "currency": "USD",
    "currency_symbol": "$",
    "available_balance": 250000,
    "total_balance": 270000,
    "blocked_balance": 5000,
    "pending_balance": 15000,
    "lifetime_balance": 1500000,
    "lifetime_withdrawn": 1230000,
    "status": "ACTIVE",
    "last_transaction_at": "2024-01-15T10:30:00.000Z"
  }
}
```

---

## Create Currency Wallet

<EndpointHeader verb="POST" path="/merchant/api/v1/wallet/currency/{currency}" />

Creates a new wallet for the specified currency.

### Path Parameters

<ParamTable
  rows={[
    { name: "currency", type: "string", required: true, desc: "ISO 4217 currency code" },
  ]}
/>

### Response (201 Created)

```json
{
  "success": true,
  "data": {
    "wallet_id": "wal_eur_001",
    "currency": "EUR",
    "currency_symbol": "€",
    "available_balance": 0,
    "total_balance": 0,
    "blocked_balance": 0,
    "pending_balance": 0,
    "lifetime_balance": 0,
    "lifetime_withdrawn": 0,
    "status": "ACTIVE",
    "last_transaction_at": "2024-01-15T10:30:00.000Z"
  }
}
```

<CodeRail>

## Examples

<Tabs groupId="language">
  <TabItem value="curl" label="cURL" default>

```bash
# Get balance for a currency
curl -X GET "https://api.zenpayz.com/merchant/api/v1/wallet/currency/USD" \
  -H "Authorization: Bearer zp_test_xxxxx" \
  -H "X-Timestamp: 2024-01-15T10:30:00.000Z" \
  -H "X-Signature: a1b2c3d4e5f6..." \
  -H "X-Secret-Salt: your_secret_salt"

# Create a new currency wallet
curl -X POST "https://api.zenpayz.com/merchant/api/v1/wallet/currency/EUR" \
  -H "Authorization: Bearer zp_test_xxxxx" \
  -H "X-Timestamp: 2024-01-15T10:30:00.000Z" \
  -H "X-Signature: a1b2c3d4e5f6..." \
  -H "X-Secret-Salt: your_secret_salt"
```

  </TabItem>
  <TabItem value="sdk" label="SDK">

```javascript
// Get balance for a currency
const balance = await zenpays.wallet.getBalance('USD');
console.log(`Available: ${balance.available}`);

// Create a new currency wallet via REST
// POST /merchant/api/v1/wallet/currency/EUR
```

  </TabItem>
</Tabs>

</CodeRail>
