The API for businesses
Check that the agent emailing you is backed by a real person, by program. JSON over HTTPS under https://amail-api-production.up.railway.app/v1/supplier/, with your key as a bearer token.
The address in these examples, maya.shopping@amail.example, is made up. Here it answers not_active. Use the address an agent gave you.
Quick start
Five steps from nothing to a signed answer you can act on. The Node blocks, read in order, are one program: Amail's own tests run it as printed.
Register
One call with no key. The answer holds your key, shown once.
curl
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/register \ -H 'content-type: application/json' \ -d '{"name": "Larkfern Books", "domain": "larkfern.example", "email": "it@larkfern.example"}'
Node
// Node 18 or later, nothing to install. Save as quickstart.mjs. const base = 'https://amail-api-production.up.railway.app'; // Register once. The key is shown once: keep it with your secrets. const registered = await fetch(`${base}/v1/supplier/register`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ name: 'Larkfern Books', domain: 'larkfern.example', email: 'it@larkfern.example' }), }).then((answer) => answer.json()); const key = registered.key.secret; // Every other call carries the key. const call = (method, path, body) => fetch(`${base}${path}`, { method, headers: { authorization: `Bearer ${key}`, ...(body ? { 'content-type': 'application/json' } : {}) }, body: body ? JSON.stringify(body) : undefined, }).then((answer) => answer.json());
Prove your domain by DNS
Publish the TXT record you were given, then ask Amail to look. Until you do, you are an "unverified business": the agent is told nothing about you, and every code you open waits for its person to say yes.
curl
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/domain/dns \ -H 'authorization: Bearer amail_sk_...'
Node
// Publish this TXT record at your domain, then ask Amail to look for it. const { dns } = registered.supplier.domainProof; console.log(`${dns.type} ${dns.name} "${dns.value}"`); const proved = await call('POST', '/v1/supplier/domain/dns'); // dns_record_not_found until the record is seen; then domainVerified is true. console.log(proved.error?.code ?? proved.supplier.domainVerified);
Run a verification against your sandbox
This is a test deployment:
GET /v1/supplier/sandboxgives you an address of your own whose verifications confirm by themselves 5 seconds after you open them (more). With a real agent, open it on the address the agent gave you and give the agent thecode.curl
curl \ https://amail-api-production.up.railway.app/v1/supplier/sandbox \ -H 'authorization: Bearer amail_sk_...' curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/verifications \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"address": "sandbox-...", "sessionRef": "chat-4417"}'
Node
// This deployment has a sandbox: your own address, which confirms by itself. const { address } = await call('GET', '/v1/supplier/sandbox'); const opened = await call('POST', '/v1/supplier/verifications', { address, sessionRef: 'chat-4417' }); // With a real agent: give it opened.code in your own session, then wait. let verification = opened; while (verification.status === 'waiting_for_agent') { await new Promise((done) => setTimeout(done, 2000)); verification = await call('GET', `/v1/supplier/verifications/${opened.id}`); }
Read the receipt
Once
statusisconfirmed, check the signedreceiptwith readSigned: it is made out to you, for your session. A sandbox receipt is a test receipt: refuse it in production.What countsthe signed receipt, checked by you: not what an agent says, and not a copy someone hands you. It is for acting on now; for later, the answer that counts is always the issuer's, asked now.
curl
curl \ https://amail-api-production.up.railway.app/v1/supplier/verifications/kyv_... \ -H 'authorization: Bearer amail_sk_...'
Node
// readSigned is the block under "Verify anything Amail signed", saved beside it. import { readSigned } from './amail-verify.mjs'; if (verification.status !== 'confirmed') throw new Error(verification.status); const signed = await readSigned(verification.receipt, { typ: 'amail-test-receipt+jwt', test: true, // the sandbox's own type sub: address, aud: registered.supplier.id, sessionRef: 'chat-4417', }); // In production: typ 'amail-receipt+jwt' and no test, so a test receipt is refused.
Act only on the level you need
Each level is a fixed fact (what each means). Decide what each may do with you. Ask again before you rely on it later: a person can switch their agent off.
curl
curl 'https://amail-api-production.up.railway.app/v1/check?address=maya.shopping%40amail.example'
Node
// Act only on the level you need: here, a live connection to take an order. const { kya } = signed.receipt; if (kya.level >= 2) console.log('Take the order'); else console.log('Offer another way: pay as a guest, or sign in');
No account? The check page does the same by hand. In Python, the same checks are printed whole under Verify anything Amail signed and Your webhook.
Every route
| Route | What it does |
|---|---|
GET/v1/check | The public check of an address (no key) |
GET/.well-known/amail-check-keys | The keys that sign check answers, receipts and records (no key) |
POST/v1/supplier/register | Register a business and get its first key (no key) |
GET/v1/supplier/me | The business this key speaks for |
GET/v1/supplier/keys | The business's keys |
POST/v1/supplier/keys | Make another key |
POST/v1/supplier/keys/{id}/revoke | Revoke a key |
POST/v1/supplier/domain/dns | Look for the DNS record that proves the domain |
GET/v1/supplier/verifications | Your verifications, newest first |
POST/v1/supplier/verifications | Open a verification: a one-time code for the agent |
GET/v1/supplier/verifications/{id} | One verification |
POST/v1/supplier/messages/verify | Did Amail send this message? |
GET/v1/supplier/agreements | Your agreements, newest first |
POST/v1/supplier/agreements | Propose terms to an agent address |
GET/v1/supplier/agreements/{id} | One agreement |
POST/v1/supplier/agreements/{id}/accept | Accept the terms the agent came back with |
POST/v1/supplier/agreements/{id}/decline | Decline the terms the agent came back with |
POST/v1/supplier/agreements/{id}/end | End an agreement |
POST/v1/supplier/authorisations | Is this agent authorised for this offer? |
GET/v1/supplier/requests | Your requests for details, newest first |
POST/v1/supplier/requests | Ask an agent's person for details |
GET/v1/supplier/requests/{id} | One request |
POST/v1/supplier/requests/{id}/cancel | Take a request back |
GET/v1/supplier/events | What happened to what you started, after a cursor |
GET/v1/supplier/webhook | Your webhook |
PUT/v1/supplier/webhook | Set your webhook |
DELETE/v1/supplier/webhook | Remove your webhook |
GET/v1/supplier/sandbox | The sandbox of a test deployment (on this test deployment) |
The same, for a program: /openapi.json (OpenAPI 3.1). An index of these pages for a model: /llms.txt. What changed: Changelog, and /changelog.json.
Conventions
| How | |
|---|---|
| Your key | Authorization: Bearer amail_sk_... on every call but register, the public check and its keys. |
| An error | {"error": {"code", "message"}} with a status that fits; 400 invalid_request adds details: [{path, message}], one per field, never your value. Every code. |
| Retrying a POST | Send Idempotency-Key on POST /verifications, /requests, /agreements and /keys: the same key and body give the same answer, one-time code included, for 24 hours, with Idempotent-Replayed: true. Another body is 409 idempotency_key_reused. /authorisations changes nothing and needs none. |
| A list | GET /verifications, /requests, /agreements: newest first, ?limit=&cursor=, answering {"items": [...], "next": "..."}; next is null on the last page. Requests and agreements also keep their first names, requests and agreements, beside items. |
| Too many | 429 with Retry-After in seconds. Every limit. |
| Times | ISO 8601 in UTC; a day as YYYY-MM-DD. Amounts are strings with two decimals: "84.00". |
Register and your keys
POST/v1/supplier/register
Your business's name (2 to 80 characters), the domain it runs, and an email address we can reach you at. No key.
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/register \ -H 'content-type: application/json' \ -d '{"name": "Larkfern Books", "domain": "larkfern.example", "email": "it@larkfern.example"}'
{
"supplier": {
"id": "sup_5v30vw0kmks0gff8298zm1zqg3",
"name": "Larkfern Books",
"domain": "larkfern.example",
"domainVerified": false,
"domainVerifiedBy": null,
"domainVerifiedAt": null,
"domainCheckedAt": null,
"domainUnproved": null,
"domainRecordMissing": null,
"createdAt": "2026-10-10T12:00:00.000Z",
"domainProof": {
"dns": {
"type": "TXT",
"name": "_amail.larkfern.example",
"value": "amail-verify=k05fml2PdjNBb79PSUBJ2HXek0a1Kx7F"
}
}
},
"key": {
"id": "spk_k6csckx5xnvkq03g2egtkh6rm7",
"secret": "amail_sk_mKp650voMb0noghfrUm6jbkkiSmNLdQJvhvjrQS7cfQ"
}
}Shown onceAmail keeps only a hash of your key. Errors: 400 invalid_name, invalid_domain, invalid_email, public_suffix_domain, name_reserved, domain_reserved.
Your account and your keys
| Call | Answers |
|---|---|
GET /v1/supplier/me | {"supplier": {...}}, as above: whether your domain is proved, and the record to publish. |
GET /v1/supplier/keys | {"keys": [{"id", "label", "createdAt", "lastUsedAt", "revokedAt"}]}. Never a secret. |
POST /v1/supplier/keys | Another key. label is optional, up to 60 characters. 409 too_many_keys past the most you may hold. |
POST /v1/supplier/keys/:id/revoke | Stops that key on the next call, the key you call with included. Answers with the list. |
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/keys \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"label": "Warehouse system"}'
{
"key": {
"id": "spk_2pa26th6fewmq3tqk43kvqt2kr",
"label": "Warehouse system",
"createdAt": "2026-10-10T12:00:00.000Z",
"lastUsedAt": null,
"revokedAt": null
},
"secret": "amail_sk_FljI0XWAP0oYsHss8jIWW6dyAPeECLehZFxixbvb0MI"
}Note the shapehere secret sits beside key; registering puts it inside.
Prove your domain
POST/v1/supplier/domain/dns
Publish the TXT record from domainProof.dns, then call this with no body. It answers {"supplier": {...}} with "domainVerifiedBy": "dns", or 409 dns_record_not_found while the record is not seen (a new record can take a few minutes).
Why it mattersUntil it is proved, the agent and its person see you as "unverified business" and nothing you typed, and every code you open waits for the person. A DNS record is the one proof: only whoever runs a domain can publish one.
Keep the recordIt is looked for again every day. Five misses in a row over at least three days and the domain is no longer proved; a lookup that fails is not a miss. You are emailed at a first miss.
One business holds a proved domain
400 public_suffix_domain: a domain anyone can take a name under (co.uk,myshopify.com). Register your own name under it (shop.myshopify.com).409 domain_already_proved: another business holds the proof, and its record is still published.- When you stop holding the proof, your active agreements end at once (
endedBy: "domain_proof"). Proving again brings none back.
Where you stand, field by field
domainCheckedAt: when the record was last seen.domainRecordMissing:null, or{"since", "misses", "nextCheckAt", "unprovedAfter": {"misses": 5, "days": 3}}while the record is not seen. Put it back and it clears at the next look, six hours after a first miss, then twelve, then daily.domainUnproved:null, or{"at", "reason"}:record_gone(another business published its record and yours had gone),email_retired(you proved it by an emailed code, which no longer proves anything),stronger_proof(another business published the record for a domain you had proved by email) orduplicate. Publish the record and call this again.- A proof by DNS is never taken by another while its own record is still published. Where the deployment has a reading service switched on, a name that poses as a bank, a public body, a mail provider or Amail itself, on a domain that is not theirs, is shown to the person with one line of caution: you are not told, and a proved domain does not take it away. What you prove is your domain, never your name.
Read an address
GET/v1/check?address=
The public check. No key.
curl 'https://amail-api-production.up.railway.app/v1/check?address=maya.shopping%40amail.example'
{
"address": "maya.shopping@amail.example",
"checkedAt": "2026-10-10T12:00:00.000Z",
"claims": {
"status": "active",
"switchedOff": null,
"kind": "base",
"createdOn": "2026-09-30",
"closesOn": null,
"oneOfSeveral": false,
"goodStanding": true,
"kya": {
"level": 2,
"name": "Live connection",
"facts": [
{ "name": "mailbox_confirmed", "established": true,
"establishedOn": "2026-10-03", "how": "sent_message",
"validUntil": "2027-10-03" },
{ "name": "live_connection", "established": true,
"establishedOn": "2026-10-04", "how": "forwarding_loop",
"checkedOn": "2026-10-10T12:00:00.000Z" },
{ "name": "identity_verified", "established": false,
"establishedOn": null, "how": null }
],
"kyc": { "verified": false, "on": null }
}
},
"statement": "eyJhbGciOiJFZERTQSIsInR5cCI6ImFtYWlsLWNoZWNrK2p3dCJ9.eyJpc3Mi.c2ln",
"statementExpiresAt": "2026-10-10T12:05:00.000Z",
"keysUrl":
"https://amail-api-production.up.railway.app/.well-known/amail-check-keys",
"statusUrl":
"https://amail-api-production.up.railway.app/v1/check?address=maya.shopping%40amail.example"
}| Field | What it is |
|---|---|
status | active, closing, switched_off (with switchedOff.on, the day) or not_active. An address that never existed and a closed one both answer not_active, alike. |
kind | base: the agent's main address. task: one it made for a single order or store. |
kya | The level, 1 to 3, its name, and each fact with how and when it was established (how to read a level). |
statement | The same answer, signed, good until statementExpiresAt (five minutes). Shortened here. |
statusUrl | Where to ask again. The answer that counts is always the issuer's, asked now: a copy, signed or not, says only what was true when it was signed. |
What the signed copy holds
statement is a compact JWS of type amail-check+jwt. Its payload: iss this deployment, sub the address, iat and exp in seconds, five minutes apart, v the format, 2.
{
"iss": "https://amail-api-production.up.railway.app",
"sub": "maya.shopping@amail.example",
"iat": 1791633600,
"exp": 1791633900,
"v": 2,
"claims": { "…": "the claims object of the public check, whole" }
}Verify anything Amail signed
Seven types, all compact JWS signed with Ed25519 by one key, told apart by typ in the header.
typ | What it is | Expires | Made out to you |
|---|---|---|---|
amail-check+jwt | The answer about an address. | Yes, exp, five minutes | No |
amail-receipt+jwt | A receipt: the one signed result of a verification. Has sessionRef (yours) and a nonce. | Yes, exp, fifteen minutes | aud |
amail-agreement+jwt | A record: one change to an agreement. | No | aud |
amail-authorisation+jwt | A signed answer to "authorised for this amount?". | Yes, exp, ten minutes | aud |
amail-answer+jwt | The answer to a request for details: each item given or declined, a digest and never the value. Has sessionRef and a nonce. | Yes, exp, thirty days, or a switch-off | aud |
amail-bundle+jwt | No longer made (the handshakes route is gone). One you hold stands as an answer does. | Yes, exp, thirty days, or a switch-off | aud |
amail-invitation+jwt | An invitation to a shared space. Agents hold these, not businesses. | Yes, exp, seven days | No: sub is the invited address |
Check each the same way: alg is EdDSA and typ the one you expect; the signature under the key kid names; iss the origin you fetched the keys from; sub the address you asked about; exp in the future where it expires; aud your own id (sup_...) where it is made out to you; v 2 for a check and a receipt; and for a receipt or an answer, your sessionRef (or the id you were given when you asked, as jti). readSigned below does all of it. Save it as amail-verify.mjs.
Test receiptsA test deployment's sandbox signs its receipts as amail-test-receipt+jwt, marked "test": true: they stand for nobody. readSigned refuses one unless you pass test: true. Never pass it in production.
Node
import { createPublicKey, verify } from 'node:crypto'; const ORIGIN = 'https://amail-api-production.up.railway.app'; let keys = []; async function keyFor(kid) { let jwk = keys.find((key) => key.kid === kid); if (!jwk) { // Unknown kid: fetch the list again, once, then give up. const list = await fetch(ORIGIN + '/.well-known/amail-check-keys'); keys = (await list.json()).keys; jwk = keys.find((key) => key.kid === kid); } return jwk ? createPublicKey({ key: jwk, format: 'jwk' }) : null; } // The types made out to one reader: aud is required. The one that records // something that happened has no expiry; every other one must have one. // A test deployment's sandbox signs its receipts as their own type: they stand // for nobody. Refuse one, and anything marked test, unless want.test is true. const TEST = 'amail-test-receipt+jwt'; const MADE_OUT = ['amail-receipt+jwt', 'amail-agreement+jwt', TEST, 'amail-authorisation+jwt', 'amail-answer+jwt', 'amail-bundle+jwt']; const RECORDS = ['amail-agreement+jwt']; const VERSIONED = ['amail-check+jwt', 'amail-receipt+jwt', TEST]; // want: { typ, sub, aud, sessionRef, id }. For a receipt or an answer, name // your sessionRef (best: pass one whenever you ask) or the id you were given // when you asked (the verification's or the request's): Amail's nonce only // makes each one unique, and ties it to nothing of yours. export async function readSigned(jws, want) { const [head, body, signature] = jws.split('.'); const { alg, typ, kid } = JSON.parse(Buffer.from(head, 'base64url')); if (alg !== 'EdDSA' || typ !== want.typ) throw new Error('wrong type'); if (typ === TEST && want.test !== true) throw new Error('a test receipt'); const key = await keyFor(kid); const signed = Buffer.from(head + '.' + body); const ok = key && verify(null, signed, key, Buffer.from(signature, 'base64url')); if (!ok) throw new Error('bad signature'); const payload = JSON.parse(Buffer.from(body, 'base64url')); if (payload.test !== undefined && want.test !== true) { throw new Error('a test receipt'); } if (payload.iss !== ORIGIN) throw new Error('wrong issuer'); if (payload.sub !== want.sub) throw new Error('wrong address'); const now = Date.now() / 1000; if (!RECORDS.includes(typ) && !(payload.exp > now)) throw new Error('expired'); if (MADE_OUT.includes(typ)) { if (!want.aud) throw new Error('say whose you expect'); if (payload.aud !== want.aud) throw new Error('not made out to you'); } if (VERSIONED.includes(typ) && payload.v !== 2) throw new Error('older format'); const NONCED = ['amail-receipt+jwt', 'amail-answer+jwt', TEST]; if (NONCED.includes(typ)) { if (typeof payload.nonce !== 'string') throw new Error('no nonce'); if (!want.sessionRef && !want.id) { throw new Error('say which session or request you expect'); } } if (want.sessionRef && payload.sessionRef !== want.sessionRef) { throw new Error('for another session'); } if (want.id && payload.jti !== want.id) { throw new Error('for another request'); } return payload; }
Python
The same in Python (Python 3.8 or later, pip install cryptography)
"""Check a receipt, or anything else Amail signs, offline. Python 3.8+ and `cryptography`: pip install cryptography A signed thing is a compact JWS: three base64url parts joined by dots, signed with Ed25519 (alg EdDSA) by a key published at /.well-known/amail-check-keys. The same steps as the Node example on /docs/api: 1. The header's alg is EdDSA and its typ the type you expect. 2. The signature verifies under the published key its kid names. 3. iss is the Amail you called, sub the address you asked about. 4. It has not expired (an agreement's record has no expiry). 5. A thing made out to one reader names you in aud: your business id. 6. A receipt is format 2 and carries Amail's nonce; name your sessionRef (best: pass one whenever you open a verification) or the verification's id. 7. A test deployment's sandbox signs its receipts as their own type, amail-test-receipt+jwt, marked "test": true: they stand for nobody. Both are refused unless you are testing (allow_test, and that typ asked for). As a script (used by Amail's own tests): the receipt on stdin; prints its payload as JSON and exits 0, or prints why not and exits 1. python verify_receipt.py --keys https://amail.example/.well-known/amail-check-keys \ --issuer https://amail.example --sub maya.shopping@amail.example \ --aud sup_... --session-ref chat-4417 < receipt.txt Keys are fetched over https only (plain http only from this machine, for local development), or read from a file you saved. """ import argparse import base64 import binascii import json import sys import time import urllib.parse import urllib.request from cryptography.exceptions import InvalidSignature from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey # The types made out to one reader: aud is required. TEST = "amail-test-receipt+jwt" MADE_OUT = {"amail-receipt+jwt", "amail-agreement+jwt", "amail-authorisation+jwt", "amail-answer+jwt", "amail-bundle+jwt", TEST} # The one that records something that happened has no expiry; every other one has. RECORDS = {"amail-agreement+jwt"} VERSIONED = {"amail-check+jwt", "amail-receipt+jwt", TEST} NONCED = {"amail-receipt+jwt", "amail-answer+jwt", TEST} LOCAL_HOSTS = {"localhost", "127.0.0.1", "::1"} class NotValid(Exception): """Why a signed thing was refused.""" def _b64(part): if not isinstance(part, str): raise NotValid("not a signed statement") try: return base64.urlsafe_b64decode(part + "=" * (-len(part) % 4)) except (binascii.Error, ValueError): raise NotValid("not a signed statement") def load_keys(source): """The published keys, by kid: from an https URL, or a file holding /.well-known/amail-check-keys.""" if "://" in source: url = urllib.parse.urlparse(source) # Keys decide what is believed: fetched over https, or plain http only # from this machine. local = url.scheme == "http" and url.hostname in LOCAL_HOSTS if not (url.scheme == "https" or local): raise NotValid("fetch the keys over https") with urllib.request.urlopen(source, timeout=10) as answer: listed = json.load(answer) else: with open(source, encoding="utf-8") as file: listed = json.load(file) keys = {} for jwk in listed.get("keys", []) if isinstance(listed, dict) else []: if (isinstance(jwk, dict) and jwk.get("kty") == "OKP" and jwk.get("crv") == "Ed25519" and isinstance(jwk.get("kid"), str)): keys[jwk["kid"]] = Ed25519PublicKey.from_public_bytes(_b64(jwk.get("x"))) return keys def read_signed(jws, keys, want, now=None, allow_test=False): """The payload of a signed thing, once every check passes; NotValid otherwise. want: {"typ", "iss", "sub", "aud", "session_ref" or "id"}. sub is required: a statement about another address is not about the agent you deal with. """ if not want.get("sub"): raise NotValid("say which address you expect") parts = jws.strip().split(".") if isinstance(jws, str) else [] if len(parts) != 3: raise NotValid("not a signed statement") head, body, signature = parts try: header = json.loads(_b64(head)) payload = json.loads(_b64(body)) except ValueError: raise NotValid("not a signed statement") if not isinstance(header, dict) or not isinstance(payload, dict): raise NotValid("not a signed statement") typ = want["typ"] if header.get("alg") != "EdDSA" or header.get("typ") != typ: raise NotValid("wrong type") if typ == TEST and not allow_test: raise NotValid("a test receipt from a sandbox: it stands for nobody") kid = header.get("kid") key = keys.get(kid) if isinstance(kid, str) else None if key is None: raise NotValid("signed by an unknown key: fetch the keys again, once") try: key.verify(_b64(signature), (head + "." + body).encode("ascii")) except InvalidSignature: raise NotValid("bad signature") if payload.get("iss") != want["iss"]: raise NotValid("wrong issuer") if payload.get("sub") != want["sub"]: raise NotValid("wrong address") seconds = time.time() if now is None else now expires = payload.get("exp") current = isinstance(expires, (int, float)) and expires > seconds if typ not in RECORDS and not current: raise NotValid("expired") if typ in MADE_OUT: if not want.get("aud"): raise NotValid("say whose you expect") if payload.get("aud") != want["aud"]: raise NotValid("not made out to you") if typ in VERSIONED and payload.get("v") != 2: raise NotValid("older format") if typ in NONCED: if not isinstance(payload.get("nonce"), str): raise NotValid("no nonce") if not want.get("session_ref") and not want.get("id"): raise NotValid("say which session or request you expect") if want.get("session_ref") and payload.get("sessionRef") != want["session_ref"]: raise NotValid("for another session") if want.get("id") and payload.get("jti") != want["id"]: raise NotValid("for another verification or request") if "test" in payload and not allow_test: raise NotValid("a test receipt from a sandbox: it stands for nobody") return payload def main(): parser = argparse.ArgumentParser( description="Check an Amail receipt read from stdin.") parser.add_argument("--keys", required=True, help="the URL of /.well-known/amail-check-keys, or a file") parser.add_argument("--issuer", required=True, help="the Amail origin you called, e.g. https://amail.example") parser.add_argument("--aud", required=True, help="your business id (sup_...)") parser.add_argument("--session-ref", help="the sessionRef you passed when you opened it") parser.add_argument("--id", help="or the verification's id") parser.add_argument("--sub", required=True, help="the agent address you asked about") parser.add_argument("--typ", default="amail-receipt+jwt") parser.add_argument("--now", type=int, help="seconds since 1970, for tests") parser.add_argument("--allow-test", action="store_true", help="accept a sandbox's test receipt " "(with --typ amail-test-receipt+jwt)") args = parser.parse_args() want = {"typ": args.typ, "iss": args.issuer, "aud": args.aud, "sub": args.sub, "session_ref": args.session_ref, "id": args.id} try: payload = read_signed(sys.stdin.read(), load_keys(args.keys), want, now=args.now, allow_test=args.allow_test) except (NotValid, ValueError) as why: print("refused: " + str(why), file=sys.stderr) sys.exit(1) print(json.dumps(payload)) if __name__ == "__main__": main()
Why a nonce is not enough, and when an answer stops standing
The nonce is Amail's, and only makes each receipt and answer unique: you did not choose it, so it proves nothing about which of your sessions it belongs to. That is what sessionRef is for: pass one every time you ask, the reference you showed the agent in your own channel, and check it. By hand, on the check page, aud is by-hand: and the id that page opened.
An answer to a request stands until exp or until the person switches their agents off, whichever is first: a signature cannot know the future. Before you act on one, read answerValidUntil on the request again; a time already past means it is not good. You are also told by credential.changed.
The keys
GET/.well-known/amail-check-keys
{
"keys": [
{ "crv": "Ed25519", "x": "-w0XtpH32zGrIeHyYYvDIyyrkon-20IyzIB795L4i3k",
"kty": "OKP", "kid": "check_e88f7de894bcc560", "use": "sig", "alg": "EdDSA" }
],
"statementType": "amail-check+jwt",
"statementLifetimeSeconds": 300,
"receiptType": "amail-receipt+jwt",
"receiptLifetimeSeconds": 900,
"formatVersion": 2,
"ephemeral": false
}- Take the origin from your own settings, over HTTPS. Never from the thing you are checking.
- Keep the list. You do not need to fetch it for every check.
- On a
kidyou do not hold, fetch the list again, once. If the key is still not there, the signature is not Amail's. ephemeral: true: this deployment made its key when it started and makes another at its next restart, so what it signed before then stops verifying. A production deployment refuses to start without a lasting key.
Verify an agent
An address check is about an address. A verification shows that the agent in front of you controls it: you get a one-time code, the agent gives it back to Amail naming you (your proved domain, or unverified), and you read one signed receipt.
POST/v1/supplier/verifications
| Field | |
|---|---|
address | Required. The address the agent gave you. |
sessionRef | Your reference for this session (a chat id, an order number): 1 to 128 printable characters, no spaces. It comes back in the receipt. Pass one every time. |
purpose | One line, up to 200 characters, shown to the agent and the person as you typed it. |
liveTest | true: also test the live connection once the agent confirms. |
terms, amount + currency, request | Anything else you need from the person, in the same code: below. |
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/verifications \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"address": "maya.shopping@amail.example", "purpose": "Order 4417, 3 books", "sessionRef": "chat-4417", "liveTest": true}'
{
"id": "kyv_z5p6ec2apvmcyzh8n55kxyhehc",
"address": "maya.shopping@amail.example",
"status": "waiting_for_agent",
"purpose": "Order 4417, 3 books",
"sessionRef": "chat-4417",
"liveTestRequested": true,
"createdAt": "2026-10-10T12:00:00.000Z",
"expiresAt": "2026-10-11T12:10:00.000Z",
"codeExpiresAt": "2026-10-10T12:10:00.000Z",
"addressStatus": "active",
"switchedOff": null,
"askedBy": {
"name": "Larkfern Books",
"domain": "larkfern.example",
"domainVerified": true,
"domainVerifiedBy": "dns",
"path": "api"
},
"confirmedAt": null,
"credential": null,
"kya": null,
"liveTest": null,
"receipt": null,
"receiptExpiresAt": null,
"code": "K7M2-9XWP"
}The code8 characters, shown in two groups of four. The agent may give it back with or without the dash, in either case: dashes and spaces are ignored. It works once, for 10 minutes (codeExpiresAt), and is never shown again.
One fact, two spellingsthe agent's pending_verifications tells it who you are as proved and way; here and in the receipt they are askedBy.domainVerified and askedBy.path. The map.
GET/v1/supplier/verifications/:id
The same object without code. GET /v1/supplier/verifications lists yours, newest first, each item exactly as read alone. Once confirmed:
{
"id": "kyv_z5p6ec2apvmcyzh8n55kxyhehc",
"address": "maya.shopping@amail.example",
"status": "confirmed",
"purpose": "Order 4417, 3 books",
"sessionRef": "chat-4417",
"liveTestRequested": true,
"createdAt": "2026-10-10T12:00:00.000Z",
"expiresAt": "2026-10-11T12:10:00.000Z",
"codeExpiresAt": "2026-10-10T12:10:00.000Z",
"addressStatus": "active",
"switchedOff": null,
"askedBy": { "…": "as above" },
"confirmedAt": "2026-10-10T12:01:12.000Z",
"credential": { "…": "the address as it is now, with its signed statement" },
"kya": { "…": "the level, as in Read an address" },
"liveTest": {
"id": "klt_8ggxfj3ya5dzt20g7je40k48sy",
"address": "maya.shopping@amail.example",
"status": "live",
"confirmedAt": "2026-10-10T12:01:16.000Z",
"roundTripMs": 3200,
"reused": false,
"askedAt": "2026-10-10T12:01:12.000Z",
"completedAt": "2026-10-10T12:01:16.000Z"
},
"receipt":
"eyJhbGciOiJFZERTQSIsInR5cCI6ImFtYWlsLXJlY2VpcHQrand0In0.eyJpc3Mi.c2ln",
"receiptExpiresAt": "2026-10-10T12:16:16.000Z"
}status | Meaning |
|---|---|
waiting_for_agent | Not confirmed yet. You are not told why, whatever keeps it waiting. |
confirmed | The agent controls this address. Carries credential, kya, liveTest if asked, and receipt (null while a live test is still out: read again). |
expired | Not confirmed a day and ten minutes after you opened it: nobody gave the code back, or the person said no or did not answer. You are not told which. |
refused | The code was presented five times by agents that do not control the address, or that named another business. |
Act only on confirmedA no is learned only at the deadline, a day later, so treat everything else as "not yet": do not hold an order open for the day, offer your customer another way, and open a new verification rather than waiting on an old one (why).
It proves who, nothing moreyour first agreement, your first request for details and the first answer the agent would give you alone all wait for the person, who approves you once with their passkey.
Your sandbox, on a test deployment
GET/v1/supplier/sandbox
curl \ https://amail-api-production.up.railway.app/v1/supplier/sandbox \ -H 'authorization: Bearer amail_sk_...'
{
"address": "sandbox-3f9c0a1b2d4e5f6a7b8c9d0e@amail.example",
"confirmsAfterSeconds": 5,
"receiptMarked": "test"
}Your own address, given to you alone: a plain verification of it that you open confirms by itself 5 seconds later, with a sample level (Live connection), "test": true on its view, and a receipt of type amail-test-receipt+jwt. To any other business it is an address nobody has. Terms, an amount or a request are refused (400 sandbox_plain_only). Only a test deployment has it: elsewhere the route does not exist.
Terms, an amount and a request, in the same verification
One code, one receipt, for everything you need from the person: terms as in an agreement, amount answered as "authorised?" is, request as in a request for details. Made whole or not at all.
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/verifications \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"address": "maya.shopping@amail.example", "purpose": "Order 20418", "sessionRef": "order-20418", "terms": {"kinds": ["offers"], "maxPerWeek": 1, "duration": "30d"}, "amount": "84.00", "currency": "USD", "request": {"items": ["delivery_address"], "purpose": "deliver_order"}}'
{
"id": "kyv_z5p6ec2apvmcyzh8n55kxyhehc",
"status": "waiting_for_agent",
"…": "the verification, as above",
"code": "7KQM-3XPD",
"complete": false,
"parts": {
"terms": { "…": "the agreement, as in Agree what you may send" },
"amount": {
"amount": "84.00",
"currency": "USD",
"authorised": null,
"statement": null,
"expiresAt": null
},
"request": { "…": "the request, as in Ask for details" }
},
"receipt": null,
"receiptExpiresAt": null
}completeturns true when every part is settled (eventverification.completed); thenreceiptnames each part's outcome, with the SHA-256 of the request's own signed answer and no value.- Terms are never accepted because the code was confirmed. Terms outside what the agent may agree come back
declined, with arefusalthat names no limit; the other parts go on. - A person who has to decide has a day; after it every line still open is a no.
The receipt
A compact JWS of type amail-receipt+jwt, made out to you alone, for acting on now: it expires fifteen minutes after it was signed. Keep it as your record; for later, read the address again. Verify it with readSigned, naming your aud and sessionRef. Its payload:
{
"iss": "https://amail-api-production.up.railway.app",
"sub": "maya.shopping@amail.example",
"aud": "sup_5v30vw0kmks0gff8298zm1zqg3",
"iat": 1791633676,
"exp": 1791634576,
"jti": "kyv_z5p6ec2apvmcyzh8n55kxyhehc",
"v": 2,
"nonce": "Jv0bK3x9QmT2rZc8pL5aWq",
"sessionRef": "chat-4417",
"receipt": {
"verificationId": "kyv_z5p6ec2apvmcyzh8n55kxyhehc",
"result": "confirmed",
"issuedFor": {
"id": "sup_5v30vw0kmks0gff8298zm1zqg3",
"name": "Larkfern Books",
"domain": "larkfern.example",
"domainVerified": true,
"domainVerifiedBy": "dns",
"path": "api"
},
"address": "maya.shopping@amail.example",
"purpose": "Order 4417, 3 books",
"openedAt": "2026-10-10T12:00:00.000Z",
"confirmedAt": "2026-10-10T12:01:12.000Z",
"addressStatus": "active",
"kya": { "…": "the level at that moment" },
"liveTest": {
"status": "live",
"confirmedAt": "2026-10-10T12:01:16.000Z",
"roundTripMs": 3200
}
}
}Did Amail send this message?
Every message an agent address sends ends with a line Message code: K7M2Q-9XWPT. Give the code (or messageId, the Message-ID header) and the recipient it reached. Once your domain is proved you may leave recipient out: your domain is used.
POST/v1/supplier/messages/verify
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/messages/verify \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"address": "maya.shopping@amail.example", "code": "K7M2Q-9XWPT", "recipient": "orders@larkfern.example"}'
{
"address": "maya.shopping@amail.example",
"sent": true,
"sentAt": "2026-10-10T11:58:03.000Z",
"recipientDomain": "larkfern.example",
"subjectSha256": "9b1f6c0f5a3f0d1e7c2b4a6988d7e5f4c3b2a1908f7e6d5c4b3a29181f0e9d8c",
"bodySha256": "4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce",
"messageId": "<msg_8w522vafr1xqjxkw5dh4w3nra2@amail.example>"
}No means no, and nothing elsea held message, a wrong code, another recipient and an address that is not ours all answer "sent": false with every other field null. No content is ever returned. 400 invalid_recipient: not one address, or left out before your domain is proved.
Comparing the digests
Compare subjectSha256 with the SHA-256 of the subject you received, and bodySha256 with the SHA-256 of the plain-text words in this form: lines end in a line feed alone, spaces and tabs at the end of each line removed, empty lines at the end removed, Unicode NFC, hashed as UTF-8. A difference means the words changed after they left, or a mail system rewrote them (a mailing list footer does). Both are an empty string once the message is no longer kept; bodySha256 is null for an answer Amail wrote with a person's details in it.
On email the message itself is the stronger proof: in production agent mail's domain publishes DMARC p=reject and is signed, so your server's dmarc=pass for the From address says it came through Amail.
Agree what you may send the person
Your mail always reaches the agent, and updates about an order always reach the person. Anything else reaches the person only under an agreement. You propose terms; the agent accepts, counters or declines, inside rules its person set that you are never told.
Terms are fixed choices, nothing else:
| Term | Choices | Left out |
|---|---|---|
kinds | A list of any of offers, marketing, requests: offers, newsletters, questions for the person. | []: order updates only |
maxPerWeek | 1, 3, 7: messages shown to the person in any seven days. | 1 |
duration | 30d, 90d, 1y, open (open: until someone ends it). | 30d |
share | nothing, same_customer: one customerRef to recognise this customer again, different for every business. | nothing |
Send all foura term you leave out takes the most cautious choice, without saying so.
POST/v1/supplier/agreements
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/agreements \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"address": "maya.shopping@amail.example", "kinds": ["offers"], "maxPerWeek": 1, "duration": "90d", "share": "nothing"}'
{
"agreement": {
"id": "agr_71gejgqe3tfcccz571gdate9ag",
"address": "maya.shopping@amail.example",
"status": "proposed",
"awaiting": "agent",
"proposedBy": "supplier",
"terms": {
"kinds": ["offers"],
"maxPerWeek": 1,
"duration": "90d",
"share": "nothing"
},
"alwaysAllowed": ["order_updates"],
"createdAt": "2026-10-10T12:00:00.000Z",
"acceptedAt": null,
"endsAt": null,
"endedAt": null,
"endedBy": null,
"messages": { "shown": 0, "held": 0, "orderUpdates": 0 },
"customerRef": null,
"receipts": [
{
"event": "proposed",
"by": "supplier",
"at": "2026-10-10T12:00:00.000Z",
"receipt": "eyJhbGciOiJFZERTQSIsInR5cCI6ImFtYWlsLWFncmVlbWVudCtqd3QifQ.e30.c2ln"
}
]
}
}| Call | Does |
|---|---|
GET /v1/supplier/agreements | Yours, newest first: {"agreements", "items", "next"}. |
GET /v1/supplier/agreements/:id | One. |
POST /v1/supplier/agreements/:id/accept | Accepts the terms the agent came back with. 409 nothing_to_accept, or 409 outside_what_agent_may_agree if they have since fallen outside its rules. |
POST /v1/supplier/agreements/:id/decline, /end | One call under two names: turns a proposal away, or ends an active agreement, at once. |
status | Meaning |
|---|---|
proposed | Waiting for an answer. awaiting: agent, or supplier when the agent came back with other terms. |
waiting_for_person | The agent accepted and its person approves this themselves. The first agreement with a person always waits for them. |
active | In force until endsAt, or until someone ends it. |
declined | Turned away by the agent, the person or you, or for your domain proof (endedBy: "domain_proof"). |
ended | Was active and is over. endedBy: supplier, agent, person, switched_off, time or domain_proof. |
expired | Nobody answered in fourteen days. |
Errors409 agreement_exists (end the one you have first), 409 domain_not_allowed (a domain many unrelated senders share), 400 invalid_request (a term that is not one of the choices). Posting again while your proposal is open replaces its terms.
How an agreement changes while it stands
- The person can narrow their rule at any time: an agreement outside it ends at once,
endedBy: "person". - An active agreement can go back to
waiting_for_personwhen its person asks to approve that kind themselves. A yes makes itactiveagain with the same dates; a no ends it. - One that reaches
endsAtis ended within a minute, with a signed record whosebyistime. - A proposal to an address that is not active is taken like any other and never answered.
- The weekly number is yours for that person over any seven days: ending an agreement and making another does not reset it.
Say what each message is
One header on every message you send to an agent address:
X-Amail-Kind: offer| What it is | In the header | In kinds | What the agent is told |
|---|---|---|---|
| An update about an order | order-update | always allowed (alwaysAllowed: order_updates) | order_update |
| An offer | offer | offers | offers |
| A newsletter | marketing (or newsletter) | marketing | marketing |
| A question for the person | request | requests | requests |
| A message that does not say | none | never allowed | untagged |
Heldno header (unless it reads as an order update), a kind not agreed, past maxPerWeek, sent to a list, or not what it says it is. Held mail still reaches the agent as fields; the person is not shown it; messages.held counts it, with no reason.
What else decides whether a message counts
- Send from your proved domain (or a subdomain), signed so DMARC passes. Until it is proved, only mail from exactly the domain you registered counts as yours.
order-updateopens nothing by itself: the message has to read as one (an order number, a total, a tracking number).List-Unsubscribe,List-IdorPrecedence: bulkmake itmarketing, whatever the header says.- Where a reading service is switched on, a message that reads as another kind than it says is held. It can only hold back, never let through.
- While an agreement is active, its address stays open to your proved domain even if it was a task address that has since closed.
The record of each change
Every change comes with a compact JWS in receipts, type amail-agreement+jwt, made out to you, with no expiry. Its payload:
{
"iss": "https://amail-api-production.up.railway.app",
"sub": "maya.shopping@amail.example",
"aud": "sup_5v30vw0kmks0gff8298zm1zqg3",
"iat": 1791633780,
"jti": "age_r0ytn087q4anxr8gamwg675sz7",
"agreement": {
"id": "agr_71gejgqe3tfcccz571gdate9ag",
"event": "accepted",
"by": "agent",
"status": "active",
"issuedFor": {
"id": "sup_5v30vw0kmks0gff8298zm1zqg3",
"name": "Larkfern Books",
"domain": "larkfern.example",
"domainVerified": true
},
"address": "maya.shopping@amail.example",
"terms": {
"kinds": ["offers"],
"maxPerWeek": 1,
"duration": "90d",
"share": "nothing"
},
"alwaysAllowed": ["order_updates"],
"acceptedAt": "2026-10-10T12:03:00.000Z",
"endsAt": "2027-01-08T12:03:00.000Z",
"endedAt": null,
"customerRef": null
}
}Is this agent authorised for this amount?
Before you take an order, ask whether the agent may commit to the amount without asking its person. You need a verification of that address the agent confirmed for you in the last day. Safe to send again: it changes nothing.
POST/v1/supplier/authorisations
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/authorisations \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"address": "maya.shopping@amail.example", "amount": "79.99", "currency": "EUR", "verificationId": "kyv_z5p6ec2apvmcyzh8n55kxyhehc"}'
{
"id": "auc_0k8gr1p2142hfx9sas6xrg7b5p",
"address": "maya.shopping@amail.example",
"amount": "79.99",
"currency": "EUR",
"authorised": "yes",
"askedAt": "2026-10-10T12:04:00.000Z",
"expiresAt": "2026-10-10T12:14:00.000Z",
"statement":
"eyJhbGciOiJFZERTQSIsInR5cCI6ImFtYWlsLWF1dGhvcmlzYXRpb24rand0In0.e30.c2ln",
"keysUrl":
"https://amail-api-production.up.railway.app/.well-known/amail-check-keys"
}authorised | Meaning |
|---|---|
yes | The agent may commit to this amount now. |
needs_person | The agent has to ask its person first. Wait for it to come back. |
no | This agent may not buy: its person said so, switched off, or took back its key. |
One word, never a limitno remainder and no reason. A yes counts against what the person lets the agent spend in a month. Probing many amounts stops working: after two answers that were not yes, or six questions, everything is needs_person for a day. 409 verification_needed without a verification that fits.
statement is the signed answer, amail-authorisation+jwt, made out to you, good for ten minutes.
Ask for a delivery address, a phone number, an answer
The agent never holds its person's details. You ask Amail; the person's own rule decides; Amail gives you what was allowed, once, with a signed answer. You need a verification of that address the agent confirmed for you in the last thirty days.
POST/v1/supplier/requests
curl -X POST \ https://amail-api-production.up.railway.app/v1/supplier/requests \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"address": "maya.shopping@amail.example", "purpose": "deliver_order", "orderRef": "ORD-20418", "sessionRef": "order-20418", "items": ["delivery_address", "phone"], "note": "So the courier can ring you on the day."}'
{
"request": {
"id": "ask_4t0c6k2m9q1x7v3b8n5d2h6j0p",
"address": "maya.shopping@amail.example",
"status": "waiting_for_agent",
"purpose": "deliver_order",
"orderRef": "ORD-20418",
"sessionRef": "order-20418",
"items": [
{ "item": "delivery_address", "state": "waiting" },
{ "item": "phone", "state": "waiting" }
],
"createdAt": "2026-10-10T12:05:00.000Z",
"expiresAt": "2026-10-17T12:05:00.000Z",
"answeredAt": null,
"valuesUntil": null,
"receipt": null,
"answerValidUntil": null,
"keysUrl":
"https://amail-api-production.up.railway.app/.well-known/amail-check-keys"
}
}| Field | |
|---|---|
purpose | One of deliver_order, contact_about_delivery, complete_order, other. |
items | Each asked once: the items below. |
orderRef | An order number: letters, digits and at most two dashes, 4 to 24 long, no word in it. |
sessionRef | Yours, as for a verification; it comes back in the signed answer. |
note | One line for the person only. The agent never sees it. |
| Item | What comes back when it is given |
|---|---|
delivery_address | value: line1, line2, city, region, postalCode, country (two letters). An empty part is left out. |
phone | value.number, with its country code: +447700900123 |
order_name | value.name: the name a parcel is sent to |
confirm | answer: true or false, about the order in orderRef, which it needs |
{"item": "choose", "options": [...]} | answer: one of your options, each a short label of letters and digits. |
date, or {"item": "date", "dates": [...]} | answer: YYYY-MM-DD, one of yours when you offered some |
First time, the person decideswhatever their rule says: they see your proved domain, and approve you with their passkey. Each item reads waiting, then waiting_for_person, given or declined; declined never says why. Nothing is given until the whole request is settled.
The answer
GET/v1/supplier/requests/{id}
{
"request": {
"id": "ask_4t0c6k2m9q1x7v3b8n5d2h6j0p",
"address": "maya.shopping@amail.example",
"status": "answered",
"purpose": "deliver_order",
"orderRef": "ORD-20418",
"sessionRef": "order-20418",
"items": [
{
"item": "delivery_address",
"state": "given",
"value": {
"line1": "12 Harbour Lane",
"line2": "Flat 3",
"city": "Bristol",
"region": "Avon",
"postalCode": "BS1 4QA",
"country": "GB"
},
"salt": "Zk3vQ0m1x8bT2nYw5rLd9A",
"digest":
"9f2c1b7e4a6d8c0f3e5b7a9d1c2e4f6a8b0d2c4e6f8a0b1c3d5e7f9a1b3c5d7e"
},
{ "item": "phone", "state": "declined" }
],
"createdAt": "2026-10-10T12:05:00.000Z",
"expiresAt": "2026-10-17T12:05:00.000Z",
"answeredAt": "2026-10-10T12:06:00.000Z",
"valuesUntil": "2026-10-11T12:06:00.000Z",
"receipt":
"eyJhbGciOiJFZERTQSIsInR5cCI6ImFtYWlsLWFuc3dlcitqd3QifQ.e30.c2ln",
"answerValidUntil": "2026-11-09T12:06:00.000Z",
"keysUrl":
"https://amail-api-production.up.railway.app/.well-known/amail-check-keys"
}
}| Field | What it is |
|---|---|
value | In this answer to you and nowhere else, until valuesUntil; then erased. Keep what you need. "valueUnreadable": true: nothing left to collect, ask again. |
receipt | The signed answer, amail-answer+jwt, made out to you: each item's state, a nonce and your sessionRef, no value. Verify it with readSigned. |
answerValidUntil | Until when to rely on it: thirty days, or the start (UTC) of the day the person next switches off. Read it again before you act. |
digest | SHA-256, in hex, of salt, a line break, and value as JSON with its keys in order and no spaces. With value and salt you can show what you were given. |
GET /v1/supplier/requests lists yours ({"requests", "items", "next"}); POST /v1/supplier/requests/{id}/cancel takes one back. 409 verification_needed: no such address, no such verification, or the person switched off, alike.
Events and webhooks
Be told instead of reading again. An event is a type and ids, never content: read what it names to see what it says now. You are told only about what you started, and about addresses you verified lately.
GET/v1/supplier/events?after={cursor}&wait={seconds}
curl \ https://amail-api-production.up.railway.app/v1/supplier/events?after=now&wait=25 \ -H 'authorization: Bearer amail_sk_...'
{
"events": [
{
"id": "evt_524737824d98448ca674acc0dc",
"type": "verification.confirmed",
"createdAt": "2026-10-10T12:01:00.000Z",
"data": { "verificationId": "kyv_z5p6ec2apvmcyzh8n55kxyhehc" }
},
{
"id": "evt_97d3c033dfca45468050bb3d5e",
"type": "request.answered",
"createdAt": "2026-10-10T12:09:00.000Z",
"data": { "requestId": "ask_4t0c6k2m9q1x7v3b8n5d2h6j0p" }
}
],
"cursor": "UtWOPWELQrbm_1JQhZctIA"
}| Parameter | |
|---|---|
after | The cursor of your last call; now to start from the newest event kept; left out, from the oldest (30 days). A cursor works only for you. |
wait | Up to 25 seconds: a call that finds nothing holds on until an event arrives, or answers empty with the same cursor. Two calls with one key may wait at once. |
limit | Up to 100 events, oldest first. |
| Type | What happened | Read |
|---|---|---|
verification.confirmed, verification.refused, verification.expired | A verification you opened was confirmed, refused, or can no longer be confirmed. You are never told that it waits for the person | GET /v1/supplier/verifications/{verificationId} |
verification.completed | Every part of a verification with parts is settled and its agent confirmed: the receipt is ready | GET /v1/supplier/verifications/{verificationId} |
credential.changed | The person behind an address you hold something on switched off, closed their account, or fell a rung. Dated by the day. Read the address again before you rely on anything it gave you | GET /v1/supplier/verifications/{verificationId}, then GET /v1/check |
live_test.finished | The live test inside a verification has its result | the verification it was asked in |
agreement.proposed | The agent proposed terms, or answered yours with others | GET /v1/supplier/agreements/{agreementId} |
agreement.waiting_for_person, agreement.accepted, agreement.declined, agreement.ended | An agreement changed. Ended covers every way one ends | GET /v1/supplier/agreements/{agreementId} |
agreement.expired | Terms nobody answered in fourteen days | GET /v1/supplier/agreements/{agreementId} |
request.waiting_for_person, request.answered, request.expired, request.cancelled | A request for details changed | GET /v1/supplier/requests/{requestId} |
Your webhook
PUT/v1/supplier/webhook
curl -X PUT \ https://amail-api-production.up.railway.app/v1/supplier/webhook \ -H 'authorization: Bearer amail_sk_...' \ -H 'content-type: application/json' \ -d '{"url": "https://larkfern.example/hooks/amail"}'
{
"webhook": {
"url": "https://larkfern.example/hooks/amail",
"status": "active",
"createdAt": "2026-10-10T12:00:00.000Z",
"updatedAt": "2026-10-10T12:00:00.000Z",
"failingSince": null,
"pausedAt": null,
"lastSuccessAt": null,
"lastFailureAt": null,
"lastFailure": null,
"confirmedAt": "2026-10-10T12:00:01.000Z",
"waiting": 0,
"notice": null
},
"secret": "amail_whsec_..."
}Answer the challengewhen you set it, Amail first posts webhook.verify with data.challenge. Answer within ten seconds with 200 and {"challenge": "..."}, or the webhook reads unconfirmed and is sent nothing. The call answers after the challenge.
GET /v1/supplier/webhook reads it without the secret; DELETE removes it. One per business; setting it again replaces it, with a new secret. A webhook set before Oct 14, 2026 is unconfirmed until you set it again (notice says so).
Check every delivery before you act on it:
Node
import { createHmac, timingSafeEqual } from 'node:crypto'; // secret: the one shown when you set the webhook. rawBody: the // body exactly as it arrived, before any JSON parsing. function fromAmail(headers, rawBody, secret) { const at = Number(headers['amail-timestamp']); if (!Number.isInteger(at)) return false; // More than five minutes either way: refuse it, even if signed. if (Math.abs(Date.now() / 1000 - at) > 300) return false; const want = Buffer.from('v1=' + createHmac('sha256', secret) .update(`${at}.${rawBody}`).digest('hex')); // Compared as bytes of equal length: a header outside ASCII is a no. const got = Buffer.from(String(headers['amail-signature'] ?? '')); return got.length === want.length && timingSafeEqual(got, want); } // Then keep each Amail-Event-Id you have handled, and skip one you // have seen: an event can arrive more than once. // When the webhook is set, agree to it: give the challenge back. // (It arrives before you hold the secret, so it cannot be checked.) function answerChallenge(event) { return event.type === 'webhook.verify' ? { status: 200, headers: { 'content-type': 'application/json' }, body: JSON.stringify({ challenge: event.data.challenge }) } : null; }
Python
The same in Python (the standard library only)
"""Check that a webhook delivery came from Amail. Python 3.8+, standard library only. Each delivery is a POST with three headers: Amail-Event-Id the event's id: keep the ones you handled and skip a repeat Amail-Timestamp seconds since 1970 Amail-Signature "v1=" and the hex HMAC-SHA256, under your signing secret, of the timestamp, a dot, and the body exactly as sent Use the raw body as it arrived, before any JSON parsing: parsing and writing it again changes the bytes and the signature no longer matches. As a script (used by Amail's own tests): reads {"headers", "body", "secret"} as JSON on stdin and prints true or false. """ import hashlib import hmac import json import sys import time # More than five minutes either way: refuse it, even if signed. TOLERANCE_SECONDS = 300 def from_amail(headers, raw_body, secret, now=None): """True when the delivery was signed by Amail with this secret, within five minutes. headers: a mapping of header names, in lower case, to values. raw_body: the body as received, as str or bytes. secret: the signing secret shown once when you set the webhook. """ stamp = headers.get("amail-timestamp", "") got = headers.get("amail-signature", "") if not isinstance(stamp, str) or not isinstance(got, str) or not stamp.isdigit(): return False at = int(stamp) if abs((time.time() if now is None else now) - at) > TOLERANCE_SECONDS: return False body = raw_body.encode("utf-8") if isinstance(raw_body, str) else raw_body signed = str(at).encode("ascii") + b"." + body digest = hmac.new(secret.encode("utf-8"), signed, hashlib.sha256).hexdigest() want = b"v1=" + digest.encode("ascii") # Compared as bytes: a header holding characters outside ASCII is a mismatch, # never an error. return hmac.compare_digest(got.encode("utf-8"), want) def answer_challenge(event): """When you set the webhook, Amail first sends webhook.verify: give its challenge back. It arrives before you hold the secret, so it cannot be checked. Returns the JSON body to answer with status 200, or None for any other event. """ if event.get("type") == "webhook.verify": return json.dumps({"challenge": event["data"]["challenge"]}) return None if __name__ == "__main__": given = json.load(sys.stdin) headers = {key.lower(): value for key, value in given["headers"].items()} print("true" if from_amail(headers, given["body"], given["secret"]) else "false")
How deliveries work, in full
- Each event is one
POSTof the event as JSON (id,type,createdAt,data), with the headersAmail-Event-Id,Amail-Timestamp(seconds since 1970) andAmail-Signature:v1=and the hex HMAC-SHA256, under your signing secret, of the timestamp, a dot, and the body as sent. - Your receiver agrees first. When you set the webhook, Amail posts one event of type
webhook.verify, signed like every other, withdata.challenge: a one-time value. Answer it within ten seconds with status200,Content-Type: application/json, and a body of exactly one JSON object whose top-levelchallengeis the one sent:{"challenge": "whc_..."}, at most 1024 bytes. An answer that only holds the challenge somewhere (the event sent back, the challenge nested underdata, as plain text) is not taken: a service that answers with what it was sent agrees to nothing. Until your receiver has, the webhook readsstatus: "unconfirmed",lastFailure: "not_confirmed"(ortimeout,connection,http_and the status), and it is sent nothing at all; the feed has every event either way. Set the webhook again to be asked again. So nobody can point Amail at someone else's address. The challenge comes before you are shown the secret, so you cannot check its signature: answer it, and check every event after it. - Answer an event with any
2xxwithin five seconds. Anything else is a failure: a redirect is not followed, and what you answer is not read beyond its status. - At least once, in order. An event that failed is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours, then given up; the ones after it wait their turn. The feed still has every event either way. An event can arrive twice: use
Amail-Event-Idto skip one you have handled. - Paused after three days in which nothing got through. What waited for it is given up, and nothing new is queued for it. Read
GETon the webhook to seestatus,failingSince,pausedAtandlastFailure(a fixed word:timeout,connection,redirect,not_public, orhttp_and the status). Set the webhook again to start again. - Only the public internet. A webhook is https on port 443, with no name or password in it. Its host is looked up when you set it and again before every delivery: if any address it has is private, loopback, link-local, shared (CGNAT), multicast, reserved or for documentation, in IPv4 or IPv6, it is refused, and a delivery to it fails as
not_public. The connection goes to the address that was checked; the name is not looked up a second time. - Your signing secret is shown once, when you set the webhook, and Amail keeps no copy: it is worked out again for each delivery. Setting the webhook again gives a new secret and the old one stops working at once, asks your receiver to agree again, and drops what was waiting to be sent to the old one (the feed keeps it).
Errors
One shape, everywhere: code for your program, message one plain sentence for a person.
{ "error": { "code": "supplier_unauthorized", "message": "That key is not valid." } }{ "error": { "code": "invalid_request",
"message": "limit: ... (and 1 more: see details)",
"details": [ { "path": "limit", "message": "..." },
{ "path": "cursor", "message": "..." } ] } }Every statusa path that is no route is 404 not_found in this same shape, whatever its method. Every 429 carries Retry-After in seconds. Something wrong on our side is 500 internal_error.
| Code | Status | What it means |
|---|---|---|
invalid_request | 400 | The body or a value in it was not understood. The message names the value where it can: a term that is not one of the fixed choices, a liveTest that is not true or false, a message check with neither a code nor a Message-ID. Where fields did not fit their shape, details lists each one as {path, message}, never with what you sent. |
invalid_idempotency_key | 400 | An Idempotency-Key is 1 to 200 printable characters with no spaces. |
sandbox_plain_only | 400 | The sandbox address confirms a plain verification only: leave out terms, amount and request. |
invalid_address | 400 | The address is missing, or is not one email address. |
invalid_name | 400 | A business name is 2 to 80 characters on one line. |
invalid_domain | 400 | Give the domain your business runs, for example shop.example. |
invalid_email | 400 | Give one email address. |
invalid_label | 400 | A key label is up to 60 characters on one line. |
invalid_purpose | 400 | A purpose is one line of up to 200 characters. |
invalid_session_ref | 400 | A sessionRef is 1 to 128 printable characters with no spaces: the reference you showed the agent in your own channel. |
invalid_amount | 400 | Give the amount as a number with two decimals, for example "80.00". |
invalid_currency | 400 | Give the currency as its three-letter code, for example EUR. |
name_reserved | 400 | The name reads as Amail's own. |
domain_reserved | 400 | The domain is one of Amail's own. |
public_suffix_domain | 400 | Anyone can take a name under that domain (co.uk, myshopify.com), so it is no business's own. Register the name your business runs under it. |
invalid_webhook | 400 | A webhook is an https address on port 443, of up to 500 characters, with no name or password in it. |
webhook_not_public | 400 | The webhook's host could not be looked up, or one of its addresses is not on the public internet (private, loopback, link-local, shared, multicast or reserved, in IPv4 or IPv6). |
invalid_cursor | 400 | The cursor was not one the feed or the list gave you. Pass the cursor of your last call (a list: its next), or none to start from the oldest event kept (a list: the newest item). |
too_many_unchecked_requests | 429 | Your person already has as many requests from askers that proved no domain as reach them in a day. The code was right; nothing was confirmed and nothing reached them. Tell the business; it can try tomorrow, or prove its domain. |
too_many_waits | 429 | This key already has two calls to the feed waiting. Wait for one to answer. |
too_many_webhook_changes | 429 | The webhook was set or removed ten times this hour. |
supplier_unauthorized | 401 | The key is missing, wrong or revoked. A call to the feed that was waiting answers this the moment its key is revoked. |
not_found | 404 | There is no such key, verification, live test or agreement of yours, or no such route. Another business's is answered the same way. |
too_many_keys | 409 | You hold the most keys allowed. Revoke one first. |
idempotency_key_reused | 409 | That Idempotency-Key was used for another call or another body in the last 24 hours. Use a new key for a new call. |
dns_record_not_found | 409 | The TXT record was not seen. A new record can take a few minutes. |
domain_already_proved | 409 | Another business holds the proof of this domain, and its DNS record is still published. Only one business can hold it. |
public_suffix_domain | 409 | A business registered under a domain anyone can take a name under is never proved. |
agreement_exists | 409 | You already have an agreement with this address. End it before proposing another. |
domain_not_allowed | 409 | No agreement is made for a domain that many unrelated senders share. |
nothing_to_accept | 409 | No terms are waiting for your answer on this agreement. |
outside_what_agent_may_agree | 409 | Your terms are outside what this agent may agree. It names no limit. |
verification_needed | 409 | Give a verification of this address that its agent confirmed for you in the last day, with questions left on it. |
too_many_requests | 429 | A limit below was reached. The message says which. Wait and try again. |
Limits
Past a limit: 429 too_many_requests, a message that says which, and Retry-After. Each number is read from the running code.
| What | Limit |
|---|---|
| Calls with one key | 120 a minute |
| Past any limit | 429, with Retry-After: the seconds until the limit lets one more through; where a limit counts what is waiting rather than a window, 60 |
| A list (verifications, requests, agreements) | newest first, a page at a time (limit), and next: the cursor of the page after, or null; every list answers items and next. Verifications: 20 unless asked, at most 50; requests and agreements: up to 100 |
| List calls with one key | 20 a minute, counted inside its calls |
| An Idempotency-Key (on POST verifications, requests, agreements and keys) | 1 to 200 printable characters, scoped to the API key that sends it; the same key and body give the same answer for 24 hours (then 409 idempotency_key_reused for another body); only an answer that succeeded is kept, at most 500 for one business (its oldest goes first), and revoking an API key forgets its answers. Kept in memory only, so a restart forgets it. Asking "authorised?" changes nothing and is safe to send again without one |
| The sandbox, on a test deployment only | your own address, sandbox- and 24 characters nobody else can work out @ the agents' domain, given to you alone (GET /v1/supplier/sandbox): a plain verification of it that you open confirms by itself 5 seconds after it was opened; to any other business it is an address nobody has. Its view says test: true and carries a sample level (Live connection), and its receipt is an amail-test-receipt+jwt, which stands for nobody and which a reader of receipts refuses. No other deployment has the route or the addresses |
| Keys one business may hold at once | 5 (then 409 too_many_keys) |
| Registrations from one network address | 5 in 10 minutes |
| A domain proved by DNS | its record is looked for again every 24 hours, and 6 hours after a miss; after 5 misses in a row over at least 3 days it is no longer proved. A lookup that fails is not a miss and is asked again after 1 hour. You are emailed at a first miss, once in 7 days at most |
| A signed check answer | good for 5 minutes |
| A receipt | made out to you alone; good for 15 minutes after it was signed |
| A session reference (sessionRef) | 1 to 128 printable characters, no spaces |
| Verifications one business may open | 120 an hour |
| Verifications of one address, by every business with a key | 30 an hour |
| A verification code | 8 characters, good once, for 10 minutes |
| A verification that is not confirmed | may still be confirmed for 10 minutes and 24 hours after it was opened, whatever keeps it waiting (its person may be deciding); then it reads expired |
| A code presented by agents that do not control its address, or that name another business | 5 times, then the verification is refused |
| Real live tests of one address, whoever asks | 12 a day unless the deployment sets another number; past it the test answers "unavailable". Each address of a person has its own day, so no answer says two addresses share one |
| A live test result | reused for 5 minutes for the same address |
| Being told an address you verified changed (credential.changed) | for 30 days after the agent confirmed your verification |
| A live test inside a verification | gives up after 60 seconds; the receipt waits for it |
| Message checks one business may make | 300 an hour |
| A message code | 10 characters |
| Proposals one business may make | 60 an hour |
| Proposals waiting at one address | 20 from businesses with a proven domain, 5 from the rest |
| A proposal nobody answers | lapses after 14 days |
| A verification, for asking "authorised?" | good for 24 hours and 3 questions |
| "Authorised?" questions about one person in a day | after 2 answers that were not yes, or 6 questions, no answer is yes until a day has passed |
| A signed authorisation answer | good for 10 minutes |
| A verification, for asking for details | good for 30 days to ask; what you ask a person who has not approved you before waits for them |
| Requests for details one business may make | 120 an hour |
| Requests from one business to one person | 5 a day; past it a request is taken, waits like any other, and is shown to nobody |
| A request | a note of up to 280 characters for the person only; a choice of 2 to 6 options |
| A request nobody answers | runs out after 7 days |
| What you were given | can be read for 24 hours, then it is erased; the signed answer is good for 30 days, or until the person switches their agents off, whichever is first |
| Verifications with terms, an amount or a request | 60 an hour for one business |
| Requests read from mail, for one person | 2 a day from one sender's domain, whichever mailbox there writes; where anyone can have a mailbox, 2 a day from one address and 4 from all of that domain's; 10 a day from every sender together |
| How long an event is kept in the feed | 30 days |
| Events in one answer of the feed | 100 at most |
| How long one call to the feed may wait | 25 seconds (wait) |
| Calls to the feed waiting at once | 2 for one key, 500 on one server (then 429 too_many_waits) |
| Setting or removing a webhook | 10 times an hour (then 429 too_many_webhook_changes) |
| A webhook address | https, port 443, a public address, up to 500 characters; its host is looked up for at most 5 seconds |
| One delivery | 5 seconds to connect and answer with a 2xx; a redirect is a failure; at most 4096 bytes of the answer are read and none kept |
| The challenge when a webhook is set | 10 seconds to answer 200, as application/json, with one JSON object whose top-level challenge is exactly the one sent, in at most 1024 bytes; until then nothing is sent to it |
| A delivery that failed | tried again after 1 minute, 5 minutes, 30 minutes, 2 hours, 12 hours, then given up; the feed still has it |
| A webhook that keeps failing | paused after 3 days in which nothing got through; set it again to start again |
Without a key
| What | Limit |
|---|---|
| Address checks from one network address (page or GET /v1/check) | 30 a minute |
| From one network address, in 10 minutes | 5 verifications, 10 message checks, 600 reads of a result |
| By-hand verifications of one address | 10 an hour, counted apart from businesses with a key |
| By-hand codes for one address, from one network address | 3 an hour, on the verify page and the ask page together |
| A by-hand request whose code nobody confirmed | deleted 60 minutes after the code ran out |
| Asking by hand, from one network address, in 10 minutes | 5 requests, 600 reads of where one stands |
| By-hand requests that reach one person | 5 a day, once an agent of theirs confirmed each code; past it a request is declined |
| Verifications from askers that proved no domain (by hand, or a business with no proof) that reach one person | 10 a day, whichever of their addresses was asked; past it the agent's confirm is refused with too_many_unchecked_requests, nothing reaches the person, and the verification waits for the agent until it runs out |
| By-hand message checks, and live tests inside by-hand verifications, the person is shown | the newest 5 a day for one address |
A network address is one IPv4 address, or one IPv6 /64. Limits per network address and per key are counted by each server on its own.
Rules that always hold
- Your name and purpose are shown to the agent and the person as you typed them, as text, and marked "unverified business" until your domain is proved.
- An agent never sees your key; you never see its token. The one-time code is all that passes, and the agent gives it back only under your name.
- Proving who the agent is gives you nothing else: what you ask of the person goes to them the first time.
- An event is a type and ids, never what anyone said.
- The person sees who verified their agent, who tested its connection and who checked a message, every agreement, and what it let through.
- What Amail does not solve: an agent fooled about who it talks to, on a channel Amail does not carry, can still confirm your code for someone else; your
sessionRefstops a receipt passing as another of your sessions, not that. The person's own approval of a new business stands in the way. Nobody has solved instructions slipped into what an agent reads.