Skip to Content
Athanor

Schema

The API's SDL as it stands, generated from the data graph. The source of every type on these pages.

The schema is compiled from the same data graph the product runs on and checked in beside it; bun run api:sdl regenerates it and a test fails when it is stale. What follows is that file, included at build time.

Introspection (__schema) answers on sandbox, so a GraphQL explorer pointed at the sandbox endpoint with a bearer token shows the same.

schema.graphql
"""A value the schema does not describe further."""
scalar JSON

"""An ISO-8601 timestamp, UTC."""
scalar DateTime

type PageInfo {
  hasNextPage: Boolean!
  hasPreviousPage: Boolean!
  startCursor: String
  endCursor: String
}

type Query {
  viewer: Viewer!
  products: [Product!]
  pricing(depository: Depository!, alternatives: [Depository!]!): Pricing
  node(id: ID!): Node
  nodes(ids: [ID!]!): [Node]!
}

type Viewer {
  organization: ViewerOrganization
  webhooks: [WebhookEndpoint!]
  workload: Workload
}

union ViewerOrganization = OrganizationDealer | OrganizationCustodian

type OrganizationDealer implements Node {
  id: ID!
  name: String!
  orders(first: Int, after: String, last: Int, before: String): OrderConnection
  clients(first: Int, after: String, last: Int, before: String): ClientConnection
}

interface Node {
  id: ID!
}

type OrderConnection {
  edges: [OrderConnectionEdge!]!
  pageInfo: PageInfo!
  totalCount: Int
}

type OrderConnectionEdge {
  cursor: String!
  node: Order!
}

type Order implements Node {
  id: ID!
  reference: String!
  status: OrderStatus!
  settlementStep: SettlementStep
  nextDeadlineAt: DateTime
  accountNumber: String
  depository: Depository!
  budget: Money
  lines: [OrderLine!]!
  direction: Direction
  lock: Lock
  funding: Funding
  release: Release
  delivery: Delivery
  cancellation: Cancellation
  nextSteps: [OrderStep!]!
  draftedAt: DateTime!
  settledAt: DateTime
  client: Client
}

enum OrderStatus {
  draft
  direction_pending
  direction_signed
  locked
  released
  settled
  cancelled
}

enum SettlementStep {
  executed
  invoiced
  funded
  released
  wired
  delivered
  settled
}

enum Depository {
  brinks_salt_lake_city
  brinks_los_angeles
  brinks_new_york
  cnt_bridgewater
  delaware_depository
  delaware_depository_aston
  delaware_depository_boulder_city
  delaware_depository_las_vegas
  ids_delaware
  ids_texas
  money_metals_eagle
  stonex_new_york
  texas_bullion_leander
  texas_precious_metals_shiner
  tds_las_vegas
  tds_dallas
  wyoming_reserve
  ids_canada
}

scalar Money

type OrderLine {
  id: String!
  productId: ID!
  quantity: Int!
  unitPrice: Money
  indicativeUnitPrice: Money
}

type Direction {
  stage: DirectionStage!
  authorizedMaximum: Money!
  issuedAt: DateTime!
  sentAt: DateTime
  signedAt: DateTime
  custodianRequestRef: String
}

enum DirectionStage {
  issued
  sent
  signed
  declined
  expired
  refused
}

type Lock {
  lockedAt: DateTime!
  allIn: Money!
  fundingDeadlineAt: DateTime!
  holdEndsAt: DateTime!
}

type Funding {
  amount: Money!
  receivedAt: DateTime
}

type Release {
  armedAt: DateTime!
  releasedAt: DateTime
}

type Delivery {
  shippedAt: DateTime
  deliveredAt: DateTime
}

type Cancellation {
  reason: CancellationReason!
  detail: String
  at: DateTime!
}

enum CancellationReason {
  execution_window_expired
  delivery_backstop_expired
  funding_window_expired
  funding_deadline_expired
  routing_declined
  non_delivery
  direction_declined
  pairing_suspended
  pairing_ended
  depository_disabled
  dealer_cancelled
  platform_cancelled
}

enum OrderStep {
  submitProductSheet
  changeDepository
  issueDirection
  sendDirection
  lockPrices
}

type Client implements Node {
  id: ID!
  name: String
  email: String!
  status: ClientStatus!
  source: ClientSource!
  iraAccountNumber: String
  custodianName: String
  depository: Depository
}

enum ClientStatus {
  active
  processing
  archived
}

enum ClientSource {
  manual
  custodian_synced
}

type ClientConnection {
  edges: [ClientConnectionEdge!]!
  pageInfo: PageInfo!
  totalCount: Int
}

type ClientConnectionEdge {
  cursor: String!
  node: Client!
}

type OrganizationCustodian implements Node {
  id: ID!
  name: String!
  orders(first: Int, after: String, last: Int, before: String): CustodianOrderConnection
}

type CustodianOrderConnection {
  edges: [CustodianOrderConnectionEdge!]!
  pageInfo: PageInfo!
  totalCount: Int
}

type CustodianOrderConnectionEdge {
  cursor: String!
  node: CustodianOrder!
}

type CustodianOrder implements Node {
  id: ID!
  reference: String!
  dealerName: String!
  clientName: String
  iraAccountNumber: String
  kind: CustodianOrderKind!
  status: OrderStatus!
  standing: CustodianOrderStanding!
  lines: [CustodianOrderLine!]!
  depository: Depository!
  allIn: Money
  itemized: ItemizedPricing
  draftedAt: DateTime!
  lockedAt: DateTime
  executionWindowEndsAt: DateTime
  fundingDeadlineAt: DateTime
  holdEndsAt: DateTime
  deliveryCheckAt: DateTime
  deliveryExceptionAt: DateTime
  deliveryException: Boolean!
  conformityClaimEndsAt: DateTime
  funding: CustodianFunding!
  delivery: CustodianDelivery!
  authorization: Authorization!
  snapshot: LockSnapshot
  cancellation: Cancellation
  fundedAt: DateTime
  settledAt: DateTime
}

enum CustodianOrderKind {
  purchase
}

enum CustodianOrderStanding {
  unlocked
  waiting_on_cash
  waiting_on_metal
  delivered
  cancelled
}

type CustodianOrderLine {
  productName: String!
  metal: String!
  quantity: Int!
}

type ItemizedPricing {
  dealerPrice: Money!
  dealerSpread: Money!
}

type CustodianFunding {
  instructions: FundingInstructions
  paidIn: Money
  returned: Money
}

type FundingInstructions {
  reference: String!
  amount: Money!
}

type CustodianDelivery {
  evidence: DeliveryEvidence!
  shippedAt: DateTime
  deliveredAt: DateTime
}

enum DeliveryEvidence {
  none
  shipped
  delivered
}

type Authorization {
  kind: AuthorizationKind!
  formVersion: Int
  stage: DirectionStage
  acceptedAt: DateTime
}

enum AuthorizationKind {
  direction
}

type LockSnapshot {
  pairingStatus: String!
  depository: Depository!
  masterAccountLast4: String
  directionVersion: Int!
  directionFormVersion: Int
}

type WebhookEndpoint implements Node {
  id: ID!
  url: String!
  events: [WebhookEventType!]!
  status: WebhookEndpointStatus!
  statusReason: String
  createdAt: DateTime!
  lastDeliveryAt: DateTime
}

enum WebhookEventType {
  order_direction_issued
  order_direction_signed
  order_locked
  order_funded
  order_released
  order_shipped
  order_delivered
  order_delivery_exception
  order_cancelled
}

enum WebhookEndpointStatus {
  verifying
  active
  paused
  disabled
  removed
}

type Workload implements Node {
  id: ID!
  documentMode: DocumentMode!
  documents: [TrustedDocument!]
}

enum DocumentMode {
  ad_hoc
  trusted_only
}

type TrustedDocument implements Node {
  id: ID!
  hash: String!
  operationName: String
  document: String!
  schemaHash: String!
  registeredAt: DateTime!
}

type Product implements Node {
  id: ID!
  name: String!
  metal: Metal!
  form: String!
  weight: String!
  unit: String!
  purity: String!
  manufacturer: String
  bsiCode: String
  bsiPlusCode: String
}

enum Metal {
  gold
  silver
  platinum
  palladium
}

type Pricing {
  asOf: DateTime!
  refreshInMs: Int!
  prices: [Price!]!
  atOtherDepositories: [DepositoryPricing!]!
  closed: [Metal!]!
}

type Price {
  productId: ID!
  unitPrice: Money!
}

type DepositoryPricing {
  depository: Depository!
  prices: [Price!]!
}

type Mutation {
  draftOrder(input: DraftOrderInput!): Order
  advanceOrder(input: AdvanceOrderInput!): Order
  registerWebhook(input: RegisterWebhookInput!): WebhookEndpoint
  verifyWebhook(input: WebhookEndpointInput!): WebhookEndpoint
  removeWebhook(input: WebhookEndpointInput!): WebhookEndpoint
  registerDocument(input: RegisterDocumentInput!): TrustedDocument
  setDocumentMode(input: SetDocumentModeInput!): Workload
}

input DraftOrderInput {
  idempotencyKey: String!
  clientId: ID!
  accountNumber: String
  depository: Depository!
}

input AdvanceOrderInput {
  idempotencyKey: String!
  orderId: ID!
  step: OrderStepInput!
}

input OrderStepInput @oneOf {
  submitProductSheet: ProductSheetInput
  changeDepository: ChangeDepositoryInput
  issueDirection: IssueDirectionInput
  sendDirection: SendDirectionInput
  lockPrices: LockPricesInput
}

input ProductSheetInput {
  budget: Money!
  lines: [OrderLineInput!]!
  then: SheetStep
}

input OrderLineInput {
  productId: ID!
  quantity: Int!
  markup: MarkupInput!
}

input MarkupInput {
  kind: MarkupInputKind!
  value: String!
}

enum MarkupInputKind {
  percent
  fixed
}

enum SheetStep {
  issue
  lock
}

input ChangeDepositoryInput {
  depository: Depository!
}

input IssueDirectionInput {
  authorizedMaximum: Money
}

input SendDirectionInput {
  recipientEmail: String
}

input LockPricesInput {
  expectedAllIn: Money
}

input RegisterWebhookInput {
  url: URL!
  events: [WebhookEventType!]!
}

scalar URL

input WebhookEndpointInput {
  id: ID!
}

input RegisterDocumentInput {
  document: String!
}

input SetDocumentModeInput {
  mode: DocumentMode!
}