> For the complete documentation index, see [llms.txt](https://tri.gitbook.io/tri-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tri.gitbook.io/tri-doc/liquidity-pool/balance/set-autofill-balance.md).

# Set Autofill Balance

### Liquidity Pool

<mark style="color:purple;">`PATCH`</mark> <https://sandbox.triangle.digital/api/v2/liquidity\\_pool/clients/{client\\_id}/balance>

Turns Autofill balance on or off for one Spending Capacity balance. With it on, a purchase paid from the balance charges the holder's saved card in $25 units for whatever the balance does not cover; with it off, a purchase the balance does not cover is refused, and a purchase paid from the balance must be at least 1 QTY and $25.00 in total — a smaller one is refused with `below_minimum` (see [Purchase Assets](/tri-doc/liquidity-pool/purchase-assets.md) and [Buy Carbon Pool](/tri-doc/liquidity-pool/buy-carbon-pool.md)). An automatic top-up obeys the same ceiling as [Add Balance](/tri-doc/liquidity-pool/balance/add-balance.md): one charge cannot exceed 9999.00, and a purchase needing more than that from the card is refused.

**Whose balance is changed.** One address serves every holder, and the holder is named in the body:

<table data-full-width="true"><thead><tr><th width="460">Body</th><th>Holder</th></tr></thead><tbody><tr><td><code>employee_id</code></td><td>That employee.</td></tr><tr><td><code>individual_consumption_id</code></td><td>That Individual Consumption.</td></tr><tr><td>Neither of the two</td><td><strong>The client's own balance</strong> — the one <a href="/tri-doc/liquidity-pool/balance/get-balance.md">Get Balance</a> answers at <code>/clients/{client_id}/balance</code>.</td></tr></tbody></table>

The two identifiers cannot be sent together. Business accounts hold money per employee, so sending neither of them answers `404` with the code `client_level_balance_unavailable` for such a client.

Autofill balance can be turned on before a card is saved: the value is stored and takes effect once the holder has one. Repeating the request stores the same value, so no `Idempotency-Key` is needed. The answer carries the balance resource with the stored value. Money, time and error formats follow the [conventions of the balance endpoints](/tri-doc/liquidity-pool/balance.md).

**Path parameters**

<table data-full-width="true" data-search="false"><thead><tr><th width="230">Name</th><th width="110">Type</th><th>Description</th><th width="210">Where to take it from</th></tr></thead><tbody><tr><td><code>client_id</code></td><td>integer</td><td><strong>Required.</strong> The client the balance belongs to.</td><td><a href="/tri-doc/liquidity-pool/get-clients.md">Get Clients</a> — <code>client_id</code></td></tr></tbody></table>

**Headers**

<table data-full-width="true"><thead><tr><th>Name</th><th>Value</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr></tbody></table>

**Query parameters**

<table data-full-width="true" data-search="false"><thead><tr><th width="159.800048828125">Name</th><th width="149">Type</th><th>Description</th><th width="160.796875">Example</th></tr></thead><tbody><tr><td><code>hash</code></td><td>string</td><td><strong>Required.</strong> API key.</td><td>fk5f0iuy-rr06-j4x3-i75b-fy2s67s4ilo1</td></tr></tbody></table>

**Body**

<table data-full-width="true" data-search="false"><thead><tr><th width="159.800048828125">Name</th><th width="149">Type</th><th>Description</th><th width="160.796875">Example</th></tr></thead><tbody><tr><td><code>autofill_balance</code></td><td>boolean</td><td><strong>Required.</strong> Whether the balance is topped up from the holder's saved card, in $25 units, when a purchase paid from the balance needs more than it holds.</td><td>true</td></tr><tr><td><code>employee_id</code></td><td>integer</td><td>The employee whose balance is changed. <strong>Omit it, and omit <code>individual_consumption_id</code> as well, to change the client's own balance.</strong> Cannot be sent together with <code>individual_consumption_id</code>. Taken from <a href="/tri-doc/liquidity-pool/get-employees.md">Get Employees</a> — <code>employee_id</code>.</td><td>107</td></tr><tr><td><code>individual_consumption_id</code></td><td>uuid</td><td>The Individual Consumption whose balance is changed. <strong>Omit it, and omit <code>employee_id</code> as well, to change the client's own balance.</strong> Cannot be sent together with <code>employee_id</code>. Taken from <a href="/tri-doc/liquidity-pool/get-individual-consumptions.md">Get Individual Consumptions</a> — <code>individual_consumption_id</code>.</td><td>7c2f9e10-4b8d-4a1e-9f33-6d05c8a2b741</td></tr></tbody></table>

```json
{
    "autofill_balance": true,
    "employee_id": 107
}
```

**Response fields**

<table data-full-width="true" data-search="false"><thead><tr><th width="230">Field</th><th width="110">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>balance</code></td><td>object</td><td>Current balance of the holder — <code>currency</code> (ISO 4217) and <code>amount</code> (decimal string).</td></tr><tr><td><code>credit_card</code></td><td>boolean</td><td>Whether the holder has a saved card. Without one Autofill balance is stored but nothing can be charged yet.</td></tr><tr><td><code>autofill_balance</code></td><td>boolean</td><td>The value stored by this call.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}
{% code fullWidth="false" %}

```json
{
    "balance": {
        "currency": "USD",
        "amount": "17.50"
    },
    "credit_card": true,
    "autofill_balance": true
}
```

{% endcode %}
{% endtab %}

{% tab title="404" %}
The holder does not exist or belongs to another client; or the client-level balance was addressed for a Business account, which holds balances per employee. See [Balance Error Codes](/tri-doc/liquidity-pool/balance/balance-error-codes.md).

```json
{
    "title": "This client holds balances per employee",
    "status": 404,
    "detail": "Address the balance of an employee or an individual consumption.",
    "code": "client_level_balance_unavailable"
}
```

{% endtab %}

{% tab title="422" %}
`autofill_balance` is missing or is not a boolean, or both holder identifiers were sent at once. Nothing was changed. See [Balance Error Codes](/tri-doc/liquidity-pool/balance/balance-error-codes.md).

```json
{
    "title": "Autofill balance is not a boolean",
    "status": 422,
    "detail": "Send autofill_balance as true or false.",
    "code": "invalid_autofill_balance",
    "param": "autofill_balance"
}
```

{% endtab %}
{% endtabs %}
