> ## Documentation Index
> Fetch the complete documentation index at: https://dev.nickel.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Charge Customers Automatically (Autopay)

> Get authorization to charge a customer once, then pay their invoices without them lifting a finger

For repeat customers — monthly service, net-terms accounts, subscriptions — you don't want every invoice to wait on someone clicking a link. A **charge authorization** is your customer's permission to charge a payment method they've put on file. Once it's active, you can pay their invoices directly from the API.

<Note>
  In the API, an invoice is a **payment link** — the endpoints and field names below say `paymentLink`. Same thing; this guide says "invoice" because that's what your customer sees.
</Note>

<Info>
  **Before you start**: You need a customer (see the [Quickstart](/guides/quickstart)) and a [webhook subscription](/guides/receive-webhooks) to hear when authorizations are granted. Amounts are in cents throughout.
</Info>

<Steps>
  <Step title="Ask the customer to authorize you">
    Request authorization with [`POST /customer/{customerId}/requestChargeAuthorization`](/api-reference/charge-authorization/request-charge-authorization-from-a-customer). With `sendEmail: true`, Nickel emails the customer a secure form where they enter their card or bank details; with `false`, you get the form's `url` back to deliver however you like:

    ```bash theme={null}
    curl -X POST https://rest.staging.nickel.com/customer/cmr9zja1s0000sf028pvdtpsh/requestChargeAuthorization \
      -H "Authorization: Bearer $NICKEL_SANDBOX_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "sendEmail": false,
        "paymentMethodTypes": ["ACH", "CREDIT_CARD"],
        "transactionLimitCents": 500000,
        "expirationDate": "2027-07-01"
      }'
    ```

    ```json theme={null}
    {
      "id": "cmra1chkb001usf02i34fnbbt",
      "active": false,
      "url": "https://nickel.staging.nickelpayments.com/customer/cmr9zja1s0000sf028pvdtpsh?requestId=EYTtDSxk",
      "transactionLimitInCents": 500000,
      "expiresAt": 1814400000000,
      "paymentMethod": null,
      "customerId": "cmr9zja1s0000sf028pvdtpsh"
    }
    ```

    The authorization starts `active: false` with no payment method — it activates when your customer completes the form. `transactionLimitCents` caps any single charge, and `expirationDate` (`YYYY-MM-DD`) sets an end date.

    <Note>
      Watch the field names: you send `transactionLimitCents`, but responses return `transactionLimitInCents` — and `expiresAt` comes back as epoch **milliseconds**.
    </Note>
  </Step>

  <Step title="Already have a signed ACH form? Skip the wait">
    If the customer already signed an ACH debit authorization (a common part of net-terms paperwork), create the authorization directly — upload the signed PDF via [`POST /file`](/api-reference/file/upload-a-file) with `type=ACH_DEBIT_AUTHORIZATION_PDF`, then attach it with their bank details:

    ```bash theme={null}
    curl -X POST https://rest.staging.nickel.com/customer/cmr9zja1s0000sf028pvdtpsh/uploadACHDebitAuthorizationPdf \
      -H "Authorization: Bearer $NICKEL_SANDBOX_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "routingNumber": "101050001",
        "accountNumber": "987654321",
        "accountType": "checking",
        "fileId": "cmra1a8zi001osf02tcmt858v",
        "memo": "Monthly service autopay",
        "transactionLimitCents": 500000
      }'
    ```

    ```json theme={null}
    {
      "id": "cmra1c0mb001ssf02t4sz8k2q",
      "active": true,
      "transactionLimitInCents": 500000,
      "expiresAt": null,
      "paymentMethod": {
        "type": "ACH",
        "achDetails": {
          "bankName": "First Bank of the United States",
          "routingNumber": "101050001",
          "accountNumberLastFour": "4321"
        },
        ...
      },
      "customerId": "cmr9zja1s0000sf028pvdtpsh"
    }
    ```

    No waiting — the authorization is `active: true` immediately, because the customer already consented on paper. Keep the signed PDF honest: it's your proof of authorization for ACH rules.
  </Step>

  <Step title="Wait for the green light">
    When the customer completes the hosted form (or you upload a signed PDF), your webhook receives `charge_authorization.authorized` — here's a real delivery:

    ```json theme={null}
    {
      "id": "b637dc72-aed7-419e-9d9c-eb3fb0a70583",
      "created_at": "2026-07-07T02:33:55.253Z",
      "associated_object_type": "charge_authorization",
      "associated_object_id": "cmra1c0mb001ssf02t4sz8k2q",
      "category": "charge_authorization.authorized",
      "type": "event"
    }
    ```

    Confirm with [`GET /chargeAuthorization/{chargeAuthorizationId}`](/api-reference/charge-authorization/returns-a-charge-authorization-by-id) — you're looking for `active: true` and a populated `paymentMethod`.
  </Step>

  <Step title="Charge invoices">
    Create invoices as usual ([`POST /paymentLink`](/api-reference/payment-link/create-a-new-payment-link)), then pay them with [`POST /chargeAuthorization/pay`](/api-reference/charge-authorization/make-payments-using-charge-authorizations). The request is a batch — one entry per authorization, each charging one or more invoices via the `paymentLinks` array:

    ```bash theme={null}
    curl -X POST https://rest.staging.nickel.com/chargeAuthorization/pay \
      -H "Authorization: Bearer $NICKEL_SANDBOX_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "payments": [
          {
            "chargeAuthorizationId": "cmra1c0mb001ssf02t4sz8k2q",
            "paymentLinks": [{"paymentLinkId": "cmra1chnp001ysf02cumv23r7"}]
          }
        ],
        "idempotencyKey": "autopay-2026-07-06-run1"
      }'
    ```

    ```json theme={null}
    {
      "paymentLinks": [
        {
          "id": "cmra1chnp001ysf02cumv23r7",
          "name": "INV-124",
          "status": "ACTIVE",
          "requestedAmountCents": 45000,
          "completedAmountCents": 0,
          "paymentId": "cmra1cu1h0020sf02v55com2p",
          ...
        }
      ],
      "errors": []
    }
    ```

    <Warning>
      Always send an `idempotencyKey` (any string unique to this batch, like `autopay-2026-07-06-run1`). If your request times out and you retry with the same key, Nickel won't charge the same invoices twice.
    </Warning>

    Per invoice you can add `amountCents` (omit it to charge the invoice's remaining balance) and `withdrawalDate` (`YYYY-MM-DD`, today or later) to schedule the charge instead of processing immediately.

    Notice the response above: the ACH charge was created (`paymentId` is set) but the invoice still shows `status: "ACTIVE"` and `completedAmountCents: 0` — bank debits take days to settle. Card charges settle synchronously and complete the invoice right away.
  </Step>

  <Step title="Handle the aftermath">
    The batch **partially succeeds**: invoices that couldn't be charged (authorization expired, over the transaction limit, already paid) come back in `errors[]` with a `paymentLinkId` and a human-readable `error`, while the rest go through. Check it on every call.

    From here it's the standard payment lifecycle — `payment.made` fires (for ACH that means *initiated*; the payment is `PENDING` until funds arrive), and you track it exactly as in [Send an Invoice and Get Paid](/guides/send-an-invoice).

    One more event matters to autopay: `charge_authorization.deleted` fires if the customer (or you) revokes the authorization. Stop charging when you receive it — a quick `GET` to confirm `active` before each batch is cheap insurance.
  </Step>
</Steps>

## Where to go next

<Columns cols={2}>
  <Card title="Receive webhooks" href="/guides/receive-webhooks" icon="bolt">
    The receiver that hears charge\_authorization.authorized.
  </Card>

  <Card title="Refund or void a payment" href="/guides/refunds" icon="rotate-left">
    When an autopay charge shouldn't have happened.
  </Card>
</Columns>
