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

# Pay by hosted invoice

> The default flow: create an experiment, confirm the quote, and pay the Stripe-hosted invoice in a browser.

# Pay by hosted invoice

This is how most orders are paid. You create an experiment, Adaptyv prices it
into a quote, you confirm the quote, and Stripe issues a hosted invoice page for
whoever pays your bills. No payment header, no wallet.

You need a token whose role grants `Quote:Update` — **Member**, **Billing**, or
**Admin**.

```mermaid theme={null}
sequenceDiagram
    autonumber
    participant You
    participant API
    participant Stripe
    participant Payer as Whoever pays your bills

    You->>API: POST /experiments (no X-Adaptyv-Payment-Method)
    API-->>You: experiment id
    Note over API: Adaptyv prices the work
    You->>API: POST /quotes/{quote_id}/confirm
    API-->>You: invoice_id + payment.hosted_invoice_url
    You->>Payer: send hosted_invoice_url
    Payer->>Stripe: pay on the hosted page
    Stripe->>API: notify that the invoice is paid
    You->>API: GET /invoices/{invoice_id}
    API-->>You: 200 — paid
```

## Create the experiment

Send no `X-Adaptyv-Payment-Method` header. Its absence selects this rail for an
ordinary token and pins the experiment to it. If you hold a token issued with a
machine payment policy, send `X-Adaptyv-Payment-Method: async_invoice`
explicitly to get the hosted invoice.

```bash theme={null}
curl -X POST "$FOUNDRY_API_URL/experiments" \
  -H "Authorization: Bearer $FOUNDRY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d @experiment.json
```

## Read the quote

```bash theme={null}
curl "$FOUNDRY_API_URL/quotes/$QUOTE_ID" \
  -H "Authorization: Bearer $FOUNDRY_API_TOKEN"

curl -L "$FOUNDRY_API_URL/experiments/$EXPERIMENT_ID/quote/pdf" \
  -H "Authorization: Bearer $FOUNDRY_API_TOKEN" -o quote.pdf
```

## Confirm the quote

Confirming finalizes the invoice. You may attach a purchase-order number, which
appears on it.

```bash theme={null}
curl -X POST "$FOUNDRY_API_URL/quotes/$QUOTE_ID/confirm" \
  -H "Authorization: Bearer $FOUNDRY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"purchase_order_number": "PO-2026-00142"}'
```

```json theme={null}
{
  "id": "qt_1OqLk2...",
  "status": "accepted",
  "invoice_id": "in_1OqLk2LkdIwHu7ix6OboRpXl",
  "payment": {
    "kind": "hosted_invoice",
    "hosted_invoice_url": "https://invoice.stripe.com/i/acct_1234/test_5678"
  }
}
```

Send `hosted_invoice_url` to whoever pays your bills. They can view the invoice,
pay it with any method you have enabled, and download the PDF and receipt — see
Stripe's [hosted invoice page](https://docs.stripe.com/invoicing/hosted-invoice-page).

<Warning>
  Confirming is one-way. A second confirm on the same quote returns `409`. To
  decline, call `POST /quotes/{quote_id}/reject` first.
</Warning>

## Check that it settled

Payment happens on Stripe's page, outside the API: there is no credential to
submit and no endpoint that completes it. Stripe notifies the API when the money
clears, and the invoice flips from `open` to `paid`.

```bash theme={null}
curl "$FOUNDRY_API_URL/invoices/$INVOICE_ID" \
  -H "Authorization: Bearer $FOUNDRY_API_TOKEN"

curl -L "$FOUNDRY_API_URL/invoices/$INVOICE_ID/pdf" \
  -H "Authorization: Bearer $FOUNDRY_API_TOKEN" -o invoice.pdf
```

To remove the browser step, have an agent settle the invoice with
[x402](/api-reference/payments/pay-x402-exact) or
[MPP-SPT](/api-reference/payments/pay-mpp-spt) instead. Both are selected at
experiment creation.
