Working with it

SDK reference

Errors

PathGlobalApiError — the status, the stable code, the request id and the details of an error the API answers, and the codes worth handling by name.

PathGlobalApiError

An answer outside 2xx rejects with one.

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

try {
  await pg.router.execute(quote.id, { idempotencyKey: 'payout-42' });
} catch (e) {
  if (e instanceof PathGlobalApiError) {
    e.status;    // 409
    e.code;      // 'pathglobal.router.quote_expired'
    e.message;   // for a person and a log; do not parse it
    e.requestId; // PathGlobal-Request-Id: quote it to Path Global support
    e.details;   // structured, optional
  }
}
PropertyType
statusnumberThe HTTP status
codestringpathglobal.<product>.<condition>. Stable: switch on it
messagestringFor a person
requestIdstring | undefinedThe request_id of the error envelope
detailsRecord<string, unknown> | undefinedThe details of the envelope, when the API gives them

The API answers { "error": { "code", "message", "details", "request_id" } }. A body that is not JSON, or an error without a code, becomes pathglobal.core.internal with the status of the answer.

A timeout or a failed connection is not a PathGlobalApiError: it is the error of fetch or of AbortSignal.timeout (Client).

Handling by code

if (e instanceof PathGlobalApiError) {
  switch (e.code) {
    case 'pathglobal.router.quote_expired':
      // Quote again; a quote executes once, before expires_at.
      break;
    case 'pathglobal.core.idempotency_in_progress':
      // The first request with this key is still running: send it again later, with the same key.
      break;
    case 'pathglobal.core.idempotency_conflict':
      // The same key was sent with another body: this is a bug in the caller.
      break;
    case 'pathglobal.risk.approval_pending':
      // The change waits for a decision on its approval: details.approval names it.
      break;
    case 'pathglobal.risk.halted':
      // New work is paused. Nothing was started.
      break;
    case 'pathglobal.core.mode_unavailable':
      // The mode of the key is not available now.
      break;
    case 'pathglobal.core.unsupported_version':
      // apiVersion is not a version of the API: details.latest names the latest.
      break;
  }
}

A 429 is a rate limit, which carries the standard RateLimit headers, or one of the codes below: a corridor throttle, a velocity bound, a spent Crossway budget. Read code before sending again. A 5xx answer is not kept against the idempotency key: the request may be sent again with the same key.

Codes

PATHGLOBAL_ERROR_CODES, also reachable as PathGlobalApiError.codes, names 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; PathGlobalErrorCode is their type.

CodeStatusWhen
pathglobal.core.malformed_request400The body or the query does not match the route; a body that is not JSON
pathglobal.core.unsupported_version400Path-Version is not a version of the API; details.latest names the latest
pathglobal.core.not_found404No such object for this caller, a route that is not part of the API, or a test mode call on a live key
pathglobal.core.conflict409The object changed meanwhile, or other content under the same reference
pathglobal.core.reference_taken409The client's reference names another object
pathglobal.core.idempotency_conflict409The same idempotency key with another body
pathglobal.core.idempotency_in_progress409A request with this key is running
pathglobal.core.mode_unavailable503The mode of the key is not available
pathglobal.core.internal500An error of the API
pathglobal.auth.unauthenticated401No key, or a key that is revoked, expired or used outside its address ranges
pathglobal.auth.scope_missing403The key does not carry the scope of the call
pathglobal.accounts.insufficient_funds422The holding or the position does not hold the amount
pathglobal.accounts.frozen409The holding is frozen
pathglobal.accounts.asset_not_held422The holding does not hold that asset
pathglobal.addresses.subject_not_verified422The subject is not verified
pathglobal.addresses.alias_unavailable409, 422The alias is not available, or the address cannot carry one
pathglobal.addresses.alias_held409The subject holds an alias in this network; release it first
pathglobal.addresses.alias_change_limit409The subject has made the alias changes the network allows in a year
pathglobal.addresses.revoked409, 410The address is revoked. A quote or a route to it answers 410 with details.rotated: false
pathglobal.addresses.moved410A quote or a route names a PATH address its holder replaced. The answer does not name the new address
pathglobal.addresses.registrar_unavailable503The PATH network did not take a write of a subject, an address or an alias. Send the same request again
pathglobal.accounts.holder_unknown422holder.path_id names no subject of the client
pathglobal.addresses.rail_not_on_address422The address does not carry that rail; on a pledge, details.index names the entry
pathglobal.endpoints.anchor_incompatible422The anchor does not receive what the endpoint receives
pathglobal.endpoints.issuer_unavailable422No endpoint of that type is issued for that asset, network or country, or the format is not issued on that network on this date (details.status)
pathglobal.networks.identifier_invalid422The identifier is not one of the network
pathglobal.networks.operation_unsupported422The network does not offer the operation
pathglobal.networks.not_connected503The network is not reachable for the operation now
pathglobal.networks.closed409The network is closed now
pathglobal.networks.circuit_open503The connection to the network is not available now
pathglobal.networks.timeout504The network did not answer in time
pathglobal.router.no_route422No route delivers the intent within its constraints
pathglobal.router.router_unknown400, 404router is neither path-flash-1.0 nor a router of the catalogue; details.routers lists them, path-flash-1.0 first
pathglobal.router.payee_unknown404The PATH address or the alias does not resolve. One answer for every case, with no details
pathglobal.router.payee_unavailable503The payee's member did not answer; details.path_code when it answered. Send the same request again later
pathglobal.router.terms_unverifiable502What the payee's member published does not verify; details.check is sonar, discovery, signature, answer, commitment or instruction. Nothing moves
pathglobal.router.instruction_refused409The payee's member refused the payment instruction (details.path_code), or its amount or limits do not fit the route (details.reason: amount or limits). Nothing moves
pathglobal.router.quote_expired409The quote is past expires_at
pathglobal.router.quote_already_used409The quote has been executed
pathglobal.decision.model_unknown400No such decision model
pathglobal.proof.failed422The payment does not pass Proof
pathglobal.proof.review409The verdict is in review
pathglobal.liquidity.no_liquidity400No provider or pool fills the pair for the amount
pathglobal.liquidity.pool_unavailable400, 409The pool is paused or cannot pay out the amount now
pathglobal.liquidity.lock_expired400A liquidity lock or quote has expired
pathglobal.clearing.participant_unknown404The key acts for no participant
pathglobal.clearing.not_debtor403The caller is not the party the call needs
pathglobal.clearing.cap_exceeded422The obligation passes a cap
pathglobal.clearing.participant_suspended409A party is suspended
pathglobal.clearing.cycle_closed409The cycle is closed or settled
pathglobal.settlement.not_funded422The source of the route is neither collected nor held
pathglobal.settlement.invalid_transition409The object is not in a state that allows the call
pathglobal.settlement.guarantee_unavailable422A leg cannot be secured at the level it needs
pathglobal.settlement.rail_unavailable503The network of a leg is not answering
pathglobal.settlement.in_doubt409The outcome of a leg is not known yet
pathglobal.settlement.leg_not_secured409A leg is not secured yet
pathglobal.settlement.deadline409The deadline of the execution has passed
pathglobal.connect.capability_denied403The connection does not grant the capability
pathglobal.connect.limit_exceeded422The amount passes a limit of the connection
pathglobal.connect.inactive409The connection or the delegation is not active
pathglobal.connect.not_due409No charge is due
pathglobal.connect.account_not_found422The account could not be verified
pathglobal.connect.holder_mismatch422The holder does not match the account
pathglobal.ramp.provider_unavailable422The provider does not serve the session
pathglobal.ramp.step_invalid409The session is not at a step that advances
pathglobal.crossway.registry_not_granted403, 429The registry is not granted for the operation, or its budget is spent
pathglobal.crossway.key_unresolvable404The registry does not resolve the key
pathglobal.tools.unavailable503The tool is not available
pathglobal.tools.refusedvariesThe PATH protocol refused the call; details.path_code names why
pathglobal.tools.answer_unverifiable502A signed answer of the PATH network does not verify, or does not answer the question asked
pathglobal.addresses.membership_unverified409A membership of your own requires a proof of membership, not available in this version
pathglobal.treasury.destination_not_allowed403The destination is not one the transfer may pay
pathglobal.treasury.out_of_policy422The change is outside the policy
pathglobal.treasury.reconciliation_break409The source takes no debit until its break is resolved
pathglobal.refuel.cycle_state409No cycle has started, or the cycle has no report yet
pathglobal.ledger.insufficient_position422The account does not hold what the change takes
pathglobal.ledger.limit_exceeded422The change passes a limit of an account
pathglobal.ledger.account_frozen409The account is frozen or closed
pathglobal.risk.halted503New work is paused
pathglobal.risk.corridor_closed422The corridor is closed
pathglobal.risk.corridor_throttled429The corridor is throttled and has reached its rate
pathglobal.risk.exposure_exceeded422A bound of the corridor or a limit
pathglobal.risk.velocity_exceeded429A bound of the client or the destination for the window
pathglobal.risk.breaker_open503A breaker is open
pathglobal.risk.verdict_invalid422The verdict is not valid for this payment or subject
pathglobal.risk.identity_restricted403A party is restricted or blocked
pathglobal.risk.operator_required403Live mode: no valid signature of an operator who carries the scope
pathglobal.risk.self_approval403The checker is the maker, or the decider of a verdict asked for it
pathglobal.risk.approval_pending409The change waits for a decision
pathglobal.risk.approval_invalid409The approval is absent, not approved, expired, already used, or for another change
pathglobal.intelligence.out_of_bounds422The bounds asked for are not admitted

The HTTP contract of each route, with its codes, is in the API reference.

What an error does not say

A negative answer cannot be told apart from another: an object of another client answers as one that does not exist. Errors carry no internal detail. Give Path Global the requestId to look into one.

On this page