The Athanor API
A tenant-scoped GraphQL API for a dealer's or a custodian's own systems, one endpoint, two environments, no secrets.
The API is how your systems work with Athanor without a person at the keyboard: a dealer's order sync drafting and advancing orders, a custodian's back office reading its orders feed, a build registering the operations it will run, a webhook consumer hearing an order's facts as they happen.
It is tenant-scoped. Every request runs as one organization, the one the client was minted in, and sees only what that organization sees in the app. It is GraphQL, served at one endpoint, compiled from the same data graph the product itself runs on, so a field means the same thing here as on the page.
Environments
| Environment | API | Auth service |
|---|---|---|
| Sandbox | https://sandbox.athanor.trade/api/graphql | https://auth.athanor.trade/api/oauth2/token |
| Live | https://app.athanor.trade/api/graphql | https://auth.athanor.trade/api/oauth2/token |
Sandbox has seeded data and simulated fills, funding and shipping, and runs any operation. Build and test there; move the same code to live by changing the environment.
Getting in, in three steps
Mint a client [step]
In the app, Settings → API → Clients → New client. Name the system, pick the scopes it needs, and say how it proves who it is: where it runs (a trust policy on the platform's identity) or a private key. You get a client id. There is no secret to copy. See Authentication.
Install the SDK [step]
npm install @athanor-trade/sdkThe SDK carries the published operations, typed from the schema, and a client that obtains tokens, sends documents, and reads refusals as typed errors. See SDK.
Run an operation [step]
import {
createClient,
FederatedAuth,
Vercel,
DealerContextDocument,
} from "@athanor-trade/sdk/promises";
const athanor = createClient({
environment: "sandbox",
auth: FederatedAuth.layer({
clientId: process.env.ATHANOR_CLIENT_ID,
subjectToken: () => Vercel.subjectToken(),
scopes: ["dealer:orders:read"],
}),
});
const { viewer } = await athanor.execute(DealerContextDocument);What the API covers
Published operations
The catalog, pricing, clients, the orders feed and record, the order's steps, webhooks and the registry — per kind.
The order's machine
Draft, then advance one step at a time; the record names the steps that are legal right now.
Webhooks
The order's facts pushed to your endpoint, signed, retried, replayable.
Registered documents
Register the operations your build runs, by hash; on live, accept nothing else.
Budgets and headers
What a document costs, what a client may spend per hour, and what a 429 says.
Refusals
The errors array, its codes and reasons, and what to do with each.
Scopes
A client holds scopes within its organization's kind. A token carries the client's scopes; a field the scopes do not cover is an error at that field, not a refusal of the request.
| Scope | Kind | Grants |
|---|---|---|
dealer:orders:read | dealer | The orders feed and record |
dealer:orders:write | dealer | draftOrder and advanceOrder (and the read) |
dealer:clients:read | dealer | The clients page |
dealer:webhooks:manage | dealer | Registering, verifying and removing webhook endpoints |
custodian:orders:read | custodian | The custodian's orders feed and record |
Ids on the wire
Every id is a global id: base64 of Typename:id. Pass them back as given to node(id:) and to mutations; never build one by hand. A webhook names an order by the same id the feed does.