Payment Links API
HTTP API reference for Collect payment links. Shareable pay URLs where an agent pays over x402/USDC or a person pays via Pix, verified before fulfillment.
Payment Links API
Collect is CodeSpar's direct-charge product, and shareable payment links are its first surface. Collect is in early access.
REST API for Collect payment links. A payment link is a shareable URL where the
product IS the payment: an agent reads it and pays over x402/USDC, or a person
pays via a Pix QR. One link can advertise more than one settlement method (rail)
at once. The gateway verifies the payment before fulfillment and seals a
hash-chained receipt. Served at pay_url = https://gw.codespar.dev/pay/<slug>.
Base URL: https://api.codespar.dev
All endpoints require authentication. See Authentication.
Endpoints marked admin require a bearer api key OR service auth with an
x-codespar-user header for an account admin/owner. Collect links are
project-scoped.
Payment link object
| Field | Type | Description |
|---|---|---|
id | string | Payment link ID, pl_<...> |
slug | string | URL slug; global namespace. Auto-generated when omitted |
title | string | Display title |
description | string | null | Optional description |
pay_url | string | https://gw.codespar.dev/pay/<slug> |
accepts | Accept[] | One or more settlement rails (see below) |
environment | "test" | "live" | Environment the link settles in |
one_time | boolean | Closes after the first successful payment |
status | string | Lifecycle status |
use_count | number | Successful payments so far |
max_uses | number | null | Cap on total payments; null for unlimited |
expires_at | string | null | ISO 8601, or null |
redirect_url | string | null | Where a person is sent after paying |
active | boolean | Paused links cannot be paid |
created_at | string | ISO 8601 |
Accept (settlement rail)
accepts[] carries one entry per rail. A link can offer x402/USDC, Pix/BRL, or
both; the payer uses whichever they are provisioned for.
x402 / USDC
{
"rail": "x402",
"amount": "0.01",
"currency": "USDC",
"pay_to": { "kind": "provisioned", "consumer_id": "your-consumer" }
}amountis decimal USDC (up to 6 decimals).pay_to.kind: "provisioned"settles to the CodeSpar wallet ofconsumer_id.pay_to.kind: "byo"settles topay_to.address(a0xEVM address).
Pix / BRL
{
"rail": "pix",
"amount": "5.00",
"currency": "BRL",
"pix": { "key": "your-pix-key" }
}amountis decimal BRL (up to 2 decimals).pix.key(orpix.celcoin_account) is where the Pix payment lands.
Create a payment link
POST /v1/payment-links (admin)
Body
{
"title": "Coffee",
"description": "One coffee",
"accepts": [
{ "rail": "x402", "amount": "0.01", "pay_to": { "kind": "provisioned", "consumer_id": "your-consumer" } },
{ "rail": "pix", "amount": "5.00", "pix": { "key": "your-pix-key" } }
],
"one_time": false,
"max_uses": 10
}slugis optional; a unique one is generated when omitted.acceptsmust have at least one rail.one_time,max_uses,expires_at, andredirect_urlare all optional.
Response — 201 Created with the payment link object.
List payment links
GET /v1/payment-links
Response
{ "payment_links": [/* payment link */] }Get a payment link
GET /v1/payment-links/:id — the payment link object, or 404 payment_link_not_found.
Update a payment link
PATCH /v1/payment-links/:id (admin)
Body (at least one field)
{ "title": "...", "description": "...", "active": false, "expires_at": "2026-12-31T00:00:00Z", "redirect_url": "https://..." }Set active: false to pause the link (it can no longer be paid); true to resume.
The accepts rails are fixed at creation and are not editable.
Delete a payment link
DELETE /v1/payment-links/:id (admin) — 204 No Content. Collect links are
config, not audit data; settled receipts are retained independently.
Errors
| HTTP | code | when |
|---|---|---|
400 | invalid_body | body failed validation (including a malformed x402/Pix amount) |
403 | forbidden | non-admin caller on an admin endpoint |
404 | payment_link_not_found | unknown id in this project |
409 | slug_conflict | the slug is already taken |
Paywalls API
HTTP API reference for Gate. Create and manage x402 paywalls that charge agents per call, and read per-paywall earnings.
Wallets
Programmable wallets — per-agent fund pools with mandate-gated debits, multi-rail funding (Pix, TED, USD wire, USDC, BRLA), and automatic reconciliation. Governed by Guardrails in the managed tier.