# User Balance (Site Endpoint)

Called to retrieve the current balance for a user before or during gameplay.

### Endpoint

```
POST https://{YOUR_SITE}/gold_api
```

**Content-Type:** `application/json`

**Method:** `user_balance`

### Request

```json
{
    "method": "user_balance",
    "agent_code": "your_agent_code",
    "agent_secret": "your_agent_secret",
    "user_code": "test",
    "user_token": "c3041c6d9146a164387fa454eff7b432",
    "game_code": "vs20olympgate"
}
```

<table><thead><tr><th width="132">Field</th><th width="104">Type</th><th width="110">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>method</code></td><td>string</td><td>Yes</td><td>Must be <code>user_balance</code></td></tr><tr><td><code>agent_code</code></td><td>string</td><td>Yes</td><td>Agent code</td></tr><tr><td><code>agent_secret</code></td><td>string</td><td>Yes</td><td>Agent secret key</td></tr><tr><td><code>user_code</code></td><td>string</td><td>Yes</td><td>User identifier</td></tr><tr><td><code>user_token</code></td><td>string</td><td>Yes</td><td>User session token</td></tr><tr><td><code>game_code</code></td><td>string</td><td>No</td><td>Game being played. Can be missing or empty (e.g. for sportsbook)</td></tr></tbody></table>

### Response

#### Success

Return balance even if it is `0`:

```json
{
    "status": 1,
    "user_balance": 0
}
```

#### Failure

```json
{
    "status": 0,
    "user_balance": 0,
    "msg": "INTERNAL_ERROR"
}
```

Any `status` other than `1` is a failure, and so is no answer within 5 seconds, a network error or an HTTP status other than 2xx: the balance request then fails. The `user_balance` and `msg` of a failure answer are not used (`msg` is only logged).
