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

# Pay for a resource

> Pay MPP and x402 endpoints from your InFlow balance, get the response, and manage MPP subscriptions.

Pay an MPP or x402 endpoint with the InFlow CLI, and get the response. The `402` response of the endpoint lists the accepted protocols and options. For the payment flow and owner approval, see [Payments](/concepts/payments). To pay from your own application, see [Pay from code](/agents/pay-from-code).

## How the agent pays

By default, the agent pays from its [InFlow balance](/concepts/payments#the-inflow-balance). It can also pay in other ways when the seller offers them.

| Way to pay | MPP | x402 |
| - | - | - |
| InFlow balance | The `balance` rail of the `inflow` payment method | The `balance` scheme |
| Onchain | The `tempo` payment method | The `exact` scheme |
| Linked card | The `instrument` rail of `inflow`, or a `card` charge | The `instrument` scheme |

For x402, the CLI prefers `balance`, then `exact`, then `instrument`. For MPP, the seller challenge sets the rail. A card payment does not use your InFlow balance. See [Rails and schemes](/concepts/payments#rails-and-schemes).

## Check before you pay

Do these checks before the first payment to a new endpoint.

<Steps>
  <Step title="Read the endpoint">
    `inspect` reports the ODP, AEP, MPP, and x402 capabilities of a URL. It does not enroll and it does not pay.

    ```bash theme={null}
    inflow inspect https://api.example.com/paid-resource
    ```

    For the full payment options of one protocol, use the protocol command. It sends a request to the endpoint, but it does not pay.

    <CodeGroup>
      ```bash MPP theme={null}
      inflow mpp inspect https://api.example.com/paid-resource
      ```

      ```bash x402 theme={null}
      inflow x402 inspect https://api.example.com/paid-resource
      ```
    </CodeGroup>
  </Step>

  <Step title="Check what you can pay with">
    <CodeGroup>
      ```bash MPP theme={null}
      inflow mpp supported
      ```

      ```bash x402 theme={null}
      inflow x402 supported
      ```
    </CodeGroup>

    `mpp supported` lists your payment methods by intent, settlement rail, and currency. `x402 supported` lists your buyer capabilities by scheme and network.
  </Step>

  <Step title="Check your balance">
    ```bash theme={null}
    inflow balances list
    inflow deposit-addresses list
    ```

    `deposit-addresses list` shows where to send stablecoins. Always copy a deposit address in full. A shortened address does not work.
  </Step>
</Steps>

## Pay in one command

One command probes the endpoint, prepares the payment, and waits for approval. Then it sends the credential to the seller and returns the response body.

<CodeGroup>
  ```bash MPP theme={null}
  inflow mpp pay https://api.example.com/paid-resource --interval 5 --max-attempts 180
  ```

  ```bash x402 theme={null}
  inflow x402 pay https://api.example.com/paid-resource --interval 5 --max-attempts 180
  ```
</CodeGroup>

The result contains `outcome`, `transaction_id`, `response_status`, `settled`, and the seller's response body.

With `--format json` or `--format toon`, the agent sees only the final result. To show the `approval_url` to the owner earlier, stream the frames with `--format jsonl`.

```bash theme={null}
inflow mpp pay https://api.example.com/paid-resource --interval 5 --max-attempts 180 --format jsonl
```

The default `--timeout` is 900 seconds, the same as the approval expiry on the server.

## Pay in two steps

Use this path when your agent host cannot block on one long command.

<Steps>
  <Step title="Start the payment">
    Run `pay` without `--interval`.

    ```bash theme={null}
    inflow mpp pay https://api.example.com/paid-resource
    ```

    The result contains `transaction_id`, `approval_id`, `approval_url`, and a `_next` object.
  </Step>

  <Step title="Show the approval URL">
    Give the `approval_url` to the owner at once. Save the `transaction_id` at once. You need it to resume.
  </Step>

  <Step title="Complete the payment">
    Run the command in `_next.command` at once, with `inflow` before it. Do not wait for the owner to reply first.

    ```bash theme={null}
    inflow mpp fetch <transaction_id> https://api.example.com/paid-resource --interval 5 --max-attempts 180
    ```

    `fetch` polls until the owner approves. Then it sends the credential to the seller and returns the body.
  </Step>
</Steps>

For x402, replace `mpp` with `x402` in each command.

## Resume an interrupted payment

Run `fetch` with the saved `transaction_id`. Do not start a new payment for the same request.

<CodeGroup>
  ```bash MPP theme={null}
  inflow mpp fetch <transaction_id> https://api.example.com/paid-resource --interval 5 --max-attempts 180
  ```

  ```bash x402 theme={null}
  inflow x402 fetch <transaction_id> https://api.example.com/paid-resource --interval 5 --max-attempts 180
  ```
</CodeGroup>

## Check or cancel a payment

| Command | What it does |
| - | - |
| `inflow mpp status <transactionId>` | Shows the buyer state of an MPP transaction. |
| `inflow x402 status <transactionId>` | Shows the signing state of an x402 transaction. |
| `inflow mpp cancel <approvalId>` | Tries to cancel an MPP approval. |
| `inflow x402 cancel <approvalId>` | Tries to cancel an x402 approval. |

A cancel is a best-effort request.

## Send a body or headers

The seller request uses `GET` by default. Use `--method`, `--data`, and `--header` for other requests.

```bash theme={null}
inflow mpp pay https://api.example.com/upload --method POST --data '{"name":"report"}' --header "X-Request-Id: 42" --interval 5
```

With `--data`, the content type is `application/json`. A `--header` value can change it. `--header` repeats.

## Select one payment option

These flags limit the seller options that the CLI considers.

| Protocol | Flag | Example |
| - | - | - |
| MPP | `--payment-method` | `inflow` |
| MPP | `--intent` | `charge` |
| MPP | `--currency` | `USDC` |
| MPP | `--rail` | `balance` or `instrument` |
| x402 | `--scheme` | `balance`, `exact`, or `instrument` |
| x402 | `--network` | `eip155:84532` |
| x402 | `--asset` | An ERC-20 address or an SVM mint |
| x402 | `--asset-name` | `USDC` |

To pay with a specific linked card, use `--instrument-id` with MPP or x402. Without it, the CLI uses your primary card. If the `outcome` is `verification-required`, give the `verification_url` to the owner. Do not start a new payment.

For x402, `--payment-id` sends your own payment identifier. It must have 16 to 128 characters from `a-z`, `A-Z`, `0-9`, `_`, and `-`.

## Keep content and secrets out of chat

| Flag | What it does |
| - | - |
| `--output-file` | Writes the response body to a file. Use it for PDFs, images, and other binary content. |
| `--no-show-body` | Removes the response body from the result. |
| `--credential-file` (MPP) | Writes the `Authorization: Payment` credential to a file with mode `0600`. |
| `--payload-file` (x402) | Writes the signed payload to a file with mode `0600`. |

## Subscribe to an MPP resource

Recurring offers are MPP challenges with the intent `subscription`.

<Steps>
  <Step title="Find the option">
    ```bash theme={null}
    inflow mpp inspect https://api.example.com/pro
    ```

    Copy the option ID of the subscription offer.
  </Step>

  <Step title="Subscribe">
    ```bash theme={null}
    inflow mpp subscribe https://api.example.com/pro --option-id <option_id> --interval 5
    ```

    The owner reviews and approves the recurring terms. InFlow then settles the first period.
  </Step>

  <Step title="Use the subscription">
    ```bash theme={null}
    inflow subscriptions fetch <subscription_id> https://api.example.com/pro
    ```
  </Step>
</Steps>

| Command | What it does |
| - | - |
| `inflow subscriptions list` | Lists your subscriptions. `--status` filters by `active`, `cancelled`, `expired`, `failed`, `past_due`, `pending`, or `revoked`. |
| `inflow subscriptions get <subscriptionId>` | Shows the details of one subscription. |
| `inflow subscriptions cancel <subscriptionId>` | Cancels the subscription at once. |

<Warning>
  An agent must get explicit approval from the owner before it cancels a subscription.
</Warning>

## Decode a header

`decode` reads a raw payment header.

```bash theme={null}
inflow mpp decode "<WWW-Authenticate value, credential, or receipt>"
inflow x402 decode "<PAYMENT-REQUIRED value>"
```

## Rules for agents

* Never print OAuth tokens or API keys.
* Use `fetch` to complete an approved payment. `fetch` attaches the credential to the seller request, so the credential stays out of chat.
* On the fast path, the credential in the result is for reference only. Do not send it again.
* Save the `transaction_id` as soon as you get it.

## Troubleshooting

<AccordionGroup>
  <Accordion title="The payment never settles">
    The owner did not approve it. Approval expires after 900 seconds. Check the state with `inflow mpp status` or `inflow x402 status`.
  </Accordion>

  <Accordion title="The command finds no matching option">
    Your filters exclude every option from the seller. Remove `--currency`, `--rail`, `--scheme`, `--network`, or `--asset-name`. Then run `inflow inspect` again.
  </Accordion>

  <Accordion title="The balance is too low">
    Run `inflow deposit-addresses list`. Send stablecoins to the full address. Then run `inflow balances list` again.
  </Accordion>
</AccordionGroup>


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