SDK Reference
Complete method reference for @gwop/sdk
Package: @gwop/sdk
Invoices
gwop.invoices.create(request)
Create an invoice for agent payment.
Returns: id, publicInvoiceId, merchantId, amountUsdc, currency, status, agentProtocol, createdAt, expiresAt
The backend adds a 2.5% platform fee to amountUsdc. Request 5_000_000 → invoice total is 5_125_000.
gwop.invoices.list(request?)
List invoices with pagination and optional status filter.
gwop.invoices.get(request)
Get the full public invoice view. Takes publicInvoiceId (inv_*).
Returns: Full checkout view including amount, pricing (baseAmount, gwopFee, total), merchant, paymentMethods (when OPEN), statusCheck, links, and settlement fields (when PAID).
gwop.invoices.cancel(request)
Cancel an open invoice. Takes merchant UUID id.
Canceling an already-canceled invoice is idempotent (returns the same response). Canceling a non-OPEN invoice throws INVOICE_CANCEL_NOT_ALLOWED.
Auth Intents
gwop.authIntents.create(request)
Create a wallet authentication challenge. The agent pays a dust amount ($0.001 USDC) to prove wallet ownership.
Auth intents enforce strict idempotency — reusing an idempotencyKey returns 409 IDEMPOTENCY_CONFLICT, not the original response. Always use a fresh UUID.
gwop.authIntents.exchange(request)
Exchange a settled auth intent for a JWT.
Throws AUTH_INTENT_NOT_SETTLED (402) if the agent hasn’t paid yet. Throws AUTH_INTENT_NOT_FOUND (404) for invalid intent IDs.
Auth Sessions
gwop.authSessions.get(request)
gwop.authSessions.revoke(request)
JWKS
gwop.auth.getJwks()
Fetch the JSON Web Key Set for local JWT verification.
Use with jose:
Webhooks
gwop.validateWebhook(options)
Verify HMAC-SHA256 signature, check timestamp freshness (300s tolerance), and parse into a typed event.
Requires webhookSecret in the constructor. Uses Web Crypto API — works in Node.js, Deno, Bun, and edge runtimes.