# Accounts

## Create Account

Creates a new financial account with a specific category and asset.

```
POST /account
```

### Request

```json
{
  "category": "PAYMENT_ACCOUNT",
  "asset": "BRL"
}
```

| Field      | Type   | Required | Description                                |
| ---------- | ------ | -------- | ------------------------------------------ |
| `category` | String | Yes      | Account category (e.g., `PAYMENT_ACCOUNT`) |
| `asset`    | String | Yes      | Currency code (e.g., `BRL`, `USD`)         |

Both fields accept only `A-Z`, `0-9`, `_` and are auto-converted to uppercase.

### Response — `201 Created`

```json
{
  "id": "019702a0-1234-7abc-8def-000000000001"
}
```

The account is created with `balance = 0` and `version = 0`.

### Example

```bash
curl -X POST http://<host>:8080/account \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: ak_..." \
  -H "X-Api-Secret: sk_..." \
  -d '{"category": "PAYMENT_ACCOUNT", "asset": "BRL"}'
```

***

## Get Account

Retrieves an account's current balance and metadata.

```
GET /account/:id
```

### Response — `200 OK`

```json
{
  "id": "019702a0-1234-7abc-8def-000000000001",
  "category": "PAYMENT_ACCOUNT",
  "asset": "BRL",
  "balance": 15000,
  "version": 12,
  "created_at": "2026-01-15T10:30:00.123Z"
}
```

### Errors

| HTTP | Code                | Cause                       |
| ---- | ------------------- | --------------------------- |
| 404  | `ACCOUNT_NOT_FOUND` | Account UUID does not exist |

### Example

```bash
curl http://<host>:8080/account/019702a0-1234-7abc-8def-000000000001 \
  -H "X-Api-Key: ak_..." \
  -H "X-Api-Secret: sk_..."
```

***

## Get Account Ledger

Retrieves the ledger (account statement) for an account. See [Ledger API](/docs/api-reference/ledger.md) for details.

```
GET /account/:id/ledger
```

***

## Balance Summary by Asset

Returns the total balance grouped by category for all accounts with the specified asset.

```
GET /account/asset/:asset
```

### Response — `200 OK`

```json
[
  {
    "category": "PAYMENT_ACCOUNT",
    "asset": "BRL",
    "total_balance": 5000000,
    "account_count": 150
  },
  {
    "category": "PIX_ASSET",
    "asset": "BRL",
    "total_balance": -5000000,
    "account_count": 1
  }
]
```

### Example

```bash
curl http://<host>:8080/account/asset/BRL \
  -H "X-Api-Key: ak_..." \
  -H "X-Api-Secret: sk_..."
```

{% hint style="info" %}
In a healthy system, the sum of all `total_balance` values across all categories for the same asset should always be zero.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://entrytarget.gitbook.io/docs/api-reference/accounts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
