SDK reference

Client

new PathGlobal(options) — the key and its mode, the operator signer, idempotency keys, timeouts, lists and the answers that wait for an approval.

Construction

import { PathGlobal } from '@pathglobal/sdk';

const pg = new PathGlobal({
  apiKey: process.env.PATHGLOBAL_API_KEY!,
  timeoutMs: 15_000,
});

Options

PathGlobalOptions:

OptionTypeDefaultNotes
apiKeystring—A key_test_… key reaches the sandbox, a key_live_… key reaches live
baseUrlstringPATHGLOBAL_BASE_URLhttps://api.pathglobal.finance. A trailing slash is removed
fetchtypeof fetchthe global fetchInject one for tests or a custom agent
timeoutMsnumber30000Milliseconds before a request is abandoned
operatorOperatorSignernoneSigns every request as this operator
apiVersionstringPATHGLOBAL_API_VERSIONSent as Path-Version on every request. See Versioning
import { PATHGLOBAL_API_VERSION, PATHGLOBAL_BASE_URL, PATHGLOBAL_DECISION_MODEL, PATHGLOBAL_FLASH_ROUTER } from '@pathglobal/sdk';

PATHGLOBAL_BASE_URL; // 'https://api.pathglobal.finance'
PATHGLOBAL_API_VERSION; // '2026-11-26.genesis'
PATHGLOBAL_FLASH_ROUTER; // 'path-flash-1.0': the default router of an intent, powered by the decision model of the same name
PATHGLOBAL_DECISION_MODEL; // 'path-flash-1.0': the default decision model

PATHGLOBAL_API_VERSION is the version the SDK is published with. Pin it at construction and change it deliberately:

const pg = new PathGlobal({ apiKey: process.env.PATHGLOBAL_API_KEY!, apiVersion: '2026-11-26.genesis' });

mode

pg.mode; // 'test' | 'live'

Read from the prefix of the key, without a request: key_test_ is test, any other key is live. The API answers in the mode the key was issued for and states it in the PathGlobal-Mode header.

What each request carries

HeaderWhen
Authorization: Bearer <key>Always
Path-VersionAlways: apiVersion, or PATHGLOBAL_API_VERSION
Content-Type: application/jsonWhen the call sends a body
Idempotency-KeyWhen the call is given { idempotencyKey }
Path-Operator, Path-Operator-Timestamp, Path-Operator-SignatureWhen the client is built with operator

The answer is parsed as JSON. A status outside 2xx rejects with a PathGlobalApiError.

operator

type OperatorSigner = { id: string; sign: (message: string) => string | Promise<string> };

An operator call in live mode carries the signature of a registered operator. Give the client the operator's id and a sign function; the private key stays with you.

sign receives one string and returns the Ed25519 signature of its UTF-8 bytes, in hexadecimal (128 characters):

METHOD
path?query
sha256(body)
timestamp
LineValue
METHODGET, POST, PUT or DELETE
path?queryThe path and the query of the request, as sent, without the base URL
sha256(body)The hexadecimal SHA-256 of the JSON body as sent; of the empty string for no body
timestampThe instant of signing, ISO 8601, which the client also sends as Path-Operator-Timestamp
import { createPrivateKey, sign } from 'node:crypto';

// The operator's Ed25519 private key, from your own secret store.
const key = createPrivateKey(process.env.OPERATOR_KEY_PEM!);

const pg = new PathGlobal({
  apiKey: process.env.PATHGLOBAL_API_KEY!,
  operator: {
    id: 'op-amara',
    sign: (message) => sign(null, Buffer.from(message), key).toString('hex'),
  },
});

With operator, every request of the client is signed. Test mode reads the operator of the key and asks for no signature. A key that names an operator is used by that operator only: id is that operator. A request without a valid signature is 403 pathglobal.risk.operator_required.

The signature of an approval decision is a separate value, passed to risk.approve and risk.reject.

Idempotency keys

These calls take { idempotencyKey } as their last argument, sent as Idempotency-Key:

NamespaceCalls
accountsopenOmni, openHolding
addressescreateSubject, registerIdentifier, issue
endpointsissue
routerexecute, route
clearingrecord
connectstartSession, link, grant, consume
rampcreateSession
toolsrun, createRequest, issueReceipt
const route = await pg.router.execute(quote.id, { idempotencyKey: `payout-${order.id}` });

The API keeps a key for 24 hours, per key. The same key and body answer the first response again, with PathGlobal-Idempotent-Replay: true. The same key with another body is 409 pathglobal.core.idempotency_conflict; a request sent while the first one runs is 409 pathglobal.core.idempotency_in_progress, and may be sent again. A request holds its key for 300 seconds while it runs. A 5xx answer is not kept: the next request with the key runs.

The other calls send no idempotency key. settlement.exchange is idempotent per caller and reference; treasury.fund funds once per reference. router.quote moves nothing.

Writes the PATH network takes

An address issued, rotated or revoked, an identifier, an alias and a withdrawal are written to the PATH network by the call that makes them. When the PATH network does not take the write, the call rejects with 503 pathglobal.addresses.registrar_unavailable: send it again, with the same idempotency key where the call takes one. The identity of a subject, a pledge, and a change to an endpoint, an anchor or a rail are applied whatever the PATH network answers, and written to it later; an address reads sync: 'owed' until the network holds it, or sync: 'refused' with sync_error when the network refused it.

Error codes

PATHGLOBAL_ERROR_CODES holds the codes of addresses, subjects, aliases, endpoints and Path Tools, of the payment of a PATH address or an alias, and of the choice of a router, to switch on error.code; PathGlobalApiError.codes is the same object and PathGlobalErrorCode its type:

import { PathGlobalApiError } from '@pathglobal/sdk';

try {
  await pg.router.quote(intent);
} catch (error) {
  if (error instanceof PathGlobalApiError && error.code === PathGlobalApiError.codes.ADDRESS_MOVED) {
    // The payee replaced its PATH address: ask the payee for the current one.
  }
  if (error instanceof PathGlobalApiError && error.code === PathGlobalApiError.codes.PAYEE_UNAVAILABLE) {
    // The payee's member did not answer: quote again later.
  }
}

The codes and their statuses are on Errors.

Timeouts and transport failures

Each request is abandoned after timeoutMs (AbortSignal.timeout). A timeout rejects with the TimeoutError of the platform, and a failed connection with the error of fetch: neither is a PathGlobalApiError. The request may have reached the API. Send it again with the same idempotency key, or read the object it creates before sending it again.

Changes that wait for an approval

A change that loosens a control or moves value out waits for a second person: another credential and another operator. Its first call resolves with status 202 to { approval }, where approval is the Approval object. The return type says so: T | ApprovalWaiting.

import type { ApprovalWaiting } from '@pathglobal/sdk';

const waiting = (r: unknown): r is ApprovalWaiting =>
  typeof (r as { approval?: unknown } | undefined)?.approval === 'object';

const answer = await maker.risk.setLimit(limitId, { value: '<amount>', asset: 'USD' });
if (waiting(answer)) {
  // A checker decides with another key: checker.risk.approve(answer.approval.id)
  // then the maker applies the change with the approval id:
  await maker.risk.setLimit(limitId, { value: '<amount>', asset: 'USD' }, answer.approval.id);
}

Test approval for an object: some answers carry approval as the id of the approval that applied them (a policy, an operator, an expected funding). The calls that take an approval id apply the change with it; the treasury policy, safeguard, funding and allowlist calls apply it when the same call is made again once the approval is approved. A treasury transfer executes once approved, with no second call. Risk lists the decision calls.

Test mode only

These calls exist in test mode. On a live key they are 404 pathglobal.core.not_found.

CallDoes
accounts.fundCredits a holding without a deposit
endpoints.simulateDepositA deposit arrives on an endpoint
liquidity.supply, liquidity.withdrawSupplies a pool, pays a position out at once
clearing.close, clearing.settleCloses and settles a clearing cycle
treasury.fund, treasury.defundFunds or defunds a position from the sandbox bank
connectivity.scriptScripts an outcome of the sandbox bank

The sandbox values are on Sandbox.

Lists and pages

A list call resolves to the array. The client pages nothing on its own. The calls that read a page take after, the id of the last item read, and limit:

CallPage
risk.approvals, risk.cases{ after?, limit? } in the filter
risk.audit(from, to, page?){ after?, limit? }
intelligence.listAdvice{ after?, limit? } in the filter, limit 1 to 1000 (default 100)
treasury.ledgerEntriesafter_seq in the filter; 200 entries at a time

One client per key

A client holds one key. A maker and a checker are two clients:

const maker = new PathGlobal({ apiKey: process.env.PATHGLOBAL_MAKER_KEY! });
const checker = new PathGlobal({ apiKey: process.env.PATHGLOBAL_CHECKER_KEY! });

On this page