---
title: "Agent notes: prepaid requests without an AudD account"
description: "Notes for AI agents that have no AudD account: register with one request, buy prepaid requests with a machine payment or a checkout link your user pays, recognize at api.audd.io/agent/recognize, and know what is charged."
slug: "/resources/agents/pay-per-request"
section: "agents"
keywords: [audd, agent, prepaid requests, pay per request, http 402, mpp, checkout link, agent key, auth.md, agent recognize]
---

# Agent notes: prepaid requests without an AudD account

We wanted to make it as simple as possible: you register with one request, buy prepaid requests, and send us the audio with your own key. You'll be able to use our API without an AudD account or an email. Use this guide if you're an agent that needs to recognize a song and you can pay, or ask your user to pay. You can find the full reference at [audd.io/auth.md](https://audd.io/auth.md), and the live price and limits in the [service document](https://dashboard-api.audd.io/agent/).

```bash
# 1. Register. It's free, and the balance starts at 0.
#    The answer holds the key, which is shown once: keep the file private.
umask 077
curl -s https://dashboard-api.audd.io/agent/identity \
  -H 'Content-Type: application/json' \
  -d '{"type": "anonymous"}' -o audd-agent.json
export AUDD_AGENT_KEY=$(python3 -c 'import json; print(json.load(open("audd-agent.json"))["audd"]["api_key"])')

# 2. Get a checkout link (1 pack = 1,000 requests), and show your user
#    the user_message from the answer.
curl -s https://dashboard-api.audd.io/agent/checkout \
  -H "Authorization: Bearer $AUDD_AGENT_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"packs": 1}'

# 3. Once the purchase is fulfilled, recognize.
curl -s https://api.audd.io/agent/recognize \
  -H "Authorization: Bearer $AUDD_AGENT_KEY" \
  -F url='https://audd.tech/example.mp3'
```

## 1. Use your user's AudD token if there is one

Check whether the user already has an AudD token first, for example in the `AUDD_API_TOKEN` environment variable. If the user has an AudD account, send the `api_token` from the Dashboard in all the requests to `https://api.audd.io/`, or connect our [MCP server](/resources/agents/mcp) at mcp.audd.io. Please don't ask users to paste their API tokens into the chat.

Prepaid requests are for standard recognition only. Agent keys don't work on our account endpoints: `https://api.audd.io/`, the enterprise endpoint, streams and the MCP server. To scan long files or monitor streams, the user needs an AudD account.

## 2. A 401 from the recognition endpoint points here

If a request to the recognition endpoint has no key, you'll get a `401` with `WWW-Authenticate: Bearer` and `Link: <https://audd.io/auth.md>; rel="help"`. Its body names the registration and purchase endpoints. So just register, buy prepaid requests, and send the same request again with your key.

## 3. Register once, and keep the key

```http
POST https://dashboard-api.audd.io/agent/identity
Content-Type: application/json

{"type": "anonymous", "client_name": "my-agent"}
```

The answer contains the key (`audd.api_key`, `agt_...`), a refresh token (`refresh_token`, `audd_art_...`) and the `registration_id`. We send you the key only once, so please store the key and the refresh token as secrets. The answer also contains an `identity_assertion`, but token exchange isn't offered yet: use `audd.api_key` as your credential.

You can also send `client_name` and `agent_platform` (each at most 40 printable characters) and `contact_email`. We store the email unverified and use it only for receipts and notices.

Registration is free, but there are no free requests: the balance starts at 0, so you'll need to buy requests before the first recognition.

## 4. Ask your user before you buy

Buying spends real money. Please pay only with a payment method, and up to an amount, that your user has authorized.

You can purchase from 1 to 100 packs at a time. One pack is 1,000 requests for $5.00 (`purchase.price` in the service document: `"amount": "500"` in cents, `"currency": "usd"`). Each purchase is paid once: there's no subscription, and nothing renews. The credits expire 12 months after your last purchase.

There are two ways to pay for the requests: pay the 402 challenge yourself, or send your user a checkout link.

## 5. Pay a 402 challenge yourself

```http
POST https://dashboard-api.audd.io/agent/credits
Authorization: Bearer agt_...
Content-Type: application/json

{"packs": 1}
```

The answer is `402 Payment Required` with a `WWW-Authenticate: Payment` challenge: the Machine Payments Protocol (MPP), with the method `stripe` and the intent `charge`. The challenge states the exact amount.

Pay it with an MPP client that supports the `stripe` method, then send the same request again with the `Payment-Authorization` header the challenge names. Please keep your `Authorization: Bearer` header. The `200` answer will contain the new balance and a `Payment-Receipt`. If you repeat a request with the same `Payment-Authorization`, we'll never charge you twice.

You can also pay at the recognition endpoint. With a balance of 0, it answers `402` with a challenge for one pack: pay it and send the same recognition request again.

Each card or Link account can make up to 10 purchases a day. The daily amount is capped at $1,000.00, and the limits reset at 00:00 UTC (`purchase.limits` in the service document). So please buy several packs in one purchase (`{"packs": N}`) rather than many single packs.

If a payment is refused, nothing is charged, and the answer says what to do next: use another payment method, buy fewer packs, or wait until the limit resets.

## 6. Or give your user a checkout link

In addition to the machine payment, you can ask for a checkout link and give it to your user, without having to pay the challenge yourself. Useful if your wallet can't pay it: Link's agent wallet works only for customers in the US and Canada. The page is a Stripe payment page: your user can pay by card or any other payment method Stripe offers in their country, without an AudD account. The price, the packs and the credit expiry are the same as for the machine payment.

```bash
curl -s https://dashboard-api.audd.io/agent/checkout \
  -H "Authorization: Bearer $AUDD_AGENT_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: 5f0c2d1e-checkout-1' \
  -d '{"packs": 1}'
```

The `201` answer contains:

- `checkout_url`: the Stripe payment page for your user
- `user_message`: a sentence you can pass on, with the amount, the seller and the link
- `purchase_id`: `pur_...`
- `expires_at`: when the link stops working, about 24 hours after it was made
- `status_url`: where to check the state of the purchase

We don't charge anything until your user pays. When the link is paid, we'll add the requests to your registration automatically, whoever paid it. Please send the recognition requests after the purchase becomes `fulfilled`: poll the `status_url` to see its `state`, or check `GET https://dashboard-api.audd.io/agent/balance`. A purchase can be in one of these states:

- `awaiting_payment`: the link is open
- `processing`: paid with a method the bank confirms later
- `fulfilled`: the requests are on your balance
- `expired`: the link wasn't paid in time
- `failed`: the purchase didn't complete

When you retry the request, send the same `Idempotency-Key` header: you'll get the same link back instead of a second one. If you send the same key with a different number of packs, the request is refused with `409`.

We've written a small Python program that does all of this: see the recipe [Build an assistant that pays for its own song recognition](/resources/recipes/assistant-with-prepaid-recognition).

### When nobody pays the link

If nobody pays the link, the link stops working after about 24 hours. You do not need to cancel it, and nothing is charged. If your user still wants to pay, ask for a new link with a new `Idempotency-Key`.

## 7. Recognize with the key in the `Authorization` header

```bash
curl -s https://api.audd.io/agent/recognize \
  -H "Authorization: Bearer $AUDD_AGENT_KEY" \
  -F url='https://audd.tech/example.mp3' \
  -F return='apple_music,spotify'
```

The parameters and the response are those of [AudD's standard endpoint](/resources/agents/standard-recognition): send a `url`, a multipart `file` or a base64 `audio`, plus the optional `return`. Only the first 12 seconds of the audio are analyzed. `status: "success"` with `result: null` means the audio was processed and no song matched. The audio file you upload, as a multipart `file` or base64 `audio`, may be up to 15 MB, and the whole request body up to 24 MB. A larger file gets AudD error 400, which is free.

Please note that all the agent API requests require the key to be sent in the `Authorization` header. A key in a URL or in an `api_token` field is refused. Replace that key, since it may be in logs.

## 8. A no-match uses a credit, most errors don't

Basically, we charge one credit for each answer, a match or a no-match. We also charge one credit for AudD error 300 (the audio couldn't be fingerprinted) and 19 (internal error). Every other error answer is free, including input errors: no file, a URL that could not be downloaded, unsupported or undecodable audio, or a file over 15 MB. Unknown errors (100), timeouts and crashes on our side are free too.

So a `result: null` costs the same as a match, and if you send the same clip again, it costs another credit. The exact wording is the "Charge rule" in [auth.md](https://audd.io/auth.md).

All the answers to requests with a valid key contain the `AudD-Credits-Remaining` header with your balance. Once a credit was reserved, they also contain `AudD-Credits-Charged` (`0` or `1`), and `AudD-Credits-Low: 1` when you're running low. Check `GET https://dashboard-api.audd.io/agent/balance` with your key before a long job.

## 9. Errors come as `application/problem+json`

If something goes wrong, the answer is `application/problem+json` with `audd.code` and `audd.charged` (`true`, `false`, or `null` while it's unknown). The `type` URI is `https://audd.io/auth.md#error-<code>`, and payment problems use `https://paymentauth.org/problems/<name>`. Please honor `Retry-After`. You can find the full table of codes in [auth.md](https://audd.io/auth.md).

With a balance of 0 or expired credits, you'll get a `402` with `no_prepaid_requests` or `credits_expired`. Pay the challenge and repeat the request, or buy packs; nothing was charged. If the key is unknown, revoked or expired, you'll get a `401` with `invalid_token`: mint a new key or register again.

On a `429` or a `503`, wait for `Retry-After`, then send the same request again. If it's `too_many_failed_inputs`, fix the input first. A `504` (`timeout` or `late_settle`) means that recognition didn't finish in time. It wasn't charged, so you can repeat the request.

> **Please don't pay twice.** If you get `retry_later` (`503`) with `audd.do_not_pay_again: true`, the payment may still complete. Send the same request again with the same `Payment-Authorization`, and don't pay again. The same goes for `purchase_pending` (`409`): another purchase is waiting for the bank, so poll `audd.purchase_url` or cancel it with `DELETE`.

If we couldn't recognize the audio (error 300, 400 and so on), the answer comes in the standard endpoint's format: `status: "error"` with an `error_code`. The [error codes reference](/resources/reference/errors) groups them by category.

## 10. Manage the registration with your key

- `GET https://dashboard-api.audd.io/agent/me`: the status, the balance and the credit expiry.
- `POST https://dashboard-api.audd.io/agent/keys` makes a new key (shown once), `GET` lists the keys, and `DELETE https://dashboard-api.audd.io/agent/keys?prefix=agt_xxxxxxxx` revokes one.
- `GET https://dashboard-api.audd.io/agent/usage?from=YYYY-MM-DD&to=YYYY-MM-DD`: your usage per day.
- `DELETE https://dashboard-api.audd.io/agent/me` revokes the registration and every key. With credits left, it answers `409 forfeit_required`; repeat it with `?forfeit=true` to confirm. Credits left on a revoked registration stay on record (questions: api@audd.io).

If you lose the key, send the refresh token:

```http
POST https://dashboard-api.audd.io/agent/identity
Content-Type: application/json

{"type": "refresh", "refresh_token": "audd_art_...", "new_api_key": true}
```

Every time you use the refresh token, you get a new refresh token, so store the new one right away. If an old refresh token is used again more than 60 seconds later, every credential of the registration is revoked.

You can verify the email if you want to (`POST https://dashboard-api.audd.io/agent/verify_email`). It only makes you reachable for receipts and notices; it doesn't change any limits or access.

---

**Related**

- [Recipe: an assistant that pays for its own song recognition](/resources/recipes/assistant-with-prepaid-recognition)
- [Agent notes: the standard recognition endpoint](/resources/agents/standard-recognition)
- [Agent notes: the AudD MCP servers](/resources/agents/mcp)
- [Music recognition for AI agents](/resources/articles/music-recognition-for-ai-agents)
- [AudD API pricing](/resources/articles/music-recognition-api-pricing)
- [auth.md: sign-up, payment and errors for agents](https://audd.io/auth.md)

## Sitemap

See the [resources sitemap](https://audd.io/resources/sitemap.md) for every guide and the [glossary](https://audd.io/resources/reference/glossary.md) for AudD terms.
