Quickstart
In this quickstart, you will wire the core Gwop backend flow:
- authenticate an agent by wallet
- create an agent checkout
- see the headless x402 payment rails Gwop returns for the agent
- validate the signed
invoice.paidwebhook
You should be able to go from install to working code in under 5 minutes.
What happens when you create an agent checkout
When your backend calls invoices.create(), Gwop returns a headless x402 checkout session built for agents.
That session includes x402 payment URLs for every supported chain. The agent fetches the public invoice, discovers the available payment methods, picks a chain, and pays the session-scoped x402 URL — exactly the same way it would pay any other x402 endpoint on the internet.
The payment URL is tied to the checkout session, not to your backend. The agent pays Gwop x402 generated URL directly, Gwop settles the session, and your backend receives a signed webhook confirming the sale.
Your backend keeps full control of the API surface and business rules. Gwop handles multi-chain settlement, webhook confirmation, and the x402 payment contract — the infrastructure you would otherwise build and maintain yourself. The agent gets a machine-readable checkout with concrete payment options and pays using a standard x402 URL, no special integration required.
If you want the production-minded architecture behind this flow, continue into Integration Patterns.
Install
ESM only. For CommonJS projects, use await import("@gwop/sdk").
Environment
Create a file called quickstart.ts, then add the code below in order.
Bootstrap the client and JWT helper
One shared client is enough for invoices and webhook validation. Identity-specific calls stay explicit through identityRequestOptions.
Authenticate the agent and verify the JWT locally
The agent is now a customer. verified.subject is the permanent account identity — every purchase, credit balance, and entitlement you create from here is scoped to this wallet. First auth from a wallet creates the account; repeat auth returns the existing one.
Create an agent checkout
The publicInvoiceId is what the agent uses to fetch the checkout and discover available x402 payment methods. The agentProtocol payload tells the agent exactly what to do next: fetch the invoice, pick a chain, pay the x402 URL. Your backend keeps id for internal references and cancellation.
When the agent fetches the public invoice, it sees the full checkout session — including one x402 payment method per supported chain:
Each paymentUrl is scoped to the checkout session. The agent picks a chain and pays the URL the same way it would pay any x402 endpoint. Gwop verifies the transaction on-chain and settles the session.
What you have now
- one shared Gwop client for your backend
- wallet auth plus local JWT verification
- an agent checkout with x402 payment rails the agent can use immediately
- signed webhook validation for fulfillment
That is the full merchant-side loop: create a checkout, let the agent pay over x402, and settle via webhook. The next layer is architecture — where these pieces live in your routes, services, and adapters.
Keep going
See how to turn this flow into a production-minded backend architecture
Learn why Gwop invoices have both merchant and payer-facing identifiers
Learn when local JWT verification is enough and when to check the session
Learn why {chain}:{address} is the durable customer identity