Open app

List a service

Put a paid API in the directory and take payment per call from any Ayo agent.

A listed service is an on-chain record of your endpoint and its terms, plus middleware in front of your API that holds agents to them. Agents find the service at /app/services, call it, and pay by the call over a tab. Payments settle into your private wallet.

You need a private wallet (see Fund an agent) and an HTTP server on Hono or Express.

Choose the terms

FieldWhat to put
NameWhat agents see in the directory, up to 80 characters
EndpointThe URL that answers the hello. Agents pay for calls to this URL and any path under it
Price per unitIn USDC, such as 0.002
UnitWhat one charge is: call, query, page
Settlement window1, 6 or 24 hours. A tab not settled in this time can be flagged unpaid
Max unpaid per tabThe most you serve on one tab before it settles, in USDC. At least the price

The agent's SDK settles before the window ends and before a call would pass the maximum, so these two numbers bound how long and how much you serve on credit.

List it

  1. List a service

    Go to /app/services/new, fill in the terms and press List service. Approve the transaction. Your browser derives the service's own keys from your private wallet and the service's index: a signing key, which signs confirm_tab and flag_unpaid and gets a little SOL for their fees, and a Ring address, where settlements arrive. Because the keys come from yours, your browser can always read what the service has received.

  2. Copy the middleware

    The done screen shows AYO_SERVICE_ID and AYO_SERVICE_KEY in one block, next to the middleware line for your price and unit. Copy them into your server's environment; the key is shown once. Open the service shows the service's page.

Add the middleware

server.ts
import { Hono } from 'hono'
import { serve } from '@ayo/sdk/hono'

const app = new Hono()
app.use('/v1/*', serve({ price: '0.002', unit: 'query' }))
app.get('/v1/search', (c) => c.json({ results: [] }))

Mount it on the paths under your registered endpoint, with the price and unit you listed; the middleware checks them against the listing.

The middleware reads the service's address from AYO_SERVICE_ID and its key from AYO_SERVICE_KEY, plus the cluster settings in the SDK environment.

What the middleware does

  • A request without a voucher gets 402 with Ayo-Hello and Ayo-Settlement-Window. The agent opens a tab and repeats the request.
  • A request with a voucher reaches your handler only if the voucher checks out: signature, tab, agent status, sequence, exact price, maximum unpaid. The response carries Ayo-Accepted.
  • When the next call would pass the maximum, or settleAt is reached, the response also carries Ayo-Settle: now.
  • When the agent has settled, it sends HEAD with Ayo-Settle: confirm. The middleware decrypts the transfer, checks the amount against the last voucher, sends confirm_tab and answers 204.

Each accepted call is also posted to the API as a record encrypted to your viewing key, so your service's page shows open tabs with their running totals and the settlements you've received.

Keep vouchers

The middleware journals the last voucher of each tab to files under .ayo/ in the working directory, so a restart keeps every tab it was serving. Point storeDir at a folder that survives deploys, or pass your own store with an atomic compareAndSet. See VoucherStore. The journal is your evidence if a tab goes unpaid.

Change the listing

While any of your tabs is outstanding, you can change the name and endpoint but not the billing terms. The program refuses with OutstandingTabs. Once every tab has settled, been flagged or been voided, any term can change. A tab an agent opened and never paid on can be closed with void(tabId) once its window passes.