{"openapi":"3.1.0","info":{"title":"Amail business API","version":"1","description":"Know your agent: verify an agent address, read what stands behind it, propose terms, ask for details and be told what happened. /docs/api explains every field; /changelog.json lists what changed."},"servers":[{"url":"https://amail-api-production.up.railway.app"}],"security":[{"key":[]}],"paths":{"/v1/check":{"get":{"summary":"The public check of an address","parameters":[{"name":"address","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"What anyone may know of the address, and the same answer signed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Check"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}},"security":[]}},"/.well-known/amail-check-keys":{"get":{"summary":"The keys that sign check answers, receipts and records","responses":{"200":{"description":"A JSON Web Key Set","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"object"}}}}}}}},"security":[]}},"/v1/supplier/register":{"post":{"summary":"Register a business and get its first key","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":80},"domain":{"type":"string"},"email":{"type":"string","format":"email"}},"required":["name","domain","email"]}}}},"responses":{"200":{"description":"The business, its first key (its secret shown once) and how to prove its domain","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}},"security":[]}},"/v1/supplier/me":{"get":{"summary":"The business this key speaks for","responses":{"200":{"description":"The business","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/keys":{"get":{"summary":"The business's keys","responses":{"200":{"description":"Every key, never a secret","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}},"post":{"summary":"Make another key","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string","maxLength":60}}}}}},"responses":{"200":{"description":"The key, its secret shown once","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/keys/{id}/revoke":{"post":{"summary":"Revoke a key","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64}}],"responses":{"200":{"description":"Every key, after","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/domain/dns":{"post":{"summary":"Look for the DNS record that proves the domain","responses":{"200":{"description":"The business, with whether its domain is proved","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/verifications":{"get":{"summary":"Your verifications, newest first","description":"Each item is exactly what reading that verification gives. A verification that is not confirmed reads the same whatever keeps it waiting. List calls have a smaller per-key limit of their own.","parameters":[{"name":"limit","in":"query","required":false,"schema":{"default":20,"type":"integer","minimum":1,"maximum":50}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string","maxLength":200}}],"responses":{"200":{"description":"One page","content":{"application/json":{"schema":{"type":"object","required":["items","next"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Verification"}},"next":{"type":["string","null"],"description":"The cursor of the next page; null on the last."}}}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}},"post":{"summary":"Open a verification: a one-time code for the agent","description":"With terms, an amount or a request it carries parts, opened together. On this test deployment, GET /v1/supplier/sandbox gives you your own address whose verifications, opened by you, confirm by themselves; their view says test: true and their receipt is an amail-test-receipt+jwt, which a reader of receipts refuses.","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"address":{"type":"string","description":"An agent address, as the agent gave it."},"purpose":{"type":"string","maxLength":200},"liveTest":{"type":"boolean"},"sessionRef":{"type":"string","maxLength":128,"description":"Your own reference, shown to the agent in your channel; it comes back in the signed result."},"terms":{"$ref":"#/components/schemas/Terms"},"agreement":{"$ref":"#/components/schemas/Terms","description":"The older name of terms."},"amount":{"type":"string","pattern":"^[0-9]+\\.[0-9]{2}$"},"currency":{"type":"string","minLength":3,"maxLength":3},"request":{"type":"object"}},"required":["address"]}}}},"responses":{"200":{"description":"The verification, with its code (shown once)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Verification"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"},"503":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/supplier/verifications/{id}":{"get":{"summary":"One verification","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64}}],"responses":{"200":{"description":"The verification; once confirmed and complete, its one signed receipt","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Verification"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/messages/verify":{"post":{"summary":"Did Amail send this message?","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"address":{"type":"string","description":"An agent address, as the agent gave it."},"code":{"type":"string"},"messageId":{"type":"string"},"recipient":{"type":"string","format":"email"}},"required":["address"]}}}},"responses":{"200":{"description":"Sent or not, with nothing of what it said","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/agreements":{"get":{"summary":"Your agreements, newest first","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string","maxLength":200}}],"responses":{"200":{"description":"One page","content":{"application/json":{"schema":{"type":"object","required":["items","next"],"properties":{"items":{"type":"array","items":{"type":"object"}},"next":{"type":["string","null"],"description":"The cursor of the next page; null on the last."},"agreements":{"type":"array","items":{"type":"object"},"description":"The same items, under the name this list had first."}}}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}},"post":{"summary":"Propose terms to an agent address","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Terms"},{"type":"object","properties":{"address":{"type":"string","description":"An agent address, as the agent gave it."}},"required":["address"]}]}}}},"responses":{"200":{"description":"The agreement","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/agreements/{id}":{"get":{"summary":"One agreement","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64}}],"responses":{"200":{"description":"The agreement","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/agreements/{id}/accept":{"post":{"summary":"Accept the terms the agent came back with","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64}}],"responses":{"200":{"description":"The agreement","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/agreements/{id}/decline":{"post":{"summary":"Decline the terms the agent came back with","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64}}],"responses":{"200":{"description":"The agreement","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/agreements/{id}/end":{"post":{"summary":"End an agreement","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64}}],"responses":{"200":{"description":"The agreement","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/authorisations":{"post":{"summary":"Is this agent authorised for this offer?","description":"Changes nothing, so it is safe to send again; it takes no Idempotency-Key.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"address":{"type":"string","description":"An agent address, as the agent gave it."},"amount":{"type":"string"},"currency":{"type":"string"},"verificationId":{"type":"string"}},"required":["address","amount","currency","verificationId"]}}}},"responses":{"200":{"description":"Yes or no, signed for you alone","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/requests":{"get":{"summary":"Your requests for details, newest first","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string","maxLength":200}}],"responses":{"200":{"description":"One page","content":{"application/json":{"schema":{"type":"object","required":["items","next"],"properties":{"items":{"type":"array","items":{"type":"object"}},"next":{"type":["string","null"],"description":"The cursor of the next page; null on the last."},"requests":{"type":"array","items":{"type":"object"},"description":"The same items, under the name this list had first."}}}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}},"post":{"summary":"Ask an agent's person for details","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"address":{"type":"string","description":"An agent address, as the agent gave it."},"purpose":{"type":"string","enum":["deliver_order","contact_about_delivery","complete_order","other"]},"orderRef":{"type":"string"},"items":{"type":"array","items":{}},"note":{"type":"string"},"sessionRef":{"type":"string","maxLength":128,"description":"Your own reference, shown to the agent in your channel; it comes back in the signed result."},"verificationId":{"type":"string"}},"required":["address","purpose","items"]}}}},"responses":{"200":{"description":"The request","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/requests/{id}":{"get":{"summary":"One request","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64}}],"responses":{"200":{"description":"The request, with what was given while it can be read","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/requests/{id}/cancel":{"post":{"summary":"Take a request back","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":64}}],"responses":{"200":{"description":"The request","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/events":{"get":{"summary":"What happened to what you started, after a cursor","parameters":[{"name":"after","in":"query","required":false,"schema":{"type":"string","maxLength":64}},{"name":"wait","in":"query","required":false,"schema":{"type":"integer","minimum":0,"maximum":25}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"Events: a type and ids, never content","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/webhook":{"get":{"summary":"Your webhook","responses":{"200":{"description":"The webhook, or null","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}},"put":{"summary":"Set your webhook","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","minLength":1,"maxLength":600}},"required":["url"]}}}},"responses":{"200":{"description":"The webhook, and its signing secret shown once","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}},"delete":{"summary":"Remove your webhook","responses":{"200":{"description":"{\"webhook\": null}","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}},"/v1/supplier/sandbox":{"get":{"summary":"The sandbox of a test deployment","description":"Your own sandbox address, given to you alone: a verification of it that you open confirms by itself a few seconds later, with a sample level, test: true on its view, and a receipt of type amail-test-receipt+jwt. To any other business it is an address nobody has. Only on a test deployment; there is no such route anywhere else.","responses":{"200":{"description":"The address, and when it confirms","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"An error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/TooMany"}}}}},"components":{"securitySchemes":{"key":{"type":"http","scheme":"bearer","description":"A business key, amail_sk_..."}},"parameters":{"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":false,"description":"Scoped to the API key that sends it: the same key and body, sent with the same API key, give the same answer and make nothing more, for 24 hours; another body or route is 409 idempotency_key_reused. Only an answer that succeeded is kept, and revoking an API key forgets its answers.","schema":{"type":"string","minLength":1,"maxLength":200}}},"responses":{"TooMany":{"description":"A limit was reached","headers":{"Retry-After":{"description":"Seconds to wait","schema":{"type":"integer","minimum":1}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","description":"For invalid_request: each field that did not fit.","items":{"type":"object","required":["path","message"],"properties":{"path":{"type":"string"},"message":{"type":"string"}}}}}}}},"Terms":{"type":"object","properties":{"kinds":{"type":"array","items":{"type":"string","enum":["offers","marketing","requests"]}},"maxPerWeek":{"type":"integer","enum":[1,3,7]},"duration":{"type":"string","enum":["30d","90d","1y","open"]},"share":{"type":"string","enum":["nothing","same_customer"]}}},"Check":{"type":"object","required":["address","checkedAt","claims","statement"],"properties":{"address":{"type":"string"},"checkedAt":{"type":"string","format":"date-time"},"claims":{"type":"object"},"statement":{"type":"string"},"statementExpiresAt":{"type":"string","format":"date-time"},"keysUrl":{"type":"string"},"statusUrl":{"type":"string"}}},"Verification":{"type":"object","required":["id","address","status","askedBy","createdAt","expiresAt","receipt"],"properties":{"id":{"type":"string"},"address":{"type":"string"},"status":{"type":"string","enum":["waiting_for_agent","confirmed","expired","refused"],"description":"Never says that a person is being asked."},"code":{"type":"string","description":"Only in the answer that opened it."},"purpose":{"type":["string","null"]},"sessionRef":{"type":["string","null"]},"liveTestRequested":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"expiresAt":{"type":"string","format":"date-time"},"codeExpiresAt":{"type":"string","format":"date-time"},"addressStatus":{"type":"string"},"switchedOff":{"type":["object","null"],"description":"Set while the person has switched their agents off: the day they did.","properties":{"on":{"type":"string"}}},"askedBy":{"type":"object"},"confirmedAt":{"type":["string","null"],"format":"date-time"},"credential":{"type":["object","null"]},"kya":{"type":["object","null"]},"liveTest":{"type":["object","null"]},"receipt":{"type":["string","null"],"description":"The one signed result, amail-receipt+jwt, made out to you."},"receiptExpiresAt":{"type":["string","null"],"format":"date-time"},"test":{"type":"boolean","const":true,"description":"Only on a verification of a test deployment's sandbox address: it stands for nobody; its level is a sample and its receipt an amail-test-receipt+jwt."}}}}}}