---
title: "Set a customer's automatic top-up"
description: "Buys credit when the live balance is at or below threshold_minor, or on a schedule."
canonical_url: "https://twominutebilling.com/help/developers/api-reference/usage-controls/set-a-customer-s-automatic-top-up"
---
# Set a customer's automatic top-up

> Buys credit when the live balance is at or below threshold_minor, or on a schedule.

<api-operation method="PUT" path="/v1/businesses/{biz}/customers/{cus}/auto_topup">
<template v-slot:docs="">

Buys credit when the live balance is at or below `threshold_minor`, or on a schedule. `fixed` buys `amount_minor` (a multiple of it, so the balance lands above the threshold); `target` buys up to `target_minor`. Each run stays inside the business's top-up limits, the monthly cap and `max_runs_per_day`; on an INR card or UPI mandate a run is at most ₹15,000. Credit is granted only when the purchase invoice is paid. A decline voids the invoice and turns automatic top-up off. On a payment method that needs an advance notice, a threshold below the notice lead's usage at the current rate is refused. Needs `usage_controls:manage`.

## Path parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        biz
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      The business's id (biz_…).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cus
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      The customer's id (cus_…).
    </td>
  </tr>
</tbody>
</table>

## Headers

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        Idempotency-Key
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Safely retry writes — repeats return the original response. If a write FAILED after it had already taken effect, that failure is what repeats: the key is spent, and a new attempt needs a new key.
    </td>
  </tr>
</tbody>
</table>

## Body

The request body is **required**.

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      ISO currency. Default: the credit unit's, else the customer's.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unit
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      The credit unit's id. Null or absent = money credit.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        trigger
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      What started the auto topup input. One of <code>
        threshold
      </code>
      
      , <code>
        schedule
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        threshold_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Buy when the live balance is at or below this.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        schedule
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      <code>
        {every: week, weekday: 1–7}
      </code>
      
       (ISO, 1 = Monday) or <code>
        {every: month, day: 1–31}
      </code>
      
      . A day past the month's end runs on its last day.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        method
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      The method. One of <code>
        fixed
      </code>
      
      , <code>
        target
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        amount_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      <code>
        fixed
      </code>
      
      : the amount to buy.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        target_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      <code>
        target
      </code>
      
      : buy up to this balance.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        monthly_cap_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      Most that runs can buy per calendar month.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        max_runs_per_day
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      1 to 10. Default 3.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        payment_method
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      The <code>
        pm_…
      </code>
      
       to charge. Null = the customer's charge order.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grant
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      The credit each run buys.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grant.tax_treatment
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      The grant's tax treatment. One of <code>
        taxed_at_purchase
      </code>
      
      , <code>
        taxed_at_use
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grant.priority
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Lower draws first. 0 to 100.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grant.expires_after_months
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      The credit expires this many months after payment.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grant.applicability
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      <code>
        {kind: metered}
      </code>
      
       or <code>
        {kind: prices, prices}
      </code>
      
      .
    </td>
  </tr>
</tbody>
</table>

## Response

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The object type; always <code>
        auto_topup
      </code>
      
      . One of <code>
        auto_topup
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      atu_…
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        customer
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      cus_…
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      ISO currency.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unit
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The credit unit's id.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        trigger
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      What started the auto topup. One of <code>
        threshold
      </code>
      
      , <code>
        schedule
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        threshold_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The threshold.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        schedule
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <code>
        {every: week, weekday: 1–7}
      </code>
      
       (ISO, 1 = Monday) or <code>
        {every: month, day: 1–31}
      </code>
      
      . A day past the month's end runs on its last day.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        method
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The method. One of <code>
        fixed
      </code>
      
      , <code>
        target
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        amount_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The fixed amount.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        target_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The target balance.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        monthly_cap_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The monthly cap.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        max_runs_per_day
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      Runs per day.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        payment_method
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      pm_…
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grant
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      The credit each run buys.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The auto topup's status. One of <code>
        active
      </code>
      
      , <code>
        disabled
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        disabled_reason
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      payment_declined, operator or customer.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        disabled_at
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      ISO 8601.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        threshold_low_at
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Last <code>
        credit_auto_topup_threshold_low
      </code>
      
      , ISO 8601.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        lead_time
      </code>
    </td>
    
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      The notice lead rule on the payment method a run charges first (read and save). <code>
        required_threshold_minor
      </code>
      
       = <code>
        lead_hours
      </code>
      
       of usage at the current rate.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        created_at
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      ISO 8601.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        updated_at
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      ISO 8601.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        resource_version
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      Version.
    </td>
  </tr>
</tbody>
</table>

## Status codes

<table>
<thead>
  <tr>
    <th>
      Status
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        200
      </code>
    </td>
    
    <td>
      The automatic top-up.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        400
      </code>
    </td>
    
    <td>
      The body is not correct, or a rule refused it.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        404
      </code>
    </td>
    
    <td>
      No such customer, credit unit or payment method.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      Idempotency-Key conflict — the key is already in flight, or was reused with a different request payload.
    </td>
  </tr>
</tbody>
</table>
</template>

<template v-slot:request="">

```bash [Request]
curl -X PUT "$TMBILLING_URL/v1/businesses/biz_XXXXXXXXXXXX01/customers/cus_XXXXXXXXXXXX01/auto_topup" \
  -H "Authorization: Bearer $TMBILLING_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "currency": "USD",
    "trigger": "threshold",
    "method": "fixed",
    "amount_minor": 2900,
    "monthly_cap_minor": 2900,
    "grant": {
      "tax_treatment": "taxed_at_purchase"
    }
  }'
```

</template>

<template v-slot:response="">
<code-group>

```json [200 OK]
{
  "object": "auto_topup",
  "id": "atu_XXXXXXXXXXXX01",
  "customer": "cus_XXXXXXXXXXXX01",
  "currency": "USD",
  "unit": "seat",
  "trigger": "threshold",
  "threshold_minor": 2900,
  "schedule": {},
  "method": "fixed",
  "amount_minor": 2900,
  "target_minor": 2900,
  "monthly_cap_minor": 2900,
  "max_runs_per_day": 14,
  "payment_method": "pm_XXXXXXXXXXXX01",
  "grant": {
    "tax_treatment": "taxed_at_purchase",
    "priority": 1,
    "expires_after_months": 1,
    "applicability": {}
  },
  "status": "active",
  "disabled_reason": null,
  "disabled_at": "2026-03-14T09:30:00Z",
  "threshold_low_at": "2026-03-14T09:30:00Z",
  "lead_time": {
    "lead_hours": 1,
    "burn_minor_per_day": 14,
    "required_threshold_minor": 2900,
    "warning": "Warning"
  },
  "created_at": "2026-03-14T09:30:00Z",
  "updated_at": "2026-03-14T09:30:00Z",
  "resource_version": 1
}
```

```json [400 Bad Request]
{
  "error": {
    "type": "invalid_request_error",
    "message": "The body is not correct, or a rule refused it."
  }
}
```

```json [404 Not Found]
{
  "error": {
    "type": "invalid_request_error",
    "message": "No such customer, credit unit or payment method."
  }
}
```

```json [409 Conflict]
{
  "error": {
    "type": "idempotency_error",
    "message": "Idempotency-Key conflict — the key is already in flight, or was reused with a different request payload."
  }
}
```

</code-group>
</template>
</api-operation>


## Sitemap

See the full [sitemap](https://twominutebilling.com/sitemap.md) for all pages.
