PeaqosClient. Same client, additive surface. The flat method layout matches the HTTP API one-to-one.
Setup
client.orchestration without orchestrationUrl configured throws OrchestrationConfigError. The namespace lazy-initialises and caches per client.
Configuration
| Field | Env var (via fromEnv()) | Notes |
|---|---|---|
orchestrationUrl | PEAQOS_ORCHESTRATION_URL | Required to use the namespace. Must parse as http: or https:. Non-loopback http:// triggers a warning. |
apiKey | PEAQOS_API_KEY | Required for platform-auth calls. Sent as x-api-key. |
API_BASE_PATH = "/api/v1", prepended to every path.- Timeouts: 30 s GET, 60 s POST/PATCH/PUT/DELETE.
User-Agent: peaq-os-sdk-js/<version>.
Common envelopes
204 No Content resolves to void. validateListQuery rejects limit < 1 or limit > 500 with OrchestrationValidationError before the HTTP call.
Machines
Machine shape:
Machine identity challenges
did:peaq:0x... or peaqos:machine:<id> identity reference. The DID controller signs item.message with EIP-191 personal_sign and submits the resulting { challengeId, signature } as identityProof when creating or updating the machine record.
Agent pairings
createAgentPairingChallengereturns a server-issued challenge keyed toagentAddress,agentProvider,agentRole, and optionalagentDid.- The
item.message(EIP-191) with the key behindagentAddress. createAgentPairingaccepts the proof inparams.agentProofand returns the pairing with a signed HS256 session JWT inpairingToken. The token is returned once at create.createAgentPairingSessionrotates the session token before expiry with a fresh proof. Required after anyupdateAgentPairingto the , since policy changes invalidate the current token’sdelegationPolicyHash.
createAgentPairing and createAgentPairingSession return the pairingToken exactly once each. toJSON redacts the token to "[REDACTED]" so it does not leak through JSON.stringify.
CreateAgentPairingRequest now requires agentProof: { challengeId, signature } and accepts optional agentDid. delegationPolicy.allowedServiceIds and delegationPolicy.deniedServiceIds join the existing skill-level allow/deny lists.
Machine agents
enrollMachineAgent POSTs /machines/:machineId/agents/enrollment and returns a one-time provisioningToken. machineAgentHeartbeat uses no auth header — the agentToken rides in the request body.
Runtime endpoints
PUT. endpointBaseUrl is parsed with new URL(...) client-side; invalid URLs throw OrchestrationValidationError(field: "endpointBaseUrl", constraint: "valid URL").
Skills
Market services
Market search
searchMarket uses x-agent-pairing-token auth — the token rides in the second argument and is sent per call. getMarketSearch falls back to platform auth.
Market orders
listMarketOrders and getMarketOrder use platform auth; the four mutating calls require the agent’s pairingToken.
executeMarketOrder returns a discriminated union on execution.statusCode:
Payment settlement
submitPaymentProof accepts EVM (transactionHash) and Solana (transactionSignature) shapes with verificationMode: "recorded" | "rpc". RPC verification cross-checks the ERC-20 Transfer log against expected token, payerAddress, payeeAddress, and amount.
Pagination
Six auto-paginated iterators ship in this release:*All accepts Omit<XxxOptions, "cursor"> — cursor is managed internally; filters and limit pass through on every page.
For manual pagination, the underlying list* methods now accept cursor and limit:
Coming next
These endpoints ship on the HTTP API (see Machine Markets API: Orchestration). SDK method bindings follow shortly:- Tasks:
createTask,discoverTask,resolveTask,executeTask,getTask,listTasks - Graph:
getMachineGraph,createGraphNode,updateGraphNode,deleteGraphNode,createGraphEdge,updateGraphEdge,deleteGraphEdge - Policies:
listPolicies,createPolicy,getPolicy,updatePolicy - Observability:
listAuditEvents,listRuns,getRun,getReadiness,getHealth - Order family extras:
cancelMarketOrder,retryMarketOrder
@peaqos/peaq-os-sdk so application code can prepare for the methods landing. Forward-looking type declarations carry an @experimental JSDoc tag — treat them as wire shapes likely to change. Method-level stubs for not-yet-implemented endpoints (skill submissions, etc.) are intentionally not exported until the endpoints land.
Errors
Five exported classes, all extendPeaqosError:
instanceof OrchestrationApiError then on err.code. Never parse err.message.
Server code values exported as constants from @peaqos/peaq-os-sdk: ERROR_CODE_AUTH_REQUIRED, ERROR_CODE_AUTH_INVALID, ERROR_CODE_AGENT_AUTH_REQUIRED, ERROR_CODE_AGENT_AUTH_INVALID, ERROR_CODE_AGENT_AUTH_EXPIRED, ERROR_CODE_VALIDATION_ERROR, ERROR_CODE_NOT_FOUND, ERROR_CODE_MACHINE_NOT_ACTIVE, ERROR_CODE_MACHINE_NOT_ACTIVATED, ERROR_CODE_MACHINE_IDENTITY_EXISTS, ERROR_CODE_MACHINE_IDENTITY_IMMUTABLE, ERROR_CODE_MACHINE_IDENTITY_PROOF_REQUIRED, ERROR_CODE_MACHINE_IDENTITY_PROOF_INVALID, ERROR_CODE_MACHINE_IDENTITY_PROOF_EXPIRED, ERROR_CODE_PEAQOS_IDENTITY_UNAVAILABLE, ERROR_CODE_AGENT_PAIRING_PROOF_REQUIRED, ERROR_CODE_AGENT_PAIRING_PROOF_INVALID, ERROR_CODE_AGENT_PAIRING_PROOF_EXPIRED, ERROR_CODE_AGENT_PAIRING_UNAVAILABLE, ERROR_CODE_AGENT_PAIRING_REQUIRED, ERROR_CODE_AGENT_PAIRING_INACTIVE, ERROR_CODE_AGENT_POLICY_DENIED, ERROR_CODE_AGENT_SPEND_LIMIT_EXCEEDED, ERROR_CODE_AGENT_DAILY_LIMIT_EXCEEDED, ERROR_CODE_QUOTE_EXPIRED, ERROR_CODE_ORDER_CLOSED, ERROR_CODE_ORDER_NOT_DELIVERED, ERROR_CODE_PAYMENT_REQUIRED, ERROR_CODE_PAYMENT_RPC_REQUIRED, ERROR_CODE_PAYMENT_RPC_ERROR, ERROR_CODE_PAYMENT_TX_FAILED, ERROR_CODE_EXECUTION_UNSUPPORTED, ERROR_CODE_ENDPOINT_UNREACHABLE.
New types exported in 0.2.0:
MarketPaymentRailType adds "wdk-usdt-transfer" alongside the existing "x402" | "mpp" | "wallet" | "vault-stripe" | "escrow" | "onchain-escrow" | "offchain-record" | "external" | "not-required" set.
The transport synthesises BAD_RESPONSE (non-JSON error body) and INVALID_RESPONSE_SHAPE (envelope mismatch) inside OrchestrationApiError when the server response is malformed.
Credential handling
Three auth modes per call:- Platform (
x-api-key) — set once on the client viaapiKey, sent on every call by default. - Agent pairing (
x-agent-pairing-token) — passed per call tosearchMarketas the second argument. The SDK does not store or rotate it. - None — used only by
machineAgentHeartbeat(token rides in the body).
sanitizeBody() redacts any body field whose name contains token, key, secret, password, credential, or auth (case-insensitive) before attaching the body to an error. Redaction is recursive into nested objects.

