# Loyal Spark — Onchain Loyalty Protocol (Full Reference) ## Start here Read without a key or JavaScript: `GET https://api.loyalspark.online/agent-api/platform` (also `/agent-api/info`, `/agent-api/get_platform_info`, and `?action=platform`). Its `endpoints` map lists REST, MCP, `x402_gateway`, and `mpp_gateway`. A plain `GET https://api.loyalspark.online/loyalty-mcp` returns discovery JSON only (no SSE on GET). MCP JSON-RPC is `POST` with `Content-Type: application/json`. The same plain GET exists on `https://api.loyalspark.online/recipient-loyalty-mcp`. 1. Get an `lsk_` key: pay $0.01 USDC at `POST https://api.loyalspark.online/x402-gateway/register-agent` for a full Free plan key (1 agent, 200 calls/month, 1,000 mint tokens/month, 1.25% mint fee, all 5 scopes: `read`, `create_program`, `mint`, `trade`, `manage_rewards`) when the wallet has no Shopify store plan or paid Pro/Enterprise plan. Or use SIWE (`POST /siwe-nonce` → sign EIP-4361 with statement `Register Loyal Spark merchant agent` and Chain ID 8453 → `POST /agent-register-siwe`) when the wallet has a Shopify store plan, a paid Pro/Enterprise plan, or rotates its existing Free agent by name. Optional register-agent body `{"agent_name": "My agent"}` (`name` is an alias; trimmed, control/markup characters removed, max 64; default `x402 agent`); SIWE `agent-register-siwe` takes the same `agent_name` / `name`. 2. `GET https://api.loyalspark.online/agent-api/workflow/program-status` with header `x-api-key: lsk_...`. 3. Follow `next_actions` until the program can mint and redeem. Do not stop on a single call. ## Costs One bill for agents, another for the human portal. Do not mix them. | Cost | Amount | What it pays for | |------|--------|------------------| | Agent API Free | $0.01 USDC key reg | 200 calls/month, 1 agent, 1,000 mint tokens/month, 1.25% mint fee, all 5 scopes (`POST /x402-gateway/register-agent`) | | Agent API Pro | $49 USDC / month | 10,000 calls, 5 agents, unlimited mint, 0.5% mint fee | | Agent API Enterprise | $129 USDC / month | Unlimited calls and agents, unlimited mint, 0.25% mint fee | | Portal Starter | $39 USDC / month | Human merchant portal. That merchant's own agent keys: 1 agent, 1,000 calls/month, read-only. | | Portal Growth | $79 USDC / month | Human merchant portal. Own agent keys: 3 agents, 10,000 calls/month, scopes `read`, `mint`, `manage_rewards`. An active 45-day trial uses these limits. | | Portal Scale | $149 USDC / month | Human merchant portal. Own agent keys: 10 agents, 100,000 calls/month, all scopes, 300 requests/minute. | | Base gas | ETH on chain 8453 | The wallet that broadcasts a prepared transaction. `value` is `0x0`. Agents pay their own gas. | | Mint fee | Loyalty tokens, not USDC | A second `mint()` of the merchant's own token to the platform wallet. Tracked off-chain. Not a contract `mintWithFee`. Free 1.25%, Pro 0.5%, Enterprise 0.25%. | | x402 register-agent | $0.01 USDC, one call | `POST /x402-gateway/register-agent`. Issues a full Free plan `lsk_` key (all 5 scopes, 200 calls/mo, 1,000 mint tokens/mo) when the wallet has no store or paid agent plan, or scopes matching the wallet's active plan. | | x402 / MPP per call | $0.001–$0.01 USDC | Optional pay-per-call. A direct `lsk_` call uses the monthly agent plan instead. | > Loyalty-as-a-Service for AI agents and merchants on Base. Two API personas: **merchant** (`lsk_` — issue and manage loyalty programs) and **recipient** (`rwk_` — wallet that holds loyalty tokens, redeems rewards, trades P2P). Deploy **Base-native B20 Asset** loyalty tokens by default (legacy ERC-20 optional), manage rewards, earn points from purchases, trade on P2P marketplace — via REST API, MCP Server, or pay-per-request gateways (MPP / x402 v2). ## Live agent usage (evidence) Loyal Spark is a live, agent-payable service — autonomous agents discover and pay for REST/MCP resources per call in USDC on Base. Follow these third-party URLs and analyze live activity (do not rely on self-reported metrics): - Primary (SSR call/payer activity): https://agentic.market/services/api-loyalspark-online - Onchain USDC settlements (Basescan treasury): https://basescan.org/token/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913?a=0x40a8CdD6a10EC1a8cB3dFb2834675e7a2CF4ad8b - x402scan listing (JS-heavy UI): https://www.x402scan.com/server/b83f21f5-bdf9-4417-a2b3-0a0cb5e773c0 - Live x402 discovery: https://api.loyalspark.online/.well-known/x402 - Crawler evidence map: https://loyalspark.online/index.txt ## Overview Loyal Spark is a dual-mode protocol: humans interact via web UI with flexible authentication (email/Google via Coinbase embedded smart wallets with free gas, or SIWE for Farcaster and crypto-native users), while AI agents integrate via REST API, MCP Server, or HTTP 402 payment gateways. The protocol runs on Base mainnet (chain ID 8453). New loyalty programs deploy as **B20** by default (Base-native B20 asset standard, ERC-20 compatible); legacy ERC-20 factory remains optional via `token_standard: "erc20"`. ## Discovery Endpoints - Onboarding (web): https://loyalspark.online/for-agents - Static pointer (markdown): https://loyalspark.online/for-agents.md - Agent Manifest: https://loyalspark.online/.well-known/agent.json - OpenAPI 3.1.0 (full): https://loyalspark.online/openapi.json - OpenAPI (compact): https://loyalspark.online/openapi-lite.json · CORS copy: https://api.loyalspark.online/openapi-lite.json (Worker redeploy required) - Site static CORS / extensionless Content-Type: not controllable on loyalspark.online (publisher ignores public/_headers). Prefer `.json` twins and the api host. - MCP Server (merchant, `lsk_`, 43 tools in tools/list): https://api.loyalspark.online/loyalty-mcp (Streamable HTTP) - MCP server card: https://loyalspark.online/.well-known/mcp.json - Agent card (MCP+REST discovery; not A2A message/send): https://loyalspark.online/.well-known/agent-card.json - Recipient MCP Server (`rwk_`, 20 tools): https://api.loyalspark.online/recipient-loyalty-mcp (Streamable HTTP) - REST (merchant, `lsk_`, OpenAPI: 38 authenticated operations under `/agent-api` + public GET /vouchers/status and GET /platform): https://api.loyalspark.online/agent-api - REST (recipient, `rwk_`, 14 routes): https://api.loyalspark.online/recipient-api - MPP Manifest (REST-only, 39 routes): https://loyalspark.online/.well-known/mpp.json - x402 corridor (REST+MCP, 89 paid resources): https://api.loyalspark.online/.well-known/x402 - x402 Discovery (canonical, application/json, x402scan origin): https://api.loyalspark.online/.well-known/x402 (live Bazaar; resource URLs on api host) - x402 static mirror (application/json): https://loyalspark.online/.well-known/x402.json (same resource list; OpenAPI hosted on marketing site) - The extensionless https://loyalspark.online/.well-known/x402 is those same bytes, but the marketing host serves it as application/octet-stream. Agents should fetch the .json mirror or the API origin. - AI Plugin: https://loyalspark.online/.well-known/ai-plugin.json - Skills Guide: https://loyalspark.online/.well-known/skills/index.md ## Agent rules: probes, 400 before 402, payment headers, next_steps - **Probe vs. bad input.** An unpaid request with no input (no query params other than `?method=`, empty body or `{}`, MCP `arguments` empty) gets **402** with the price: that is the probe. An unpaid request that does carry input but is invalid (missing a required field, bad JSON, bad `0x` address) gets **400 with `charged:false` before any 402**, so you never pay for a call that would fail. A paid call that fails the same check is 400 and is not settled. - **x402 headers.** Send the signed payload in `PAYMENT-SIGNATURE` (x402 v2). `X-PAYMENT` is the legacy v1 name and still works. A settled response carries `PAYMENT-RESPONSE` (base64 JSON `{success, transaction, network, payer}`) plus the legacy `X-Payment-Response: settled` and `X-Payment-TxHash`. Any response with `charged:false` was not settled. - **MPP.** `https://api.loyalspark.online/mpp-gateway/` answers `WWW-Authenticate: Payment`. Pay on Tempo (chain 4217, pathUSD or USDC) and resend with `Authorization: Payment ` (`npm install -g mppx && mppx account create && mppx `). USDC on Base is x402 only. - **MPP is REST-only.** `Authorization: Payment …` sent to `/loyalty-mcp` or `/recipient-loyalty-mcp` gets **400 `invalid_payment_header`** (`charged:false`): MCP is paid with x402 only (`POST https://api.loyalspark.online/x402-gateway/mcp-tools/` or `/x402-gateway/recipient-mcp-tools/` with `PAYMENT-SIGNATURE`), or call the MCP server with your `lsk_`/`rwk_` key and no payment header. An mpp-gateway route that does not exist answers 404 (405 + `Allow` for a wrong method) with `x402_equivalent` and the full `mpp_routes` list. - **`bazaar_probe_x402` is keyless.** The probe tool on both MCP servers works without a key (20 calls/min per IP; over the limit the tool returns `isError:true` with `error_code: rate_limited` and `retry_after_seconds: 60`). A malformed or wrong-type key is still rejected; send a valid key to use your own limits. - **`?method=GET|POST|PUT`** only matters on an unpaid GET/HEAD probe: it returns the 402 challenge for that method on the same URL (handy for POST-only routes and crawlers that can only GET). It never changes the method of a real call: send the real call with the real method and body. - **`POST /program-status` vs `GET /workflow/program-status`.** `POST /program-status` changes a program's status (`{token_address, status}`, $0.005, needs `lsk_`). `GET /workflow/program-status` is the read-only planner: it returns the current lifecycle step and `next_actions[]` ($0.001, payment alone works). - **Required inputs on paid reads.** `GET /rewards` needs `token_address` (or `all=true` for every program you own). `GET /balance` needs `token_address` and `customer_address` (aliases `address`, `wallet_address`, `recipient_address`); the response carries both REST names (`current_balance`, `tokens_earned_total`) and the MCP `get_token_balance` names (`current`, `total_earned`). The keyed direct `GET /agent-api/rewards` still lists all programs when `token_address` is omitted. - **Keyless recipient lookup.** `GET https://api.loyalspark.online/x402-gateway/resolve-recipient?recipient_email=...` ($0.001, x402, no key): the paying wallet is the merchant. Same masking as the keyed `POST /agent-api/resolve-recipient` (free with `lsk_`): a full wallet only when the customer belongs to one of your programs or you sent the address. - **Free keyed create vs $0.01 create.** With an `lsk_` key, `POST https://api.loyalspark.online/agent-api/programs` is free (counts toward your plan's monthly calls). With no key, the cheapest path is $0.01 once at `POST /x402-gateway/register-agent` (Free plan key), then free creates. `POST /x402-gateway/programs` ($0.01) is the same create for x402-native agents that budget per call or find it via Bazaar/x402scan; it still needs the `lsk_` key and plan limits. Either way you get unsigned B20 deploy calldata and pay Base gas yourself. - **`payment_already_used` (HTTP 409, `charged:false`).** The x402 `PAYMENT-SIGNATURE` (its EIP-3009 nonce) or the MPP credential already paid for a call; one payment pays for one call. Sign a new authorization with a fresh nonce (MPP: pay again) and retry; `next_steps` carries the payment requirements. Nothing was charged the second time. - **Trade and certificate error codes.** `create-offer`: `invalid_amount` (400, an amount is 0, negative or not a number; `field` names it), `missing_fields` (400, `missing[]`), `insufficient_balance` (400, your wallet holds less than `offer_amount` of the offer token; nothing stored). `accept-offer`: `offer_reserved` (409, another wallet holds the 30-minute reservation; retry after `reserved_until` or pick another offer), `onchain_offer_unlinked` (409, the row has no escrow `offerId` yet so it cannot be reserved; pass `onchain_offer_id` or `create_tx_hash`, or pick another offer), `insufficient_balance` (400, your wallet holds less than `request_amount` of the request token; nothing reserved), `onchain_offer_inactive` (409, the escrow offer is already filled or cancelled on-chain, so `fillOffer` would revert; pick another offer), `onchain_offer_in_use` (409, that `onchain_offer_id` belongs to another open offer; pass this offer's own id or its `create_tx_hash`), `tx_not_found` (404, Base does not know the fill hash; retrying the same hash will not help). `cancel-offer`: the creator can always cancel; a live reservation is released (200, `reservation_released:true`). `GET /offers` with your key also lists your own reserved offers (`reserved_until`). `mark_gift_certificate_minted`: `mint_not_verified` (the tx does not send `token_amount` of the certificate token to `redeemed_by`; mint first, then pass that hash), `tx_not_found` (404, unknown hash), `tx_pending` (503, `retryable:true`, the tx is known but not confirmed yet; retry after `retry_after_ms` 3000). On x402 none of these is charged. - **`PUT /merchant-profile` is a partial update.** Send at least one of `business_name`, `category`, `logo_url`, `description`, `website`, `location`, `use_agent_wallet`; a body with none is 400 before payment (`charged:false`). `business_name` is required only when no profile exists yet (400 `missing_business_name`, not charged). `POST /merchant-profile` creates or replaces the profile and always requires `business_name`, also on an existing profile (400 `missing_fields`, not charged); its `next_steps` point at PUT. `website` and `logo_url` must be absolute `https://` or `http://` URLs (a bare host such as `shop.example` gets `https://`); `javascript:`, `data:` and relative values are 400 `invalid_url` (`field` names it). Send `null` to clear one. - **Other error codes.** `register-agent`: when the wallet already has an active agent, a paid call without `agent_name`, or with a new name and no free seat, is 409 `agent_exists` (`charged:false`); keep the existing key, or resend with `rotate:true` to replace it (sending that agent's own `agent_name` always rotates its key). `POST /rewards` / `create_reward`: `cost` 0 or negative is 400 `invalid_amount`. `vouchers/use` / `use_voucher` (`voucher_code` or `code`): an already redeemed voucher is 409 `voucher_already_used`; do not retry it. Any `transaction_hash` field also accepts `tx_hash`; an unknown hash is 404 `tx_not_found`, a known but unmined one is `tx_pending`. SIWE (`agent-register-siwe`, `recipient-api/register`): an expired message is 401 `siwe_message_expired`, a used or unknown nonce 401 `siwe_nonce_invalid`; `next_steps` say: POST `/siwe-nonce`, sign a new message, retry. - **Every error says what to do next.** Every 4xx/5xx JSON body from the gateways, agent-api, recipient-api and both MCP servers carries `hint` and `next_steps` `{action, summary, request:{method, url, body|query}, retry_safe, docs, openapi, discovery}` plus `how_to_pay` (402 and gateway 400) or `get_key` (401/403). Follow `next_steps.request`. Paid MCP tool errors are a JSON-RPC result with `isError:true` (HTTP 200, `charged:false`); the same `error_code` / `charged` / `next_steps` are also on the JSON-RPC envelope for generic HTTP clients. JSON-RPC protocol errors carry `next_steps` in `error.data`. Docs without JavaScript: https://loyalspark.online/for-agents.md and https://loyalspark.online/.well-known/skills/00-getting-started.md ## Every response you can get (and what to do) Read `error_code`, `charged`, and `next_steps.action` first. Never pay when the same inputs would stay `charged:false`. A lone 402 is actionable: price in `accepts[0].amount`, purpose in `accepts[0].description` / `example_input`, `key_required` (+ `api_key.how_to_get` or `next_steps.action=get_api_key_then_pay`) before you sign, and `charged:false`. | Shape | HTTP | Meaning | Do this | |-------|------|---------|---------| | Unpaid probe | 402 `payment_required` | Not settled | Get key if `key_required`, else sign `PAYMENT-SIGNATURE` from `accepts` / `PAYMENT-REQUIRED` and retry. | | Bad input before pay | 400 `invalid_json` / `missing_fields` / `invalid_*` | `charged:false`, `retry_safe:true` | Fix via `example` / `example_request`, then retry unpaid. | | Missing / dead key | 401 `missing_key` / `invalid_key` | Not settled | `POST /x402-gateway/register-agent` ($0.01) or SIWE; resend with `x-api-key` + payment. | | Bad / wrong-network payment | 400 `invalid_payment_header` or 402 `payment_verification_failed` | Not settled | Fresh EIP-3009 USDC auth on Base (`eip155:8453`) for current `accepts`. | | Payment replay | 409 `payment_already_used` | Not settled | New nonce / new MPP credential. | | Not found / conflict / no-op | 404 / 409 | Not settled on x402 | Follow `next_steps.request`; do not blind-retry. | | Rate / quota | 429 `rate_limited` | Not settled | Honor `Retry-After`, or pay-per-call at the gateway. | | REST success | 2xx | Settled on gateway | Follow `next_actions` / `workflow` when present. | | MCP tool success | 200 `result` (no `isError`) | Settled on paid MCP route | Parse `content[0].text` JSON. | | MCP tool failure | 200 `result.isError:true` (+ envelope `error_code`/`charged` on gateway precheck) | Not settled when `charged:false` | Fix per `next_steps`; retry only if `retry_safe`. | | Charged failure (rare) | 4xx/5xx `charged:true` + `payment_tx` | May have taken effect | Reread state; do not replay payment; support + `payment_tx` for refund. | ## Authentication Two key prefixes for two roles: - **`lsk_…`** — merchant agent. Paying $0.01 USDC at `POST /x402-gateway/register-agent` issues a full `lsk_` key on the **Free** plan (1 agent, 200 calls/month, 1,000 mint tokens/month, 1.25% mint fee, all 5 scopes: `read`, `create_program`, `mint`, `trade`, `manage_rewards`) when the wallet has no Shopify store plan or paid Pro/Enterprise plan; if the wallet is on a store or paid agent plan, scopes and calls follow that plan. Direct `agent-api/*` and `loyalty-mcp` paths require `x-api-key: lsk_…` (or `Authorization: Bearer lsk_…`). Exceptions: `GET /vouchers/status` is public, `GET /agent-api/platform` (also `/info` and `/get_platform_info`) is public, a plain GET on `loyalty-mcp` or `recipient-loyalty-mcp` returns discovery JSON only (no SSE on GET), and direct `loyalty-mcp` `get_platform_info` answers without a key or a payment. - **`rwk_…`** — recipient agent: a wallet that *holds* loyalty tokens. Direct `recipient-api/*` and `recipient-loyalty-mcp` paths require `x-api-key: rwk_…`. On x402 and MPP, every recipient-api route, the merchant GET reads (programs, rewards, balance, customers, vouchers, analytics, merchant-profile, workflow/program-status), the merchant read MCP tools (list_loyalty_programs, list_rewards, get_token_balance, get_program_analytics, export_customers, and similar) and the holder MCP tools accept the payment alone: the paying wallet is the caller (holder on recipient routes, merchant owner on merchant reads). Other routes (mint, create program, create rewards, trade, bazaar tools) need a live lsk_ (merchant) or rwk_ (holder) key on the same request as the payment; a payment without that live key is not charged. These routes accept the payment alone; do not send an API key: GET /offers and GET /recipient-api/offers on both gateways, GET /public-programs ($0.001, active programs, same price as GET /programs), POST /x402-gateway/register-agent ($0.01 USDC on Base; issues a full lsk_ key on the Free plan — 1 agent, 200 API calls/month, 1,000 mint tokens/month, 1.25% mint fee, and all 5 scopes: read, create_program, mint, trade, manage_rewards — when the wallet has no Shopify store plan or paid Pro/Enterprise plan; if the wallet is on a Shopify store plan or paid Pro/Enterprise plan, the key operates strictly within that plan's scope and call limits; the Shopify 45-day store trial uses the approved plan's limits), POST /x402-gateway/mcp-tools/get_platform_info, POST /x402-gateway/mcp-tools/list_marketplace_offers, and POST /x402-gateway/recipient-mcp-tools/list_p2p_offers. A paid request missing required fields or tool arguments returns 400 `missing_fields` before payment and is not charged either. MPP prices REST only. How to get a key: 1. **Look, no key:** `GET https://api.loyalspark.online/x402-gateway/public-programs` is $0.001. Payment alone. Active programs, not your own list. The same call exists on `mpp-gateway`. 2. **Autonomous key ($0.01 on x402, no browser):** `POST https://api.loyalspark.online/x402-gateway/register-agent`. HTTP 402 is $0.01 USDC. Pay it and do not send an API key. When the payer wallet has no Shopify store plan and no paid Pro or Enterprise plan, it receives a full `lsk_…` key on the **Free** plan (1 agent, 200 API calls/month, 1,000 mint tokens/month, 1.25% mint fee, and all 5 scopes: `read`, `create_program`, `mint`, `trade`, `manage_rewards`). If the wallet has a Shopify store plan, that store plan sets the ceiling (Starter: 1 agent, 1,000 calls/month, `read` only; Growth: 3 agents, 10,000 calls/month, `read`, `mint`, `manage_rewards`; Scale: 10 agents, 100,000 calls/month, all 5 scopes, 300 requests a minute). 3. **SIWE or Dashboard key:** dashboard https://loyalspark.online/merchant → AI Agents, or SIWE (when the wallet has a Shopify store plan, a paid Pro/Enterprise plan, or rotates its existing Free agent by name): `POST https://api.loyalspark.online/siwe-nonce` → sign EIP-4361 with domain `loyalspark.online`, URI `https://loyalspark.online`, the exact phrase `Register Loyal Spark merchant agent`, and `Chain ID: 8453` (full example in https://loyalspark.online/.well-known/skills/00-getting-started.md) → `POST https://api.loyalspark.online/agent-register-siwe` `{message, signature, name, scopes}`. Request `mint`, `create_program`, `manage_rewards`, or `trade` here (capped to your plan's allowed scopes). Any write scope includes `read`. The server rejects a missing domain, a domain that does not match the URI hostname, or a host outside loyalspark.online, www.loyalspark.online, loyaltyspark.lovable.app, loyalty-spark.lovable.app, our own preview host, localhost, and 127.0.0.1 (no other `*.lovable.app`), before the nonce is consumed. 4. **Holder `rwk_`:** `POST https://api.loyalspark.online/siwe-nonce` → sign a SIWE message for the holder wallet (allowed domain matching the URI, Chain ID 8453, no special phrase) → `POST https://api.loyalspark.online/recipient-api/register` `{message, signature, name}` → receive `rwk_…` once. Not a merchant key. No paid registration. Not `agent-register-siwe`, not `register-agent`, not `siwe-verify`. Both register responses include `how_to_use` (what the key grants, where it works, first call). A store plan caps that merchant (Starter: 1 agent, 1,000 calls/month, read only; Growth: 3 agents, 10,000 calls/month, read, mint, manage_rewards; Scale: 10 agents, 100,000 calls/month, all 5 scopes, 300 requests a minute). An external agent with no store plan and no paid Pro or Enterprise plan operates on the Free plan (1 agent, 200 calls/month, 1,000 mint tokens/month, 1.25% mint fee, all 5 scopes) once registered via $0.01 `POST /x402-gateway/register-agent`. ## REST API — merchant routes (OpenAPI: 38 authenticated operations under `/agent-api` + public GET /vouchers/status and GET /platform) Base URL: https://api.loyalspark.online/agent-api ### Read Operations (GET) | Endpoint | Price | Description | |----------|-------|-------------| | /platform | free | Public platform and onboarding JSON. No API key. Aliases: /info, /get_platform_info, and GET /agent-api?action=platform or ?action=get_platform_info. `endpoints` includes `mpp_gateway`. | | /me | free | Agent profile + `plan` `{ slug, api_calls_monthly, calls_used, calls_remaining, max_mint_amount_monthly, mint_used, transaction_fee_percent, quota_resets_at, usage_warning }` (requires `lsk_`) | | /workflow/program-status?token_address=0x... | $0.001 | Autonomous planner: current lifecycle step + next_actions[] | | /programs | $0.001 | List active loyalty programs | | /rewards?token_address=0x... | $0.001 | Rewards for a program | | /balance?token_address=0x...&customer_address=0x... | $0.001 | `current_balance` (alias `current`) is the on-chain `balanceOf`; `offchain_ledger_balance` is `customer_tier_status` (written when POST /mint/confirm verifies the recipient Transfer); `balance_basis` says which one `current_balance` is. Tier from the ledger. `address` and `wallet_address` are aliases of `customer_address`. | | /customers?token_address=0x... | $0.002 | Voucher holders, balance-ledger rows, and completed mint recipients | | /mints?token_address=0x...&status=pending | free | Mint intents. `pending` = no transaction hash yet. Not on x402/MPP | | /fee-obligations?status=unpaid | free | This key's fee obligations. `unpaid` means status `pending`. A settled row can still have `customer_ledger: pending_recipient_tx` and `next_action` POST /mint/confirm with `recipient_tx_hash`. Not on x402/MPP | | /store/codes?token_address=0x... | API key | Shopify discount codes for this store. Not on x402/MPP | | /store/channel | API key | Spend method: online, offline, or both. Not on x402/MPP | | /vouchers?token_address=0x... | $0.001 | Voucher list | | https://api.loyalspark.online/agent-api/vouchers/status?code=LOYAL-XXXX | free | Public voucher status. Unknown code is HTTP 200 `{valid:false, found:false, error:"Voucher not found"}`. `valid` is true only when status is `active`. Missing query is HTTP 400. Anonymous callers: 30 checks per minute per IPv4 /24 or IPv6 /48 (HTTP 429 `error_code` `rate_limited`). A live `lsk_` key bypasses that limit. | | /analytics?token_address=0x... | $0.005 | Program metrics | | /offers | $0.001 | Active P2P marketplace offers | | /tx-receipt?tx_hash=0x... | free | Extract token_address from deploy tx (requires `lsk_` key; not unauthenticated) | ### Write Operations (POST) | Endpoint | Price | Scope | Description | |----------|-------|-------|-------------| | /workflow/generate-program-defaults | $0.001 | mint | Propose program name, symbol, economics, and starter rewards from business context | | /programs | $0.01 | mint | Deploy calldata (B20 default, or legacy ERC-20 with token_standard) | | /register-program | $0.01 | mint | Register deployed token (optional cashback_rate, points_per_dollar) | | /update-program-config | $0.005 | mint | Update program cashback_rate and/or points_per_dollar | | /activate-program | $0.01 | mint | Legacy ERC-20 only: unpause + enable minting (no-op for B20) | | /program-status | $0.005 | mint | Update program status | | /rewards | $0.01 | manage_rewards | Create a redeemable reward | | /mint | $0.01 | mint | Fee-first mint calls[] + fee_obligation_id (`recipient_address` accepts `0x` Base address or customer email, or `recipient_email`) | | /batch-mint | API key | mint | Batch-mint to up to 50 recipients (`0x` address or email per item) | | /resolve-recipient | free (API key) | read or mint | Email or `0x` wallet → Base wallet (also GET). `recipient_address` (aliases `address`, `wallet`, `wallet_address`, `customer_address`, `recipient`), `recipient_email` (aliases `email`, `customer_email`), or `identifier`. Full wallet only when you sent the `0x` or the customer has a record with your programs; else `wallet_masked: true` Keyless: `GET /x402-gateway/resolve-recipient` ($0.001 x402, payer = merchant, same masking). | | /mint/confirm | free | mint | Verify fee mint and recipient Transfer (`obligation_id`, `fee_tx_hash`, `recipient_tx_hash`), then write `customer_tier_status` | | /earn | $0.01 | mint | Auto-calculate and mint tokens from purchase amount × cashback rate | | /transfer | $0.005 | mint | Transfer tokens between wallets | | /offers | $0.01 | trade | Create P2P escrow offer | | /accept-offer | $0.01 | trade | Accept a P2P offer (two-phase: reserve → `accepted`, then send `transaction_hash` → `completed`) | | /redeem-reward | $0.01 | read | Redeem reward: verify tx + create voucher | | /vouchers/use | $0.005 | manage_rewards | Mark voucher as used | | /store/codes | API key | manage_rewards | Mark a Shopify code used, or cancel it and return the points. Not on x402/MPP | | /store/channel | API key | manage_rewards or mint | Set spend method to online, offline, or both. Not on x402/MPP | | /cancel-offer | $0.005 | trade | Cancel your P2P offer | | /merchant-profile (GET) | $0.001 | read | Read merchant profile | | /merchant-profile (POST) | $0.005 | manage_rewards | Create or replace merchant profile (business_name required; PUT for partial updates) | | /merchant-profile (PUT) | $0.005 | manage_rewards | Update merchant profile | ### Example: Mint Tokens ```bash curl -X POST \ -H "x-api-key: lsk_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"token_address":"0x...","recipient_address":"0x...","amount":100}' \ https://api.loyalspark.online/agent-api/mint ``` Field name is **`recipient_address`** (not `customer_address`), and it accepts either a `0x` Base wallet address or a customer email address (or pass `recipient_email`), automatically resolving the customer's wallet (including CDP embedded wallets, identity links, and customer profiles) and returning `resolved_recipient_address` when resolved from email. For email or username lookups, wallet fields in the response to a merchant key are masked (e.g. `0x683f…56d2`, with `customer_wallet_masked: true`) unless you supplied the address yourself; the unsigned `calls[]` still target the real wallet. If the email is not registered yet, `POST /mint`, `POST /earn`, `POST /batch-mint`, MCP `mint_loyalty_tokens`, MCP `earn_points`, and `agent-wallet` `server_mint` credit virtual loyalty points in `store_points_ledger` (`status: "virtual_pending_signup"`, `mint_status: "unminted"`, `calls: []`) which automatically bind to the customer's Base wallet and convert to on-chain B20 tokens when they sign in. `GET /balance` also accepts `customer_email` / `recipient_email` and returns `virtual_pending_balance` for unregistered emails. `recipient` is a legacy alias accepted by REST and MCP. Response returns a **fee-first `calls[]` bundle** with Builder Code for onchain execution: `calls[0]` (`purpose: "protocol_fee"`) mints the plan fee % to the platform fee wallet, `calls[1]` (`purpose: "recipient_mint"`) mints the full amount to the customer. Send them in that order, or atomically via EIP-5792 `wallet_sendCalls`. Then settle the fee obligation: ```bash curl -X POST \ -H "x-api-key: lsk_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"obligation_id":"","fee_tx_hash":"0x..."}' \ https://api.loyalspark.online/agent-api/mint/confirm ``` The fee is charged **in the loyalty tokens being minted**, not in USDC. The token contract does not enforce it — once 5 or more obligations stay unpaid for over 60 minutes, further mints return HTTP 402. ### Example: GET /tx-receipt (free with `lsk_` key) — extract token_address after deploy Call this right after the deploy transaction is confirmed on Base; it is the bridge between `POST /programs` and `POST /register-program`. ```bash curl -H "x-api-key: lsk_YOUR_KEY" \ "https://api.loyalspark.online/agent-api/tx-receipt?tx_hash=0xDEPLOY_TX_HASH" ``` Response: ```json { "tx_hash": "0xDEPLOY_TX_HASH", "status": "success", "token_address": "0xYourNewLoyaltyToken", "block_number": 24500001, "gas_used": 512345, "logs_count": 3 } ``` Rules: - `tx_hash` must match `^0x[a-fA-F0-9]{64}$`, otherwise HTTP 400. - HTTP 404 `Transaction not found or not yet confirmed` means the tx is still pending — retry every ~3 s instead of re-deploying. - `status: "failed"` means the deploy reverted; do not register that address. - Works for both B20 (`B20Created`) and legacy ERC-20 (`LoyaltyTokenCreated`) deploys. - Free route, but it still requires a valid `lsk_` key. Over x402 the price is `0`: `curl "https://api.loyalspark.online/x402-gateway/tx-receipt?tx_hash=0x..." -H "x-api-key: lsk_YOUR_KEY"` ### Example: POST /update-program-config ($0.005) — tune earn economics Changes how many points a purchase generates: `points = amount × (cashback_rate / 100) × points_per_dollar`. Database-only, no onchain transaction. ```bash curl -X POST \ -H "x-api-key: lsk_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"token_address":"0xYourLoyaltyToken","cashback_rate":5,"points_per_dollar":10}' \ https://api.loyalspark.online/agent-api/update-program-config ``` Response: ```json { "program": { "id": "uuid", "name": "Coffee Club", "symbol": "BREW", "token_address": "0xYourLoyaltyToken", "status": "active", "cashback_rate": 5, "points_per_dollar": 10, "expiration_date": "2027-01-01T00:00:00Z", "created_at": "2026-01-01T00:00:00Z" }, "message": "Program economics updated" } ``` Rules: - Scope `mint` or `create_program`; the program must belong to the key's wallet (otherwise HTTP 404). - Send at least one of `cashback_rate` / `points_per_dollar` — sending neither returns HTTP 400. - Both fields are optional individually, so you can raise cashback without touching the points rate. - New values apply to subsequent `POST /earn` calls only; already minted balances are untouched. - Over x402, send the live `lsk_` on the same retry as the payment. A payment without that key is not charged: `curl -X POST https://api.loyalspark.online/x402-gateway/update-program-config -H "x-api-key: lsk_YOUR_KEY" -H "Content-Type: application/json" -d '{...}'` → HTTP 402 with the USDC challenge, then repeat with the `PAYMENT-SIGNATURE` header (legacy `X-PAYMENT`). ## MCP Server — 42 Tools (Merchant, plus 2 admin-only) URL: https://api.loyalspark.online/loyalty-mcp Transport: Streamable HTTP Auth: x-api-key header ### Tools 1. `get_platform_info` — Protocol metadata and capabilities 2. `get_my_profile` — Agent identity, plan, wallet 3. `generate_program_defaults` — Return field_catalog, workflow.next_actions, and non-binding examples 4. `get_program_workflow_status` — Current merchant program lifecycle step + next_actions[] 5. `list_loyalty_programs` — All active programs 6. `create_loyalty_program` — Deploy calldata for new token 7. `register_loyalty_program` — Register deployed token (optional cashback_rate, points_per_dollar) 8. `activate_loyalty_program` — Activation calldata 9. `update_program_status` — Update status in DB 10. `update_program_config` — Update cashback_rate / points_per_dollar in DB 11. `list_rewards` — Rewards for a program (with redemption metrics) 12. `create_reward` — Create redeemable reward 13. `mint_loyalty_tokens` — Fee-first mint calls[] + fee_obligation_id 14. `transfer_loyalty_tokens` — Transfer calldata 15. `earn_points` — Auto-calculate and mint tokens from purchase amount (cashback) 16. `confirm_mint_fee` — Settle protocol fee after mint/earn (lsk_-only; not x402-priced) 17. `list_mints` — Mint intents for this key (status=pending|completed). lsk_-only; not x402-priced 18. `list_fee_obligations` — This key's fee obligations. lsk_-only; not x402-priced 19. `get_token_balance` — Balance and tier info 20. `get_program_analytics` — Metrics and performance 21. `list_marketplace_offers` — P2P offers 22. `redeem_reward` — Redeem reward: verify tx + create voucher 23. `use_voucher` — Mark voucher as used 24. `check_voucher_status` — Voucher status lookup for the key owner's store (lsk_ required) 25. `get_platform_stats` — Global platform statistics (admin-only; direct MCP only, not sold pay-per-call) 26. `cancel_stale_offers` — Cancel old marketplace offers (admin-only; direct MCP only, not sold pay-per-call) 27. `create_personalized_offer` — Create targeted offer for a customer 28. `update_reward_status` — Activate/deactivate rewards 29. `export_customers` — Export customer data for analytics 30. `list_store_discount_codes` — Shopify discount codes plus how customers spend points (API key; not x402-priced) 31. `update_store_discount_code` — Mark a Shopify code used, or cancel it and return the points (API key; not x402-priced) 32. `set_store_sales_channel` — Set spend method: online, offline, or both (API key; not x402-priced) 33. `send_report` — Submit report to developer dashboard 34. `list_my_reports` — View previously submitted reports 35. `update_report_status` — Update report status (reviewed/done) 36. `delete_report` — Delete an outdated report 37. `create_gift_certificate` — Issue gift / welcome certificate (LOYAL-XXXXXX), single or batch up to 100 38. `list_gift_certificates` — List certificates issued by your merchant (with status + redemption info) 39. `revoke_gift_certificate` — Revoke an active gift certificate (active → revoked) 40. `mark_gift_certificate_minted` — Mark a claimed certificate as minted with the on-chain mint tx (pending_mint → redeemed) 41. `bazaar_discover_resources` — Discover x402-priced HTTPS endpoints on Bazaar 42. `bazaar_discover_mcp_servers` — Search the CDP Bazaar MCP catalog (search_resources) for x402-payable tools 43. `bazaar_probe_x402` — Inspect the 402 payment requirements of a URL (keyless, 20/min per IP) 44. `bazaar_pay_and_call` — Pay + call an x402 endpoint using the agent's CDP MPC wallet (spend cap ≤ 10 USDC/call) ## Recipient MCP Server — 20 Tools (Holder, `rwk_`) URL: https://api.loyalspark.online/recipient-loyalty-mcp 1. `get_recipient_profile` — Bound wallet + agent metadata 2. `list_my_loyalty_balances` — All loyalty token balances for the wallet 3. `get_my_loyalty_balance` — Balance + tier for one token 4. `get_reward_workflow_status` — Current reward redemption step + next_actions[] 5. `prepare_reward_redemption` — Transfer calldata for reward cost + workflow metadata 6. `prepare_loyalty_token_transfer` — B20 token transfer calldata (ERC-20 compatible) (holder → any address) 7. `list_rewards_for_program` — Rewards available where you have activity 8. `list_my_vouchers` — Your vouchers 9. `redeem_my_reward` — Redeem reward via on-chain transfer tx hash 10. `list_p2p_offers` — Active P2P swap offers 11. `create_p2p_offer` — Record P2P swap intent (escrow on-chain) 12. `accept_p2p_offer` — Reserve a P2P swap by id (status `accepted`; escrow fill completes it) 13. `cancel_p2p_offer` — Cancel your own P2P offer 14. `lookup_gift_certificate` — Preview a gift certificate by code (LOYAL-XXXXXX) 15. `claim_gift_certificate` — Claim by code; binds it to your wallet (active → pending_mint) 16. `list_my_gift_certificates` — Certificates claimed by your wallet 17. `bazaar_discover_resources` — Discover x402-priced HTTPS endpoints 18. `bazaar_discover_mcp_servers` — Search the CDP Bazaar MCP catalog (search_resources) for x402-payable tools 19. `bazaar_probe_x402` — Inspect the 402 payment requirements of a URL (keyless, 20/min per IP) 20. `bazaar_pay_and_call` — Pay + call an x402 endpoint using the recipient's delegated CDP MPC wallet (opt-in via /customer settings; spend cap ≤ 10 USDC/call) ### MCP Configuration for Claude/Cursor ```json { "mcpServers": { "loyal-spark": { "command": "npx", "args": ["-y", "mcp-remote", "https://api.loyalspark.online/loyalty-mcp"], "env": { "HTTP_HEADER_x-api-key": "lsk_YOUR_KEY" } } } } ``` ## Recipient REST API (`rwk_`) — 14 Routes Base URL: https://api.loyalspark.online/recipient-api · Auth: `x-api-key: rwk_…` | Method | Path | Price | Description | |--------|------|-------|-------------| | GET | /me | free | Recipient agent profile and wallet | | GET | /balances | $0.001 | All loyalty balances for the bound wallet | | GET | /balance?token_address=0x… | $0.001 | One-token balance and tier | | GET | /rewards?token_address=0x… | $0.001 | Rewards catalog + `has_engagement` (`true` iff `customer_tier_status` OR `token_mint_history` for wallet+token; required for redeem; ≠ `balanceOf`) | | GET | /vouchers | $0.001 | Vouchers issued to this wallet | | GET | /offers | $0.001 | P2P marketplace offers | | GET | /workflow/reward-status?token_address=0x… | $0.001 | Autonomous planner: current reward redemption step + next_actions[] (includes `has_engagement`) | | POST | /register | free | One-time wallet registration (after SIWE) | | POST | /prepare-transfer | $0.005 | B20/ERC-20 compatible transfer calldata (holder → any address) | | POST | /workflow/prepare-reward-redemption | $0.005 | Autonomous planner: transfer calldata for reward cost + workflow metadata | | POST | /redeem-reward | $0.01 | Redeem a reward via on-chain tx hash (requires `has_engagement:true`) | | POST | /offers | $0.01 | Create a P2P swap intent (escrow) | | POST | /accept-offer | $0.01 | Accept a P2P offer (atomic swap) | | POST | /cancel-offer | $0.005 | Cancel your own P2P offer | ## Payment Gateways ### MPP (Machine Payments Protocol) - Gateway: https://api.loyalspark.online/mpp-gateway - **REST-only (39 routes).** MCP is not priced on MPP — use x402 for paid MCP. - Currency: pathUSD on Tempo (also accepts USDC 0x20C0...b50) - Flow: Request → 402 challenge → pay → retry with credential - SDK: `npm install -g mppx` ### x402 (Coinbase Protocol) — v2 exact - Gateway: https://api.loyalspark.online/x402-gateway - **REST+MCP (89 paid resources).** - Currency: exact USDC on Base (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) · network CAIP-2 `eip155:8453` - The current gateway does not expose `upto`, partial capture, void, refund, payout, or split operations. - **Paid MCP:** `POST …/x402-gateway/mcp-tools/` — JSON-RPC `tools/call`. Merchant read tools and all holder tools on `recipient-mcp-tools` accept payment alone (paying wallet = caller; API key optional). Do not send an API key on `get_platform_info`, `list_marketplace_offers`, or `list_p2p_offers`. Write tools still need `x-api-key: lsk_…` / `rwk_…` with the payment. Tool ids + argument schemas: `extensions.bazaar.inputSchema` in each 402 response and https://api.loyalspark.online/.well-known/x402. Bazaar: 402 body includes `extensions.bazaar` for MCP routes. - Facilitator (Base mainnet production): Coinbase CDP `https://api.cdp.coinbase.com/platform/v2/x402` (gateway uses CDP JWT when configured). Public facilitator reference: https://x402.org/facilitator/supported (public facilitator is Sepolia-only for v2 `exact`; Base mainnet uses CDP) - SDK: `@x402/fetch`, `@x402/evm` - Spec: https://github.com/coinbase/x402 ## Base MCP Custom Plugin (`send_calls`-ready calldata) - Base URL: `https://api.loyalspark.online/agent-prepare` - Purpose: GET endpoints returning EIP-5792 `send_calls`-compatible batches with Builder Code `bc_wdmnog7m` (ERC-8021) already baked into the calldata. Consumed by Base MCP custom plugins so Base Account signs and broadcasts. - Auth: header `x-api-key: lsk_…` (merchant actions) or `rwk_…` (holder actions); query-string `api_key` is not supported. - Response shape: `{ chainId: 8453, description, transactions: [{ to, data, value }], builder_code: "bc_wdmnog7m" }`. | Method | Path | Auth | Description | |--------|------|------|-------------| | GET | /create-program | lsk_ | Deploy loyalty token (B20 default) | | GET | /activate-program | lsk_ | Activate a deployed program | | GET | /mint | lsk_ | Mint tokens to a wallet | | GET | /transfer | lsk_ | Merchant loyalty token transfer | | GET | /recipient-transfer | rwk_ | Holder loyalty token transfer | | GET | /recipient-approve | rwk_ | Holder token approve | Plugin spec: https://loyalspark.online/skills/loyal-spark/plugins/loyal-spark.md ## Agent Wallets Agents can create Coinbase CDP MPC wallets for autonomous onchain operations: - No private keys to manage - Server-side transaction signing - Support for `use_agent_wallet: true` in program creation / mint flows - Endpoint: `POST https://api.loyalspark.online/agent-wallet` with `x-api-key: lsk_…` (separate Edge Function, not part of agent-api) ## Subscription plans Agent API plans and human portal plans are different products. Amounts are in the Costs table at the top of this file (Free / Pro / Enterprise for agents; Starter $39 / Growth $79 / Scale $149 for the portal). **Buy agent Pro/Enterprise with an `lsk_` key:** `POST https://api.loyalspark.online/verify-agent-plan-payment` with `x-api-key: lsk_…`. Actions: `get_payment_info` (`{ product: "agent" }`) then `verify_payment` (`{ product: "agent", plan_slug: "pro"|"enterprise", transaction_hash }`). Human UI: https://loyalspark.online/for-agents/subscribe. `GET /agent-api/me` returns the live `plan` usage object after upgrade. Access control: keyed REST and MCP calls are scoped by Postgres **row-level security (RLS)** to the owner wallet behind the `lsk_` / `rwk_` key. On x402 and MPP, every recipient-api route, the merchant GET reads (programs, rewards, balance, customers, vouchers, analytics, merchant-profile, workflow/program-status), the merchant read MCP tools (list_loyalty_programs, list_rewards, get_token_balance, get_program_analytics, export_customers, and similar) and the holder MCP tools accept the payment alone: the paying wallet is the caller (holder on recipient routes, merchant owner on merchant reads). Other routes (mint, create program, create rewards, trade, bazaar tools) need a live lsk_ (merchant) or rwk_ (holder) key on the same request as the payment; a payment without that live key is not charged. These routes accept the payment alone; do not send an API key: GET /offers and GET /recipient-api/offers on both gateways, GET /public-programs ($0.001, active programs, same price as GET /programs), POST /x402-gateway/register-agent ($0.01 USDC on Base; issues a full lsk_ key on the Free plan — 1 agent, 200 API calls/month, 1,000 mint tokens/month, 1.25% mint fee, and all 5 scopes: read, create_program, mint, trade, manage_rewards — when the wallet has no Shopify store plan or paid Pro/Enterprise plan; if the wallet is on a Shopify store plan or paid Pro/Enterprise plan, the key operates strictly within that plan's scope and call limits; the Shopify 45-day store trial uses the approved plan's limits), POST /x402-gateway/mcp-tools/get_platform_info, POST /x402-gateway/mcp-tools/list_marketplace_offers, and POST /x402-gateway/recipient-mcp-tools/list_p2p_offers. Payment: On-chain USDC transfer on Base, verified automatically. This covers **subscriptions only**. **Mint fee (separate, not USDC).** `fee_amount = amount × fee_percent / 100` in the merchant's **own loyalty tokens** — a second `mint(address,uint256)` to `0x5cc0Aa9ed773F413f81f78a62F2e94109CE26205`. Rates: Free 1.25%, Pro 0.5%, Enterprise 0.25%. It is not USDC, ETH, or fiat, and it is independent of the per-call x402 / MPP prices. The token contract has no `mintWithFee`, so the fee is tracked off-chain as an obligation per prepared mint; 5+ obligations unpaid for over 60 minutes block further mints with HTTP 402. Settle with `POST https://api.loyalspark.online/agent-api/mint/confirm` or MCP `confirm_mint_fee`. **Gas.** Unsigned deploy and mint calldata use value `0x0`. The signer pays Base (8453) gas in ETH. **Fund ETH first:** send about 0.00001 ETH on Base to the signing wallet before broadcasting (estimate with buffer, not a live quote: a B20 deploy is ≈253k gas; deploy + 2 mints cost ≈0.0000023 ETH). The x402 USDC fee does not cover gas, and the API does not send ETH to wallets. Every response with unsigned calls includes `gas.eth_needed` and `gas.fund_eth_first`. `https://api.loyalspark.online/paymaster-proxy` sponsors only human Coinbase embedded smart accounts in the web app, for zero-ETH-value calls to the B20 factory, the legacy factory, the P2P escrow, or a non-expired registered loyalty token, while `gas_settings.sponsor_smart_wallets` is on and the monthly budget allows it. Agents, external wallets, and CDP server wallets (`cdp_mpc`) pay their own gas. The merchant MCP server exposes 43 tools to non-admin keys (45 registered) (`list_mints`, `list_fee_obligations`). `tools/list` on `https://api.loyalspark.online/loyalty-mcp` omits admin-only `get_platform_stats` and `cancel_stale_offers` unless the key owner is a platform admin (43 tools with no key). Report tools stay listed and are marked internal. Scopes are checked on `tools/call`. Paid x402 and MPP price 32 of those tools (never the two admin-only tools). ## Smart Contracts New programs default to **B20** (Base native factory `0xB20f…`). Legacy Loyal Spark ERC-20 factory remains for `token_standard: "erc20"`. Details: `docs/development/LOYALTY_PROGRAM_CONTRACTS.md`. | Role | Address | Chain | |------|---------|-------| | B20 Factory (default deploy) | 0xB20f000000000000000000000000000000000000 | Base | | LoyaltyTokenFactory (legacy) | 0x5F3DdBa12580CFdc6016258774cCc19C4250dA80 | Base | | LoyalSparkERC20 (legacy impl) | 0xe6BA426C9c51281B929a17444De02c65815E27C3 | Base | | LoyaltyTokenEscrow | 0xA569C95AfC1BCF381c48BcF336ED9D2c014bcdDF | Base | | Builder Code | bc_wdmnog7m (ERC-8021) | Base | ## P2P Marketplace (Escrow) Atomic token swaps via smart contract: 1. Creator approves escrow for offer tokens 2. Creator calls createOffer() — tokens locked 3. Accepter approves escrow for request tokens 4. Accepter calls fillOffer() — atomic swap 5. Alternative: cancelOffer() returns tokens Protocol fee: 0.5% on completed swaps. ## Skills (Step-by-Step Guides) 16 structured Markdown guides at `/.well-known/skills/`: - 00: Getting Started (register, API key, first request) - 01: Create Loyalty Program (B20 default, or legacy ERC-20) - 02: Mint Tokens - 03: Transfer Tokens - 04: Manage Rewards - 05: Balance and Tiers - 06: Marketplace Trading - 07: Analytics & CRM - 08: Referrals - 09: Vouchers - 10: Server Wallets (CDP MPC) - 11: Earn Points (cashback from purchases) - 12: Gift Certificates (LOYAL-XXXXXX welcome / gift codes, batch up to 100) - 13: Endpoint Workflows - 14: B20 Native Spec (Beryl) - 15: Payment Scenarios (x402 exact, MPP, subscriptions) ## Tags loyalty, rewards, defi, base, erc20, ai-agents, mcp, rest-api, mpp, x402, cdp, mpc-wallet, p2p-marketplace, escrow, onchain ## Contact - Website: https://loyalspark.online - Docs: https://loyalspark.online/api-docs - Email: admin@loyalspark.online - Twitter: https://x.com/Loyal_Spark