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

# Authorize and settle runs

> Man0 authentication, Compose spending sessions, x402 and metered fees.

A Man0 authentication token identifies the account. A Compose spending key authorizes its workflow payments. The app sends both: Man0 auth in `Authorization` and the Compose token in `x-compose-key`.

## Activate a spending session

Read `/api/near/balance` to get the deposit and spending addresses. After the user chooses an amount, POST its atomic-unit value to `/api/near/spending/approve`; this moves USDC into the spending wallet.

The app attaches that wallet through `ComposeSDK.wallets.attach`, then reads or creates the active key with `keys.getActive` and `keys.create`. A key carries its network, budget and expiry. `keys.use` attaches it to SDK operations, and `keys.revoke` ends its authorization.

For a Man0 run, send `x-compose-key`. The API also accepts a `compose-` spending token in `Authorization: Bearer`; `x-session-user-address` can identify the spending-wallet subject or the authenticated canonical account. The backend verifies it against those identities; `x-network-id` selects the settlement network.

## Compute and service fees

The Compose runtime meters model, connector, coordinator and specialist work. Man0 reconciles its receipts and calculates applicable creator/platform fees from the compute bill. See the [price rules](https://docs.man0.space/app/session.md#payment-and-prices).

USDC fields ending in `Wei` or `Atomic` use **six-decimal atomic units**: `1000000` is \$1. Percentage fees round upward to the next atomic unit. Each execution reports:

| Field | Amount |
| - | - |
| `composeBillWei` | Metered compute |
| `creatorFeeWei`, `platformFeeWei` | Applicable percentage fees |
| `serviceFeeWei` | Sum of creator and platform fees |
| `totalChargedWei` | Compute plus service fees |

## Settlement

For spending sessions, Man0 prepares the service-fee authorization through Compose, then settles the actual fee amount after reconciling compute receipts. Compute has its runtime receipts; service-fee settlement has its own payment intent and transaction identity.

The default service authorization is **500,000 atomic units (\$0.50)**. It is an authorization amount, while the final execution fields record the actual charges. A pause settles any billed work accumulated so far; a zero-spend preparation can be aborted.

## x402 clients

Published workflows also accept x402 v2 with the `upto` scheme. If authorization is needed, the API returns `402` and a base64 `PAYMENT-REQUIRED` header. Sign the accepted requirement and retry with `PAYMENT-SIGNATURE`.

The backend verifies the payment with the facilitator and settles the actual service fee after execution. Settlement headers can include `PAYMENT-RESPONSE` and `X-Transaction-Hash`; the final execution also carries the transaction hash and payment-intent identity.

Reclaim unused spending funds with `/api/near/spending/reclaim`. Omitting `amountWei` returns the available spending balance to the deposit wallet.


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