# Selling your API

You already run an HTTP API and want buyers, which are programs buying on a
person's behalf, to pay for each call without writing code against the SDK or
running a separate process. Start on Products or Integrations in your dashboard,
choose **Your API**, enter your API's address and a key, and set a price for
each route you want to sell. Agentify gives every priced route an address of
its own: a buyer pays there, and Agentify calls your API with your key and
passes the answer back.

This works on the test channel, where buyers pay in test USDC on Base Sepolia,
and on the live channel, where buyers pay in real USDC on Base. Each channel
has its own dashboard and account, so you connect your API separately on each
one. On the live channel, publication waits until an Agentify operator has
approved your account. Before asking for live sales, send at least one test
request from Your API that your API answers with a response a buyer could
receive, then enter your seller name and press **Ask for live sales** on
Products. A wallet is not needed to ask. Once your account is approved and has
a payout wallet, the endpoints you saved go on sale automatically.

## What you need to connect

The **Connect your API** form asks for four things:

| Field | What you enter |
| --- | --- |
| **Seller site** | The website buyers see beside every price. Your API's base address and any OpenAPI description address must be on this site or on a subdomain of it. Saving the site here updates Settings too, and while your API is connected, Settings refuses a change to a site that does not cover those addresses. |
| **API URL** | An `https://` base address on your seller site or a subdomain of it, optionally ending in a path such as `/v1`. Agentify calls public addresses only and follows no redirects. |
| **Auth method** and **API key** | How Agentify sends your key on every call: `Authorization: Bearer <key>`, `Authorization: Token <key>`, `X-API-Key: <key>`, or a header you name. Agentify stores the key encrypted, never displays it again and never writes it to logs. |
| **OpenAPI spec URL** (optional) | The address of your API's OpenAPI 3 JSON description (not Swagger 2.0 or YAML), on your seller site or under it, up to 8 MB. Agentify reads it without your key and lists up to its first 500 routes for you to open and price. You can also add routes by hand without one. |

Make a dedicated API key for Agentify alone. Every buyer's paid call goes out
with that one key, so anyone who pays for a route can reach whatever that key
can reach. Leave private account data, admin paths and unrelated permissions
off the key.

One account holds one API connection at a time. To sell an API at a different
base address, disconnect the current one first and connect again.

## Adding and pricing endpoints

Each endpoint you sell is a `GET` or `POST` method and a path starting with `/`
under your API URL. Other HTTP methods are not accepted. Paid endpoints take
exact paths (no path templates such as `/users/{id}`, which are allowed only on
a free result-read route). You can open a route from your OpenAPI description
or enter the method and path by hand on **Add an endpoint**.

Each paid endpoint has a fixed price per call in US dollars of at least
`0.01` with at most two decimal places, plus a name and
description. Buyers read the name and description before paying, and pay the
same number of USDC into your payout contract. There is no currency conversion
for an API connection ([What they pay in](https://agentify.ad/docs/money#what-they-pay-in)).

You can change an endpoint's price, name or description at any time on its
page. New prices named to buyers use the saved values right away, and a buyer
holding an older price is asked for a new one with nothing charged. Method and
path identify the address buyers call and cannot be changed; to sell another
path, add it as a new endpoint.

Once an endpoint is on sale, any buyer who pays can send their own query string
(up to 4,096 characters, plain ASCII without spaces, `#`, `"`, `<`, `>` or
control characters, with non-ASCII characters percent-encoded) and, on a
`POST`, a JSON body of up to 256 KB nested at most 63 levels deep.

### Testing before selling

Both **Add an endpoint** and each endpoint's page have a **Send a test
request** button with an optional example query (up to 4,096 characters) and,
for `POST`, an optional example JSON body (up to 12,000 characters). A test
request calls your API once with your saved key, uses your own quota and does
not save the example. It reports the HTTP status, response time, response size
and whether a result identifier was found, and never prints the response body.

## When the buyer is charged and what counts as delivered

Buyers are charged before Agentify calls your API. For each paid call,
Agentify calls your API once within a minute of the buyer's paid
request, and never a second time for the same payment. If the buyer's
connection drops and the buyer retries with the same signed payment, Agentify
returns the saved answer instead of calling your API again.

What your API returns decides whether the call is delivered:

| What your API returns | Outcome | What happens |
| --- | --- | --- |
| `2xx` with a JSON or empty body | delivered | buyer receives your status and body, and a receipt is written |
| `4xx` other than `401`, `402`, `403` and `429` | delivered | buyer's own request error is passed on and counts as delivered; non-JSON `4xx` bodies are omitted while the status is kept |
| `401`, `402`, `403`, `429`, `5xx`, redirects (`3xx`), non-JSON `2xx`, body over 1 MB, JSON nested past 63 levels, an answer that repeats your API key, or no answer within a minute | paid and not delivered | buyer receives HTTP 409 with the order record, no receipt is written, and any refund is yours to arrange outside Agentify |

Keep your own account behind the API key funded. If your API answers an
out-of-credits request with `402`, `403` or `429`, Agentify records the call as
not delivered. If your API answers with `200` and an error message inside the
JSON body, Agentify treats that `200` as delivered and the buyer pays for it.

Agentify never passes on an answer that contains your API key. Every response
to a buyer carries a header saying whether your API or Agentify wrote the body.

Agentify deletes the buyer's request and your API's answer once the request is
a day old, at its next daily cleanup or next start. The order record
and any receipt stay, and the order notes that the copy of the answer was
deleted. A paid call that ended not delivered cannot be delivered late: you can
close fulfillment on Orders with an explanation for the buyer and arrange any
refund outside Agentify
([If the buyer did not get the goods](https://agentify.ad/docs/money#if-the-buyer-did-not-get-the-goods)).

## When your API fails or gets busy

Agentify enforces two limits before any charge so buyers do not pay into an API
that is overloaded or down.

First, Agentify runs at most four paid calls at the same time across your API
connection. While all four places are busy, extra calls are refused before any
charge with a wait time, so calls do not queue past a minute.

Second, if your API fails three paid calls in a row on one
endpoint (with its own error, an unusable answer or no answer within
a minute), Agentify refuses new calls to that endpoint before any charge
for five minutes starting a minute after the last failed call. After
that wait, one paid call is let through. If your API delivers it, normal
selling resumes; if it fails, that buyer has paid for an undelivered call and a
new five-minute wait begins a minute after that call. Editing the price
or description does not clear the rest; if your API is still broken, take the
endpoint off sale.

Failed calls to a connected API never count towards the ten
unserved orders that stop SDK and shop sellers
([Every failure, mode by mode](https://agentify.ad/docs/failures#every-failure-mode-by-mode)). If your
account already has ten unserved orders from the SDK or a shop
waiting, calls to your API are still refused until you deliver or close those
orders.

The Your API overview and each endpoint page show calls paid and calls not
delivered over the last 24 hours; each endpoint page also links to its calls on
Orders.

## APIs that return a result on a second request

Some APIs answer a paid request immediately with a job identifier and return
the finished result a few seconds later on a second request. You can sell these
APIs with a paid start route and a free read route:

1. Open **Connection and key → Results read later**.
2. Enter the JSON field in the paid call's answer that holds the identifier,
   with keys joined by dots (for example `item._id`).
3. Choose where the second request carries that identifier: a `{name}` segment
   in the path, a query parameter, or a field in the JSON body (on a `POST`
   route), and enter its name. Save the setting.
4. Add the read route on **Add an endpoint** and set its price to `free`.

Each paid endpoint in the catalogue then names that read address, where the
identifier appears in the answer and where the read request carries it. The
wallet that paid for the original call signs a zero-cost payment proof and can
read the result free up to sixty times within a day of the
paid call, without creating a new order. Agentify checks that the identifier
came from a delivered call that the same wallet paid for, and refuses any other
read before calling your API.

In a path segment or a query parameter, Agentify accepts identifiers made of
letters, digits and `-`, `_`, `.`, `~`, `:` only. If your API returns
identifiers with other characters, pass the identifier in a JSON body instead.

The identifier is the only part of a read request that Agentify checks; the
rest of the request reaches your API as the buyer sent it. Make sure your read
route uses that identifier and cannot be told through other fields to list
another account's records.

Saving a change to **Results read later**, clearing it, giving the free
endpoint a paid price, making another endpoint free, or disconnecting your API
ends free reads for calls paid before that change.

## Managing your connection

### Replacing the key

Open **Connection and key → Replace the key** to save a new key or auth method
without disconnecting. Every call begun afterwards uses the new key. Calls
already under way finish with the old key within a minute, so wait until
that window passes before revoking the old key, then send a test request.

### Selling through one integration at a time

You sell through one way at a time: your code through the SDK, a WooCommerce
shop, a Lovable site, or Your API. Connecting Your API while selling another
way stops that other way once the connection succeeds. While an order on the
other integration is still open, connecting Your API or pressing **Sell through
your API again** is refused with nothing changed, naming those orders; press
again once they have finished. Switching away leaves your API connected with
its endpoints off sale. Pressing **Sell through your API again** restores each
endpoint's pause state and any whole-account pause as you left it.

### Taking an endpoint off sale and removing it

On any paid endpoint's page, pressing **Take off sale** refuses new calls right
away and lets you put the endpoint back later. Once a paid endpoint is off sale
and has no call under way, you can choose **Remove endpoint**. Its orders and
receipts stay, buyers who already paid keep their answer for a day, and
you can later add the same method and path as a new endpoint. The free result
read route has no sale of its own and is managed under **Connection and key →
Results read later**.

### Disconnecting

On **Connection and key → Disconnect**, all endpoints leave sale immediately
and **Results read later** is forgotten (so unread results from earlier paid
calls can no longer be read through Agentify). Once calls already paid for have
their answers, your account switches back to selling through your code and
Agentify deletes your key. Your endpoints and prices stay saved off sale in
case you connect again; when you reconnect, open and check each endpoint before
putting it back on sale, because its path now points at the new API URL.

## What is not settled yet

- Whether the facilitator accepts a payment of `0.01` USDC on the
  live network. That floor has been tried on the test channel only
  ([The product card](https://agentify.ad/docs/cards#what-is-not-settled-yet)).
- Machine-readable request schemas in the catalogue. Today the catalogue lists
  the method, address, name and description you entered, not the full OpenAPI
  schema of each route's parameters or request body.
- Read counts and used read signatures for free result reads live in Agentify's
  memory and reset if Agentify restarts.
- Reconciling payouts against paid calls
  ([Money](https://agentify.ad/docs/money#what-is-not-settled-yet)).
