SDK Reference
Complete method reference for @gwop/sdk
Complete method reference for @gwop/sdk
Package: @gwop/sdk
gwop.invoices.create(request)Create an invoice for agent payment.
Returns: id, publicInvoiceId, merchantId, amountUsdc, currency, status, agentProtocol, createdAt, expiresAt
The create response is the source of truth for the payable total. If Gwop applies fees or other pricing adjustments, the returned amountUsdc can differ from the base amount you submitted. Use the public invoice pricing block when you need to show a breakdown.
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.
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.
gwop.authSessions.get(request)gwop.authSessions.revoke(request)gwop.auth.getJwks()Fetch the JSON Web Key Set for local JWT verification.
Use with jose:
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.