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

# Recurring Purchases

> Charge the same stored card on a schedule under terms the user approved once

A recurring purchase reuses one enrollment and one mandate across many charges. The user approves the terms once, and each later charge runs inside those terms instead of prompting the user again.

## Before you start

You need an enrollment with status `ACTIVE`. [Setup](https://docs.reap.global/agentic-payments/setup.md) covers how to create one, and [`GET /agentic/enrollments/:id`](https://docs.reap.global/api-reference/agentic/get-enrollment) reads its status. Continue when `status` reads `ACTIVE`. Anything else means you cannot charge the card yet.

## Create the mandate

Create a mandate against an `ACTIVE` enrollment with [`POST /agentic/mandates`](https://docs.reap.global/api-reference/agentic/create-mandate). It requires an [`Idempotency-Key`](https://docs.reap.global/api-reference/idempotency). The mandate covers one merchant, so send the `merchantUrl` the user buys from. Send `amount.amount` as a decimal string. Omit `validUntil` to use the longest validity available.

> [!NOTE]
>
> Mandates work only for merchants that Reap has approved for your integration. Contact Reap to request access before you create a mandate for a new merchant.

Show your terms of service and privacy policy before you send the user to approve the mandate. [Consent and terms](https://docs.reap.global/agentic-payments/how-it-works.md#consent-and-terms) covers the rule.

```json Request body theme={null}
{
  "enrollmentId": "<enrollment-id>",
  "merchantUrl": "https://example.com",
  "frequency": "MONTHLY",
  "amount": { "amount": "150.00", "currency": "USD" },
  "presentation": { "type": "REDIRECT", "returnUrl": "https://example.com/mandates/approved" }
}
```

The mandate comes back as `REQUIRES_ACTION` with the approval page in `nextAction`:

```json Response (relevant fields) theme={null}
{
  "id": "<mandate-id>",
  "status": "REQUIRES_ACTION",
  "nextAction": { "type": "REDIRECT", "url": "<hosted-approval-url>" }
}
```

See the [create mandate reference](https://docs.reap.global/api-reference/agentic/create-mandate.md) for the full request and response.

Send the user to `nextAction.url` to review and approve the terms. The user returns to `presentation.returnUrl` afterward. Returning does not by itself mean the mandate is active, so read it with [`GET /agentic/mandates/:id`](https://docs.reap.global/api-reference/agentic/get-mandate) until `status` reads `ACTIVE`. A mandate the user does not approve before `nextAction.expiresAt` reports `EXPIRED`.

`ENROLLMENT_NOT_FOUND` means the enrollment does not exist. `ENROLLMENT_NOT_ACTIVE` means the stored card is not ready to charge, so read the enrollment and send the user through the hosted step again. `MERCHANT_URL_INVALID` means the URL is not a valid merchant site. `MERCHANT_NOT_SUPPORTED` means mandates are not available for that merchant, so contact Reap to request access. The [create mandate reference](https://docs.reap.global/api-reference/agentic/create-mandate.md) lists every code under its status.

Once the mandate is `ACTIVE`, read it with [`GET /agentic/mandates/:id`](https://docs.reap.global/api-reference/agentic/get-mandate) to check its terms.

| Term | What it does |
| - | - |
| `amount` | Sets the most one charge may total. The final quote total has to stay at or below it. |
| `frequency` | Sets the cadence as `WEEKLY`, `MONTHLY`, or `YEARLY`. The mandate allows one charge per cycle. |
| `merchant` | Names the one merchant the mandate may be charged at. |
| `validUntil` | Sets when the mandate stops authorizing charges. It is `null` until the validity is known. |
| `usage` | Shows what has been charged. `usage.cycle.renewsAt` says when the current cycle ends. |

You can charge only while `status` reads `ACTIVE`. [Lifecycle and Statuses](https://docs.reap.global/agentic-payments/lifecycle.md) lists every value.

## Find the product

Each cycle repeats this section and the next two, and reuses only the enrollment and the mandate. The amount check is the one point where a cycle can stop, so branch on it before you charge.

```mermaid theme={null}
flowchart LR
    A[Find the product] --> B[Quote and shipping]
    B --> C{"Total within the amount?"}
    C -- Yes --> D[Charge the mandate]
    C -- No --> E[Collect new terms from the user]
    D -. next cycle .-> A
```

Search the merchant catalogs, read the product details, and resolve the variant with the same calls as [Find the product](https://docs.reap.global/agentic-payments/one-time-purchases.md#find-the-product) in One-Time Purchases. The mandate covers one merchant, so add `merchantPreference` with `mode` set to `ONLY` and the merchant name in `merchantName` to keep the search at that merchant.

## Quote and shipping

Create a fresh quote for the cycle with [`POST /agentic/quotes`](https://docs.reap.global/api-reference/agentic/create-quote) and select a shipping option, with the same calls as [Quote and shipping](https://docs.reap.global/agentic-payments/one-time-purchases.md#quote-and-shipping) in One-Time Purchases. Merchant prices move, so never reuse a quote or an old total across cycles.

Check `amountBreakdown.finalAmount` against the mandate `amount` before you charge. Hold the cycle and ask the user for new terms when the total sits above it.

## Charge the mandate

Read the mandate before you charge. Confirm the status is `ACTIVE`, because a paused or canceled mandate cannot authorize the cycle. The mandate allows one charge per cycle, and `usage.cycle.renewsAt` says when the current cycle ends. While `usage.unresolvedCheckoutId` holds a value, an earlier charge has not settled and Reap accepts no new charge, so read that checkout until it settles.

Create the checkout with [`POST /agentic/checkouts`](https://docs.reap.global/api-reference/agentic/create-checkout) and send the `quoteId` with the `mandateId`. It requires an [`Idempotency-Key`](https://docs.reap.global/api-reference/idempotency).

```json Request body theme={null}
{
  "quoteId": "<quote-id>",
  "mandateId": "<mandate-id>"
}
```

A mandate charge sends `mandateId` where a [one-time checkout](https://docs.reap.global/agentic-payments/one-time-purchases.md#checkout) sends `enrollmentId` and `presentation`. Send one set or the other, never both. The response:

```json Response (relevant fields) theme={null}
{
  "id": "<checkout-id>",
  "status": "PROCESSING",
  "mandateId": "<mandate-id>",
  "nextAction": null
}
```

See the [create checkout reference](https://docs.reap.global/api-reference/agentic/create-checkout.md) for the full request and response.

The response has a `status` of `PROCESSING` and no `nextAction`, because the user approved the terms already and does not approve each charge. Read the checkout with [`GET /agentic/checkouts/:id`](https://docs.reap.global/api-reference/agentic/get-checkout) until it reaches a final status, then capture `orderId` and `finalAmount` for that cycle. A retry with the same quote returns the same checkout and does not charge twice.

`MANDATE_NOT_ACTIVE` means the mandate cannot be charged in its current status. `MANDATE_LIMIT_EXCEEDED` means the mandate does not authorize this purchase, and `detail.reason` says why. `CYCLE_ALREADY_USED` means a charge already ran in the current cycle, and `detail.renewsAt` gives when the next cycle begins. `BUDGET_EXCEEDED` means the charge goes over what the mandate allows. `MANDATE_CHARGE_UNRESOLVED` means an earlier charge has not settled, so wait for the checkout in `usage.unresolvedCheckoutId`. `QUOTE_ALREADY_USED` means the quote was already charged to another mandate, and `QUOTE_MANDATE_CHARGE_UNSUPPORTED` means the quote cannot be charged to a mandate. Create a new quote after either of those, or after `QUOTE_REPLACEMENT_REQUIRED`. The [create checkout reference](https://docs.reap.global/api-reference/agentic/create-checkout.md) lists every code under its status.

## Control the schedule

A mandate stays under your control between cycles.

* [`POST /agentic/mandates/:id/pause`](https://docs.reap.global/api-reference/agentic/pause-mandate) stops charges and keeps the approved terms
* [`POST /agentic/mandates/:id/resume`](https://docs.reap.global/api-reference/agentic/resume-mandate) continues a paused mandate under the same terms
* [`POST /agentic/mandates/:id/cancel`](https://docs.reap.global/api-reference/agentic/cancel-mandate) ends the mandate

Resuming needs no further approval from the user, because the terms have not changed. [Lifecycle and Statuses](https://docs.reap.global/agentic-payments/lifecycle.md) covers each operation with a request and a response.

> [!WARNING]
>
> Revoking an enrollment stops charges across every mandate that points at the same stored card. Pause or cancel the mandate instead when the card should stay usable.

## Next steps

> [card] [Lifecycle and Statuses](https://docs.reap.global/agentic-payments/lifecycle.md)
>
> Pause, resume, cancel, and every status value.

> [card] [FAQ](https://docs.reap.global/agentic-payments/faq.md)
>
> Short answers to common integration questions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.