Create an Invoice
Create an invoice
Response
Parameters
The idempotencyKey is sent as a header. Always use crypto.randomUUID() for new invoices.
Two IDs
Every invoice has two identifiers:
Your backend stores id for cancel and internal lookups. You hand publicInvoiceId to the agent.
Fees
amountUsdc in the response includes Gwop’s processing fee. If you send 1_000_000 (1.025) at the current 2.5% fee rate. The fee breakdown is injected into metadata:
Build your pricing around the base amount you send, not the total in the response.
Agent Protocol
The agentProtocol field contains machine-readable instructions for AI agents to complete payment. You don’t need to parse it — hand it to the agent as-is.
The protocol tells the agent:
- What to do next (
nextAction) — fetch the invoice to see payment methods - How to know it’s done (
completionCheck) — poll untilstatus === "PAID"
Idempotency
Passing the same idempotencyKey returns the original response without creating a duplicate invoice. This makes retries safe:
Always generate the idempotency key before the try/catch block so retries use the same key.
Custom Expiry
Invoices expire after 15 minutes by default. Set expiresInSeconds to customize:
Public Metadata
By default, metadata is only visible to the merchant. Set metadataPublic: true to make it visible to the payer through the public invoice endpoint:
This is useful when the agent needs context about what it’s paying for.