Skip to Content
Athanor

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

EnvironmentAPIAuth service
Sandboxhttps://sandbox.athanor.trade/api/graphqlhttps://auth.athanor.trade/api/oauth2/token
Livehttps://app.athanor.trade/api/graphqlhttps://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/sdk

The 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

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.

ScopeKindGrants
dealer:orders:readdealerThe orders feed and record
dealer:orders:writedealerdraftOrder and advanceOrder (and the read)
dealer:clients:readdealerThe clients page
dealer:webhooks:managedealerRegistering, verifying and removing webhook endpoints
custodian:orders:readcustodianThe 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.

On this page