---
name: servicerouter-seller
description: List an API on Service Router and get paid per call by agents. Use when the user wants to sell access to their API, write or submit a Service Router config, rotate upstream secrets, roll back a revision, or check earnings.
---

# Service Router for sellers

Service Router sells per-call access to an HTTP API. Agents call `https://pay-servicerouter.agents.bakingbad.dev/service/<service-id>/<path>` and pay with credits, x402, or MPP. The platform forwards each paid call to the upstream with the seller's credentials, which agents never see, and pays the seller.

Show the user the config before you submit it. Never print secret values.

## 1. Sign up once

```sh
curl -s -X POST https://api-servicerouter.agents.bakingbad.dev/v1/accounts > servicerouter-account.json
chmod 600 servicerouter-account.json
```

The `masterKey` controls the account and its earnings. Keep it in that file. A lost master key can't be recovered yet.

## 2. Write the config

One YAML file describes the service, its upstream, its prices, and its payout:

```yaml
servicerouter:
  version: "1"

service:
  id: my-prices              # [a-z0-9-], unique, in the URL forever
  title: My Prices
  summary: Live token prices by symbol
  description: |
    The latest price, 24-hour change, and volume for any token symbol.
  category: crypto/prices    # One ID of the catalog's categories: `GET https://api-servicerouter.agents.bakingbad.dev/v1/catalog` lists them
  tags: [prices, tokens]
  discoverable: true         # Listed in the x402 Bazaar. false keeps it out

payouts:
  default:
    asset: cardano-usdm      # Paid out in USDM on Cardano
    address: addr1...        # Your Cardano address

payments:
  default:
    amount: "0.001"          # USD per call

upstreams:
  - baseUrl: https://api.example.com
    openapi: https://api.example.com/openapi.json   # Or an inline `paths` object
    auth: main-key

credentials:
  main-key:
    type: http
    scheme: bearer           # Authorization: Bearer <secret>
    secret: upstream-key     # A name: the value is sent separately
```

- Each operation of the OpenAPI document becomes a route at the same path. `routes.<operationId>` sets a route's own `payment`, a `target` path, or `enabled: false`.
- An amount of `"0"` makes a route free.
- `service.discoverable` (default `true`) lists each paid route in the x402 Bazaar, Coinbase's catalog of x402 APIs, once a payment for it settles through Coinbase's facilitator: its 402 carries the route's description, input and output schemas, and response example from your OpenAPI document. `discoverable: false` keeps the service out of it. Changing it makes a new revision, like any change.

## 3. Submit it with its secrets

```sh
MASTER_KEY=$(jq -r .masterKey servicerouter-account.json)
jq -n --rawfile config service.yaml --arg key "$UPSTREAM_KEY" \
  '{config: $config, secrets: {"upstream-key": $key}}' |
curl -s -X PUT https://api-servicerouter.agents.bakingbad.dev/v1/services/my-prices \
  -H "Authorization: Bearer $MASTER_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @-
```

- `201` creates the service, `200` updates it, and each change is a new revision.
- `400 invalid_config` lists every problem with its path, line, and column. Fix them and submit again.
- Secrets are sealed and bound to the host they go to. A config with no new secrets can be sent as YAML, with `Content-Type: application/yaml`.

## 4. Check and manage it

- `GET https://api-servicerouter.agents.bakingbad.dev/v1/services`: your services. `GET https://api-servicerouter.agents.bakingbad.dev/v1/services/my-prices`: one service.
- `GET …/revisions` lists revisions. `POST …/rollback` with `{"revision": 3}` makes an older one active.
- `PUT …/secrets/<name>` with `{"value": "…"}` rotates one secret.
- `GET …/earnings`: calls, earnings by payment method, the fee, pending payout, and the next payout date.
- Its public page: `https://servicerouter.agents.bakingbad.dev/discover/my-prices`.

## 5. Prove you own the upstream

Before a service goes live, each upstream host serves `/.well-known/servicerouter.json` with the service's token. `GET https://api-servicerouter.agents.bakingbad.dev/v1/services/<id>/status` shows what's missing. A change of payout address waits until every host lists its confirmation token. This check is arriving: follow the status endpoint's answer.

## 6. Get paid

Earnings are paid out monthly, on the 1st, in USDM on Cardano to the payout address, once they reach the minimum. Agents find the service in the catalog, in its generated `llms.txt`, Agent Skill, and OpenAPI document, and in the x402 Bazaar unless `discoverable` is `false`.
