{
  "name": "Loyal Spark",
  "description": "Onchain loyalty protocol on Base. New programs deploy as native B20 Asset programs by default; legacy ERC-20 programs remain supported. Two agent personas: MERCHANT (lsk_, OpenAPI 38 authenticated /agent-api operations + 2 public (GET /vouchers/status and GET /platform) + 43 MCP tools at /loyalty-mcp) creates programs, registers and activates them when needed, manages rewards, mints tokens, runs P2P trading, gift certificates (LOYAL-XXXXXX), CDP MPC wallets, and POST /earn cashback. RECIPIENT (rwk_, 14 REST routes at /recipient-api + 20 MCP tools at /recipient-loyalty-mcp) holds tokens, redeems rewards, P2P swaps, claims gift certificates, and prepares loyalty token transfers. Pay-per-call via MPP (REST-only, 39 routes, pathUSD/USDC on Tempo) or x402 v2 (REST+MCP, 89 paid resources, USDC on Base) with Coinbase Bazaar discovery metadata.",
  "url": "https://loyalspark.online",
  "version": "2.3.3",
  "protocol": "mcp+rest",
  "protocolNote": "Documents MCP + REST. A2A message/send is not implemented.",
  "openapi": "https://loyalspark.online/openapi.json",
  "openapi_lite": "https://loyalspark.online/openapi-lite.json",
  "capabilities": [
    "create_loyalty_program",
    "mint_tokens",
    "earn_points_from_purchases",
    "manage_rewards",
    "marketplace_trading",
    "customer_analytics",
    "tier_management",
    "referral_programs",
    "voucher_management",
    "server_wallet_creation",
    "autonomous_transactions"
  ],
  "response_contract": {
    "rule": "Every JSON error has error_code, a one-line error, charged (boolean), retry_safe when not charged, and next_steps.action + next_steps.request. Follow next_steps; do not guess.",
    "unpaid_402": "HTTP 402 payment_required includes accepts (price, description, schemas), example_input, key_required, charged:false. If key_required, next_steps.action is get_api_key_then_pay (register-agent $0.01 or SIWE) BEFORE signing payment.",
    "mcp_tool_error": "JSON-RPC result.isError:true (HTTP 200). Gateway prechecks also set top-level error_code, charged:false, next_steps, and X-LoyalSpark-Error-Code.",
    "docs": "https://loyalspark.online/llms.txt#every-response-you-can-get-and-what-to-do"
  },
  "workflow_hints": {
    "rule": "Many Loyal Spark actions are multi-step workflows, not single endpoint calls.",
    "machine_contract": "Lifecycle-sensitive REST and MCP responses include workflow.current_step, completed_steps, next_actions, prerequisites, field_catalog, and continuation_context. External agents choose all parameter values.",
    "required_docs": [
      "https://loyalspark.online/.well-known/skills/00-getting-started.md",
      "https://loyalspark.online/.well-known/skills/13-endpoint-workflows.md"
    ],
    "merchant_program_lifecycle": [
      "Choose program name, token symbol, and expiration period",
      "Call POST /programs or create_loyalty_program to get deploy calldata",
      "Broadcast the onchain deploy transaction",
      "Extract token_address from B20Created or GET /tx-receipt",
      "Call POST /register-program or register_loyalty_program",
      "If token_standard is erc20, also call activate-program and then program-status active",
      "Create at least one reward before large-scale minting",
      "Only then mint tokens or use earn_points"
    ],
    "voucher_flow": [
      "Transfer tokens onchain first",
      "Then call redeem-reward with transaction_hash",
      "Then use voucher via vouchers/use when consumed"
    ]
  },
  "authentication": {
    "type": "api_key",
    "header": "x-api-key",
    "prefix": "lsk_",
    "registration_url": "https://api.loyalspark.online/x402-gateway/register-agent",
    "registration_note": "Autonomous lsk_ key: POST this URL. HTTP 402 asks for $0.01 USDC on Base. Pay it and do not send an API key. If the payer wallet has no Shopify store plan and no paid Pro/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, all 5 scopes: read, create_program, mint, trade, manage_rewards). If the wallet has a Shopify store plan, scopes and calls follow that store plan (Starter $39: 1 agent, 1,000 calls/month, read only; Growth $79: 3 agents, 10,000 calls/month, read, mint, manage_rewards; Scale $149: 10 agents, 100,000 calls/month, all 5 scopes, 300 rpm). First look without a key: GET https://api.loyalspark.online/x402-gateway/public-programs for $0.001.",
    "dashboard_registration_url": "https://loyalspark.online/merchant",
    "dashboard_registration_note": "Humans: sign in with Google, email (Coinbase), or a Web3 wallet, then AI Agents \u2192 Register Agent",
    "siwe_registration_url": "https://api.loyalspark.online/agent-register-siwe",
    "siwe_registration_note": "SIWE registration/rotation: POST /siwe-nonce, sign an EIP-4361 message with the exact phrase 'Register Loyal Spark merchant agent' and Chain ID 8453, then POST {message, signature, agent_name} (alias name, max 64 characters) to siwe_registration_url. Requires a Shopify store plan, a paid Pro/Enterprise plan, or rotates an existing Free agent by name; otherwise returns HTTP 402 error_code payment_required (use POST /x402-gateway/register-agent for $0.01 USDC to get a Free plan key). Doc: https://loyalspark.online/llms-full.txt",
    "key_types": [
      {
        "prefix": "lsk_",
        "role": "MERCHANT agent. Paying $0.01 at POST /x402-gateway/register-agent issues a full lsk_ key on the Free plan (all 5 scopes: read, create_program, mint, trade, manage_rewards; 200 calls/month, 1,000 mint tokens/month, 1.25% mint fee) when the wallet has no store or paid agent plan, or scopes matching the wallet's active store/agent plan.",
        "registration_url": "https://api.loyalspark.online/x402-gateway/register-agent",
        "registration_note": "Autonomous key: POST this URL, pay the $0.01 USDC 402, do not send an API key. Or use dashboard_registration_url / siwe_registration_url.",
        "works_at": [
          "https://api.loyalspark.online/agent-api",
          "https://api.loyalspark.online/loyalty-mcp"
        ],
        "first_call": "GET /programs with header x-api-key: lsk_..."
      },
      {
        "prefix": "rwk_",
        "role": "RECIPIENT agent (token holder) \u2014 reads own balances and vouchers, redeems rewards, trades P2P, claims gift certificates, prepares loyalty token transfers",
        "works_at": [
          "https://api.loyalspark.online/recipient-api",
          "https://api.loyalspark.online/recipient-loyalty-mcp"
        ],
        "registration_url": "https://api.loyalspark.online/recipient-api/register",
        "registration_note": "Autonomous agents: POST /siwe-nonce, sign an EIP-4361 message for the holder wallet (no special phrase), then POST to registration_url with {message, signature, name}",
        "first_call": "GET /balances with header x-api-key: rwk_..."
      }
    ],
    "docs_url": "https://loyalspark.online/api-docs"
  },
  "api": {
    "base_url": "https://api.loyalspark.online/agent-api",
    "authentication_summary": "Direct agent-api: all routes except public GET /vouchers/status and GET /platform require header x-api-key: lsk_.... GET /info and GET /get_platform_info are aliases of GET /platform. 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 \u2014 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 \u2014 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.",
    "endpoints": [
      {
        "method": "GET",
        "path": "/platform",
        "scope": "none (public)",
        "description": "Public platform and onboarding JSON. No API key. Aliases: GET /info, GET /get_platform_info, and GET /agent-api?action=platform. endpoints map includes x402_gateway and mpp_gateway."
      },
      {
        "method": "GET",
        "path": "/me",
        "scope": "authenticated",
        "description": "Get agent profile, permissions, wallet info, and plan {slug, api_calls_monthly, calls_used, calls_remaining, max_mint_amount_monthly, mint_used, transaction_fee_percent, quota_resets_at, usage_warning}. Free with lsk_."
      },
      {
        "method": "POST",
        "path": "/workflow/generate-program-defaults",
        "scope": "read or mint or create_program",
        "description": "Return field_catalog, workflow.next_actions, and non-binding examples for program name, symbol, economics, and starter rewards. Does not fill values for the agent.",
        "body": {
          "business_name": "Coffee Corner",
          "category": "cafe",
          "preferred_style": "playful",
          "locale": "en"
        }
      },
      {
        "method": "GET",
        "path": "/workflow/program-status",
        "scope": "read",
        "description": "Return machine-readable merchant workflow state, next actions, and prerequisites for the most recent or specified program."
      },
      {
        "method": "GET",
        "path": "/programs",
        "scope": "read",
        "description": "List all active loyalty programs"
      },
      {
        "method": "POST",
        "path": "/programs",
        "scope": "mint or create_program",
        "description": "Start a program deploy workflow. External agents must pass name and symbol. Returns workflow metadata for next steps.",
        "body": {
          "name": "Coffee Corner Loyalty",
          "symbol": "COFF",
          "token_standard": "b20",
          "expiration_days": 365,
          "auto_generate": false
        }
      },
      {
        "method": "POST",
        "path": "/register-program",
        "scope": "mint or create_program",
        "description": "Register a deployed token as a loyalty program in the database. B20 becomes active immediately; legacy ERC-20 needs activation flow next.",
        "body": {
          "name": "Coffee Rewards",
          "symbol": "COFFEE",
          "token_address": "0x...",
          "expiration_days": 365,
          "cashback_rate": 5,
          "points_per_dollar": 1
        }
      },
      {
        "method": "POST",
        "path": "/update-program-config",
        "scope": "mint or create_program",
        "description": "Update default cashback_rate and/or points_per_dollar for a program you own",
        "body": {
          "token_address": "0x...",
          "cashback_rate": 7.5,
          "points_per_dollar": 2
        }
      },
      {
        "method": "POST",
        "path": "/activate-program",
        "scope": "mint or create_program",
        "description": "Activation step for legacy ERC-20 programs. For B20 programs this is a no-op because they are active by construction.",
        "body": {
          "token_address": "0x..."
        }
      },
      {
        "method": "POST",
        "path": "/program-status",
        "scope": "mint or create_program",
        "description": "Update program status in database after on-chain activation/pause",
        "body": {
          "token_address": "0x...",
          "status": "active"
        }
      },
      {
        "method": "GET",
        "path": "/rewards",
        "scope": "read",
        "description": "List rewards for a loyalty program"
      },
      {
        "method": "POST",
        "path": "/rewards",
        "scope": "manage_rewards",
        "description": "Create a new reward redeemable with loyalty tokens"
      },
      {
        "method": "POST",
        "path": "/mint",
        "scope": "mint",
        "description": "Prepare a fee-first mint: returns calls[] (protocol fee first, then recipient) plus fee_obligation_id. Submit onchain then confirm. Prefer recipient_address (accepts a 0x Base wallet address or customer email, or pass recipient_email to automatically resolve the customer wallet); recipient is a legacy alias.",
        "body": {
          "token_address": "0x...",
          "recipient_address": "0x...",
          "amount": 100
        }
      },
      {
        "method": "POST",
        "path": "/mint/confirm",
        "scope": "mint",
        "description": "Verify the protocol-fee mint on Base and settle the pending fee obligation. Required after /mint or /earn when fee_amount > 0.",
        "body": {
          "obligation_id": "uuid",
          "fee_tx_hash": "0x...",
          "recipient_tx_hash": "0x..."
        }
      },
      {
        "method": "GET",
        "path": "/mints",
        "scope": "read or mint",
        "description": "List mint intents for this key. Query status=pending|completed and optional token_address. No per-call charge with an lsk_ key. Not on x402 or MPP."
      },
      {
        "method": "GET",
        "path": "/fee-obligations",
        "scope": "read or mint",
        "description": "This key's fee obligations. status=unpaid means pending. A settled row can still need POST /mint/confirm. No per-call charge with an lsk_ key. Not on x402 or MPP."
      },
      {
        "method": "POST",
        "path": "/earn",
        "scope": "mint",
        "description": "Auto-calculate and mint tokens from purchase amount using program's cashback rate. POS-friendly alternative to /mint.",
        "body": {
          "token_address": "0x...",
          "customer_address": "0x...",
          "purchase_amount": 50,
          "cashback_rate": 5
        }
      },
      {
        "method": "POST",
        "path": "/transfer",
        "scope": "mint",
        "description": "Transfer loyalty tokens between wallets. Returns calldata with Builder Code for onchain execution.",
        "body": {
          "token_address": "0x...",
          "to": "0x...",
          "amount": 100
        }
      },
      {
        "method": "GET",
        "path": "/balance",
        "scope": "read",
        "description": "Check token balance for a wallet"
      },
      {
        "method": "GET",
        "path": "/customers",
        "scope": "read",
        "description": "List customers with token balances and activity"
      },
      {
        "method": "GET",
        "path": "/analytics",
        "scope": "read",
        "description": "Get program analytics and performance metrics"
      },
      {
        "method": "GET",
        "path": "/vouchers",
        "scope": "read",
        "description": "List vouchers with optional filters (token_address, status, limit)"
      },
      {
        "method": "GET",
        "path": "/vouchers/status",
        "scope": "none (public)",
        "description": "Check voucher status by code or ID. No API key required.",
        "query_params": {
          "code": "LOYAL-XXXX-XXXX-XXXX-XXXX"
        }
      },
      {
        "method": "POST",
        "path": "/redeem-reward",
        "scope": "read",
        "description": "Redeem a reward: verify on-chain token transfer tx and create a voucher",
        "body": {
          "reward_id": "uuid",
          "customer_address": "0x...",
          "transaction_hash": "0x..."
        }
      },
      {
        "method": "POST",
        "path": "/vouchers/use",
        "scope": "manage_rewards",
        "description": "Mark a voucher as used (redeemed by customer). Merchant-only.",
        "body": {
          "voucher_code": "LOYAL-XXXX-XXXX-XXXX-XXXX"
        }
      },
      {
        "method": "GET",
        "path": "/tx-receipt",
        "scope": "authenticated",
        "description": "Extract token_address from a deploy transaction hash (requires API key; not public)",
        "query_params": {
          "tx_hash": "0x..."
        }
      },
      {
        "method": "GET",
        "path": "/offers",
        "scope": "read or trade",
        "description": "List active P2P escrow offers for token trading"
      },
      {
        "method": "POST",
        "path": "/offers",
        "scope": "trade",
        "description": "Create a new P2P escrow offer. Returns escrow contract calldata for atomic swap.",
        "body": {
          "offer_token_address": "0x...",
          "offer_amount": 100,
          "request_token_address": "0x...",
          "request_amount": 50
        }
      },
      {
        "method": "POST",
        "path": "/accept-offer",
        "scope": "trade",
        "description": "Accept a P2P offer. Returns escrow contract calldata for fillOffer.",
        "body": {
          "offer_id": "uuid"
        }
      },
      {
        "method": "POST",
        "path": "/cancel-offer",
        "scope": "trade",
        "description": "Cancel your own P2P offer. Returns escrow contract calldata for cancelOffer.",
        "body": {
          "offer_id": "uuid"
        }
      },
      {
        "method": "GET",
        "path": "/merchant-profile",
        "scope": "read",
        "description": "Get merchant business profile (business_name, category, branding) for the agent's bound wallet.",
        "query_params": {
          "use_agent_wallet": "true | false"
        }
      },
      {
        "method": "POST",
        "path": "/merchant-profile",
        "scope": "mint or create_program",
        "description": "Upsert merchant business profile (business_name, category, logo_url, description, website, location).",
        "body": {
          "business_name": "Coffee Co",
          "category": "cafe",
          "logo_url": "https://...",
          "description": "...",
          "website": "https://...",
          "location": "Berlin",
          "use_agent_wallet": false
        }
      },
      {
        "method": "PUT",
        "path": "/merchant-profile",
        "scope": "mint or create_program",
        "description": "Update the merchant business profile for the agent's bound wallet.",
        "body": {
          "business_name": "Coffee Co",
          "category": "cafe",
          "logo_url": "https://...",
          "description": "...",
          "website": "https://...",
          "location": "Berlin"
        }
      },
      {
        "method": "GET",
        "path": "/store/codes",
        "scope": "read",
        "description": "List Shopify discount codes for this merchant's store. Optional query token_address. API key only: not on the x402 or MPP gateway.",
        "query_params": {
          "token_address": "0x..."
        }
      },
      {
        "method": "POST",
        "path": "/store/codes",
        "scope": "manage_rewards",
        "description": "Mark a Shopify discount code used, or cancel it and return the loyalty points. API key only: not on the x402 or MPP gateway.",
        "body": {
          "redemption_id": "uuid",
          "action": "use"
        }
      },
      {
        "method": "GET",
        "path": "/store/channel",
        "scope": "read",
        "description": "How this store's customers spend points: online (checkout code), offline (voucher at the register), or both. API key only."
      },
      {
        "method": "POST",
        "path": "/store/channel",
        "scope": "manage_rewards or mint",
        "description": "Set how customers spend points. API key only: not on the x402 or MPP gateway.",
        "body": {
          "channel": "online"
        }
      }
    ]
  },
  "escrow": {
    "description": "P2P token exchange is protected by a smart contract escrow. Atomic swap \u2014 both transfers happen in one transaction, or neither does.",
    "contract_address": "0xA569C95AfC1BCF381c48BcF336ED9D2c014bcdDF",
    "contract_name": "LoyaltyTokenEscrow",
    "chain": "Base (8453)",
    "explorer": "https://basescan.org/address/0xA569C95AfC1BCF381c48BcF336ED9D2c014bcdDF",
    "fee": "0.5% protocol fee on completed swaps",
    "fee_recipient": "0x40a8CdD6a10EC1a8cB3dFb2834675e7a2CF4ad8b",
    "flow": [
      "1. Creator approves escrow contract for offer tokens",
      "2. Creator calls createOffer() \u2014 tokens locked in escrow",
      "3. Accepter approves escrow contract for request tokens",
      "4. Accepter calls fillOffer() \u2014 atomic swap executes",
      "Alternative: Creator calls cancelOffer() \u2014 tokens returned"
    ]
  },
  "wallets": {
    "type": "cdp_mpc",
    "description": "Coinbase CDP MPC wallets on Base \u2014 agents get their own server wallet for autonomous onchain operations. No private keys to manage.",
    "create_endpoint": "https://api.loyalspark.online/agent-wallet (POST JSON body per function docs; x-api-key required)",
    "chain": "Base (8453)",
    "features": [
      "Automatic wallet creation",
      "Server-side transaction signing",
      "MPC key management by Coinbase",
      "No private key exposure"
    ]
  },
  "pricing": {
    "model": "paid",
    "currency": "USDC on Base ($1 = 1 USDC) \u2014 applies to subscriptions and pay-per-request only",
    "transaction_fee_note": "The per-plan transaction_fee is the mint protocol fee. It is denominated in the merchant's own loyalty tokens (a separate mint(address,uint256) to the platform fee wallet on the same token contract), NOT in USDC, ETH, or fiat. The token contract does not enforce it on-chain; it is tracked off-chain as a fee obligation and 5+ unpaid obligations older than 60 minutes block further mints with HTTP 402. Confirm each fee with POST /agent-api/mint/confirm or MCP confirm_mint_fee.",
    "plans": [
      {
        "name": "Free (via $0.01 x402 register-agent)",
        "price_usd": "0.01 one-time key registration",
        "limits": {
          "api_calls_monthly": 200,
          "agents": 1,
          "max_mint_amount_monthly": 1000,
          "transaction_fee": "1.25%",
          "scopes": [
            "read",
            "create_program",
            "mint",
            "trade",
            "manage_rewards"
          ]
        },
        "note": "Pay $0.01 USDC at POST /x402-gateway/register-agent when the wallet has no Shopify store plan or paid Pro/Enterprise plan. Includes all 5 scopes, 200 API calls/month, and 1,000 mint tokens/month."
      },
      {
        "name": "Pro",
        "price_usdc_monthly": 49,
        "limits": {
          "api_calls_monthly": 10000,
          "agents": 5,
          "max_mint_amount_monthly": "unlimited",
          "transaction_fee": "0.5%"
        },
        "annual_price_usdc": 499.8,
        "annual_discount_percent": 15
      },
      {
        "name": "Enterprise",
        "price_usdc_monthly": 129,
        "limits": {
          "api_calls_monthly": "unlimited",
          "agents": "unlimited",
          "max_mint_amount_monthly": "unlimited",
          "transaction_fee": "0.25%"
        },
        "annual_price_usdc": 1238.4,
        "annual_discount_percent": 20
      }
    ],
    "plan_limits_note": "External agents paying $0.01 USDC at POST /x402-gateway/register-agent receive the Free plan (1 agent, 200 calls/month, 1,000 mint tokens/month, 1.25% mint fee, all 5 scopes). Merchants on a Shopify store plan operate within their store plan limits (Starter: 1,000 calls/month read-only; Growth: 10,000 calls/month read/mint/manage_rewards; Scale: 100,000 calls/month all 5 scopes). Paid Pro ($49) and Enterprise ($129) remove the mint cap and lower the mint fee to 0.5% / 0.25%. The mint fee is loyalty tokens, not USDC.",
    "payment": "Subscriptions: on-chain USDC transfer to the platform wallet, verified automatically. Mint protocol fees are separate and paid in loyalty tokens (see transaction_fee_note).",
    "access_control": {
      "model": "row-level-security",
      "description": "Keyed REST and MCP calls are scoped by Postgres row-level security 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 \u2014 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 \u2014 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."
    },
    "pay_per_request": {
      "protocols": [
        "x402 v2 exact",
        "MPP"
      ],
      "x402": {
        "gateway_url": "https://api.loyalspark.online/x402-gateway",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "scheme": "exact",
        "description": "Fixed-price route payment in USDC on Base. The gateway returns HTTP 402 requirements, verifies and settles before proxying.",
        "discovery_url": "https://api.loyalspark.online/.well-known/x402"
      },
      "mpp": {
        "gateway_url": "https://api.loyalspark.online/mpp-gateway",
        "currencies": [
          "pathUSD",
          "Tempo USDC"
        ],
        "description": "Fixed-price route payment with the MPP 402 challenge and credential flow on Tempo.",
        "manifest_url": "https://loyalspark.online/.well-known/mpp.json"
      },
      "boundary": "The current gateways do not expose upto, partial capture, void, refund, payout, or split operations.",
      "prices_usd": {
        "GET /me": "free",
        "GET /programs": "0.001",
        "GET /rewards": "0.001",
        "GET /balance": "0.001",
        "GET /customers": "0.002",
        "GET /vouchers": "0.001",
        "GET /vouchers/status": "0 (free, public)",
        "GET /analytics": "0.005",
        "GET /offers": "0.001",
        "GET /merchant-profile": "0.001",
        "POST /programs": "0.01",
        "POST /register-program": "0.01",
        "POST /update-program-config": "0.005",
        "POST /activate-program": "0.01",
        "POST /program-status": "0.005",
        "POST /rewards": "0.01",
        "POST /mint": "0.01",
        "POST /earn": "0.01",
        "POST /transfer": "0.005",
        "POST /redeem-reward": "0.01",
        "POST /vouchers/use": "0.005",
        "POST /offers": "0.01",
        "POST /accept-offer": "0.01",
        "POST /cancel-offer": "0.005",
        "POST /merchant-profile": "0.005",
        "PUT /merchant-profile": "0.005",
        "GET /tx-receipt": "free (requires API key)"
      }
    }
  },
  "chain": {
    "name": "Base",
    "chain_id": 8453,
    "token_standards": [
      "B20 Asset (Base-native)",
      "ERC-20 (legacy)"
    ],
    "default_new_program_standard": "B20",
    "explorer": "https://basescan.org",
    "builder_code": "bc_wdmnog7m"
  },
  "mcp": {
    "url": "https://api.loyalspark.online/loyalty-mcp",
    "tool_count": 43,
    "transport": "streamable-http",
    "authentication": {
      "type": "api_key",
      "header": "x-api-key",
      "prefix": "lsk_"
    },
    "tools": [
      "get_platform_info",
      "get_my_profile",
      "get_payment_info",
      "generate_program_defaults",
      "get_program_workflow_status",
      "list_loyalty_programs",
      "create_loyalty_program",
      "register_loyalty_program",
      "activate_loyalty_program",
      "update_program_status",
      "update_program_config",
      "list_rewards",
      "create_reward",
      "mint_loyalty_tokens",
      "transfer_loyalty_tokens",
      "earn_points",
      "confirm_mint_fee",
      "list_mints",
      "list_fee_obligations",
      "get_token_balance",
      "get_program_analytics",
      "list_marketplace_offers",
      "redeem_reward",
      "use_voucher",
      "check_voucher_status",
      "get_platform_stats",
      "cancel_stale_offers",
      "create_personalized_offer",
      "update_reward_status",
      "export_customers",
      "list_store_discount_codes",
      "update_store_discount_code",
      "set_store_sales_channel",
      "send_report",
      "list_my_reports",
      "update_report_status",
      "delete_report",
      "create_gift_certificate",
      "list_gift_certificates",
      "revoke_gift_certificate",
      "mark_gift_certificate_minted",
      "bazaar_discover_resources",
      "bazaar_discover_mcp_servers",
      "bazaar_probe_x402",
      "bazaar_pay_and_call"
    ]
  },
  "base_mcp_plugin": {
    "description": "GET-friendly calldata endpoints designed to be consumed by Base MCP (mcp.base.org) custom plugins. Each response returns a send_calls-compatible batch with the Loyal Spark Builder Code (bc_wdmnog7m, ERC-8021) already appended, so Base Account signs and broadcasts as-is.",
    "base_url": "https://api.loyalspark.online/agent-prepare",
    "authentication": {
      "type": "api_key",
      "header": "x-api-key",
      "prefixes": [
        "lsk_",
        "rwk_"
      ]
    },
    "response_shape": {
      "chainId": 8453,
      "description": "string",
      "transactions": [
        {
          "to": "0x\u2026",
          "data": "0x\u2026",
          "value": "0x0"
        }
      ],
      "builder_code": "bc_wdmnog7m"
    },
    "actions": [
      {
        "method": "GET",
        "path": "/create-program",
        "auth": "lsk_",
        "description": "Deploy a new B20 loyalty token (default; legacy ERC-20 via token_standard)"
      },
      {
        "method": "GET",
        "path": "/activate-program",
        "auth": "lsk_",
        "description": "Activate a legacy ERC-20 program (no-op for B20)"
      },
      {
        "method": "GET",
        "path": "/mint",
        "auth": "lsk_",
        "description": "Mint loyalty tokens to a wallet"
      },
      {
        "method": "GET",
        "path": "/transfer",
        "auth": "lsk_",
        "description": "Merchant-side loyalty token transfer"
      },
      {
        "method": "GET",
        "path": "/recipient-transfer",
        "auth": "rwk_",
        "description": "Holder loyalty token transfer"
      },
      {
        "method": "GET",
        "path": "/recipient-approve",
        "auth": "rwk_",
        "description": "Holder token approve"
      }
    ],
    "plugin_spec": "https://loyalspark.online/skills/loyal-spark/plugins/loyal-spark.md"
  },
  "recipient_api": {
    "description": "Wallet-bound API for agents that HOLD loyalty tokens (not merchants). Authenticated with x-api-key: rwk_\u2026. Register via SIWE: POST https://api.loyalspark.online/siwe-nonce, sign an EIP-4361 message for the holder wallet (no special statement phrase; Chain ID 8453), then POST {message, signature, name} to https://api.loyalspark.online/recipient-api/register. Do not send a Supabase apikey header on api.loyalspark.online. Returns rwk_\u2026 once.",
    "rest_base_url": "https://api.loyalspark.online/recipient-api",
    "mcp_url": "https://api.loyalspark.online/recipient-loyalty-mcp",
    "mcp_transport": "streamable-http",
    "mcp_tool_count": 20,
    "mcp_tools": [
      "get_recipient_profile",
      "list_my_loyalty_balances",
      "get_my_loyalty_balance",
      "prepare_loyalty_token_transfer",
      "list_rewards_for_program",
      "list_my_vouchers",
      "redeem_my_reward",
      "list_p2p_offers",
      "create_p2p_offer",
      "accept_p2p_offer",
      "cancel_p2p_offer",
      "lookup_gift_certificate",
      "claim_gift_certificate",
      "list_my_gift_certificates",
      "get_reward_workflow_status",
      "prepare_reward_redemption",
      "bazaar_discover_resources",
      "bazaar_discover_mcp_servers",
      "bazaar_probe_x402",
      "bazaar_pay_and_call"
    ],
    "rest_endpoints": [
      {
        "method": "GET",
        "path": "/me",
        "price_usd": "free",
        "description": "Recipient profile and bound wallet"
      },
      {
        "method": "GET",
        "path": "/balances",
        "price_usd": "0.001",
        "description": "All loyalty balances for the bound wallet"
      },
      {
        "method": "GET",
        "path": "/balance",
        "price_usd": "0.001",
        "description": "One-token balance and tier"
      },
      {
        "method": "GET",
        "path": "/rewards",
        "price_usd": "0.001",
        "description": "Rewards catalog + has_engagement (true iff customer_tier_status OR token_mint_history for wallet+token; required for redeem; \u2260 balanceOf)"
      },
      {
        "method": "GET",
        "path": "/vouchers",
        "price_usd": "0.001",
        "description": "Vouchers issued to this wallet"
      },
      {
        "method": "GET",
        "path": "/offers",
        "price_usd": "0.001",
        "description": "P2P marketplace offers"
      },
      {
        "method": "GET",
        "path": "/workflow/reward-status",
        "price_usd": "0.001",
        "description": "Autonomous planner: current reward redemption step + next_actions[] (includes has_engagement)"
      },
      {
        "method": "POST",
        "path": "/register",
        "price_usd": "free",
        "description": "One-time wallet registration after SIWE"
      },
      {
        "method": "POST",
        "path": "/prepare-transfer",
        "price_usd": "0.005",
        "description": "B20 token transfer calldata (ERC-20 compatible) (holder \u2192 any address)"
      },
      {
        "method": "POST",
        "path": "/redeem-reward",
        "price_usd": "0.01",
        "description": "Redeem a reward via on-chain tx hash"
      },
      {
        "method": "POST",
        "path": "/offers",
        "price_usd": "0.01",
        "description": "Create P2P swap intent (escrow)"
      },
      {
        "method": "POST",
        "path": "/accept-offer",
        "price_usd": "0.01",
        "description": "Accept a P2P offer (atomic swap)"
      },
      {
        "method": "POST",
        "path": "/cancel-offer",
        "price_usd": "0.005",
        "description": "Cancel your own P2P offer"
      },
      {
        "method": "POST",
        "path": "/workflow/prepare-reward-redemption",
        "price_usd": "0.005",
        "description": "Autonomous planner: transfer calldata for reward cost + workflow metadata"
      }
    ],
    "x402_corridor": {
      "rest_url_template": "https://api.loyalspark.online/x402-gateway/recipient-api/{path}",
      "mcp_url_template": "https://api.loyalspark.online/x402-gateway/recipient-mcp-tools/{tool_name}",
      "bazaar": "Same extensions.bazaar metadata as merchant corridor; each tool's inputSchema is in its 402 (accepts[0].extensions.bazaar.info.input.inputSchema) and in MCP tools/list"
    }
  },
  "mpp": {
    "description": "Machine Payments Protocol \u2014 pay per API request with HTTP 402 flow. No subscription needed.",
    "gateway_url": "https://api.loyalspark.online/mpp-gateway",
    "currency": "pathUSD on Tempo",
    "protocol_spec": "https://mpp.dev",
    "llms_txt": "https://loyalspark.online/llms.txt",
    "how_to_use": [
      "1. Install mppx: npm install -g mppx",
      "2. Create account: mppx account create",
      "3. Make paid request: mppx https://api.loyalspark.online/mpp-gateway/programs -H 'x-api-key: lsk_YOUR_KEY'",
      "4. Payment is handled automatically via 402 challenge/credential flow"
    ]
  },
  "x402": {
    "description": "Coinbase x402 Payment Protocol \u2014 pay per request with USDC on Base. HTTP 402 with x402 v2 accepts; on-chain verify/settle for Base mainnet via Coinbase CDP when gateway secrets are set.",
    "x402_version": 2,
    "gateway_url": "https://api.loyalspark.online/x402-gateway",
    "discovery_url": "https://api.loyalspark.online/.well-known/x402",
    "discovery_mirror": "https://loyalspark.online/.well-known/x402.json",
    "currency": "USDC on Base",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "network": "eip155:8453",
    "chain_id": 8453,
    "payment_headers": {
      "request": "PAYMENT-SIGNATURE (x402 v2, base64 payload); X-PAYMENT is the legacy v1 name and still works",
      "challenge": "PAYMENT-REQUIRED (base64 of the 402 body accepts)",
      "receipt": "PAYMENT-RESPONSE (base64 JSON {success, transaction, network, payer}); legacy X-Payment-Response: settled and X-Payment-TxHash are kept",
      "not_charged": "Any response with charged:false was not settled"
    },
    "errors": "Every 4xx/5xx JSON body carries hint and next_steps {action, summary, request:{method,url,body|query}, docs, how_to_pay|get_key}. An unpaid request with input that is invalid gets 400 charged:false before the 402; an empty probe gets the 402. Docs without JS: https://loyalspark.online/for-agents.md",
    "facilitator": "https://x402.org/facilitator/supported",
    "facilitator_base_mainnet_cdp": "https://api.cdp.coinbase.com/platform/v2/x402",
    "facilitator_note": "Production Base mainnet settlement uses CDP x402 API (JWT) when CDP_API_KEY_ID/CDP_API_KEY_SECRET are configured on the gateway. Public facilitator is Sepolia-only for v2 exact \u2014 see https://x402.org/facilitator/supported.",
    "mcp_paid": {
      "url_template": "https://api.loyalspark.online/x402-gateway/mcp-tools/{tool_name}",
      "method": "POST",
      "body": "JSON-RPC 2.0: method tools/call, params.name = tool_name, params.arguments = object per tool schema",
      "headers_after_payment": [
        "x-api-key: lsk_...",
        "Content-Type: application/json"
      ],
      "keyless_tools": [
        "get_platform_info",
        "list_marketplace_offers"
      ],
      "keyless_note": "True keyless (do not send an API key): get_platform_info, list_marketplace_offers, and list_p2p_offers on recipient-mcp-tools. Merchant read MCP tools and all holder MCP tools also accept payment alone: the paying wallet is the caller (API key optional). Mint, create program, create rewards, trade, and bazaar write tools still need a live lsk_/rwk_ key on the same request as the payment; a payment without that live key is not charged.",
      "tool_schemas_source": "https://api.loyalspark.online/.well-known/x402",
      "bazaar": "HTTP 402 response includes extensions.bazaar (discoverable, inputSchema for headers/body) for MCP resources"
    },
    "protocol_spec": "https://github.com/coinbase/x402",
    "how_to_use": [
      "1. npm install @x402/fetch @x402/evm",
      "2. POST {gateway_url}/mcp-tools/{tool} or other x402 routes \u2014 receive 402 with accepts (v2)",
      "3. Sign USDC payment on Base with an x402 client. Retry with the payment header. Recipient-api, merchant GET reads, merchant read MCP tools, and holder MCP tools accept payment alone (paying wallet = caller; API key optional). Do not send x-api-key on GET /offers, GET /recipient-api/offers, GET /public-programs, POST /register-agent, mcp-tools/get_platform_info, mcp-tools/list_marketplace_offers, or recipient-mcp-tools/list_p2p_offers. Mint, create program, create rewards, trade, and bazaar writes still need x-api-key (lsk_ or rwk_) with the payment; a payment without that live key is not charged. POST /register-agent is $0.01 and returns a full lsk_ key on the Free plan (all 5 scopes: read, create_program, mint, trade, manage_rewards; 1 agent, 200 calls/month, 1,000 mint tokens/month, 1.25% mint fee) when the wallet has no Shopify store plan or paid Pro/Enterprise plan, or scoped to the wallet's active plan.",
      "4. Gateway verify/settle via CDP x402 on mainnet; for MCP, body is forwarded to loyalty-mcp with x-api-key"
    ],
    "prices_usd": {
      "GET /me": "free",
      "GET /programs": "0.001",
      "GET /public-programs": "0.001",
      "POST /register-agent": "0.01",
      "GET /rewards": "0.001",
      "GET /balance": "0.001",
      "GET /customers": "0.002",
      "GET /vouchers": "0.001",
      "GET /vouchers/status": "0 (free, public)",
      "GET /analytics": "0.005",
      "GET /offers": "0.001",
      "GET /merchant-profile": "0.001",
      "GET /resolve-recipient": "0.001 (x402 only; payment alone, payer = merchant, same masking as keyed)",
      "POST /programs": "0.01",
      "POST /register-program": "0.01",
      "POST /update-program-config": "0.005",
      "POST /activate-program": "0.01",
      "POST /program-status": "0.005",
      "POST /rewards": "0.01",
      "POST /mint": "0.01",
      "POST /earn": "0.01",
      "POST /transfer": "0.005",
      "POST /redeem-reward": "0.01",
      "POST /vouchers/use": "0.005",
      "POST /offers": "0.01",
      "POST /accept-offer": "0.01",
      "POST /cancel-offer": "0.005",
      "POST /merchant-profile": "0.005",
      "PUT /merchant-profile": "0.005",
      "GET /tx-receipt": "free (requires API key)"
    }
  },
  "skills": {
    "url": "https://loyalspark.online/.well-known/skills/index.md",
    "format": "markdown",
    "guide_count": 16,
    "list": [
      {
        "id": "getting-started",
        "file": "00-getting-started.md",
        "description": "Register agent, get API key, first request"
      },
      {
        "id": "create-program",
        "file": "01-create-loyalty-program.md",
        "description": "Deploy B20 loyalty token on Base (legacy ERC-20 optional)"
      },
      {
        "id": "mint-tokens",
        "file": "02-mint-tokens.md",
        "description": "Mint loyalty tokens to customer wallets"
      },
      {
        "id": "transfer-tokens",
        "file": "03-transfer-tokens.md",
        "description": "Transfer tokens between wallets"
      },
      {
        "id": "manage-rewards",
        "file": "04-manage-rewards.md",
        "description": "Create redeemable rewards catalog"
      },
      {
        "id": "balance-tiers",
        "file": "05-balance-and-tiers.md",
        "description": "Check balances and tier status"
      },
      {
        "id": "marketplace",
        "file": "06-marketplace-trading.md",
        "description": "P2P token trading with atomic escrow"
      },
      {
        "id": "analytics",
        "file": "07-analytics-crm.md",
        "description": "Program analytics and CRM data"
      },
      {
        "id": "referrals",
        "file": "08-referrals.md",
        "description": "Referral programs for organic growth"
      },
      {
        "id": "vouchers",
        "file": "09-vouchers.md",
        "description": "Voucher lifecycle management"
      },
      {
        "id": "server-wallets",
        "file": "10-server-wallets.md",
        "description": "CDP MPC wallets for autonomous transactions"
      },
      {
        "id": "earn-points",
        "file": "11-earn-points.md",
        "description": "Auto-calculate tokens from purchase amount (cashback)"
      },
      {
        "id": "gift-certificates",
        "file": "12-gift-certificates.md",
        "description": "Issue, claim and mint LOYAL-XXXXXX gift / welcome certificates"
      },
      {
        "id": "endpoint-workflows",
        "file": "13-endpoint-workflows.md",
        "description": "Multi-step REST/MCP workflows and prerequisites"
      },
      {
        "id": "b20-native-spec",
        "file": "14-b20-native-spec.md",
        "description": "Base Beryl B20 Asset semantics for loyalty tokens"
      },
      {
        "id": "payment-scenarios",
        "file": "15-payment-scenarios.md",
        "description": "x402 exact, MPP, subscriptions, and spend policies"
      }
    ]
  },
  "why_use": {
    "headline": "Loyalty-as-a-Service for AI Agents",
    "value_propositions": [
      {
        "title": "Full Infrastructure Out of the Box",
        "description": "Creating an ERC-20 or B20 program is 5% of the work. Loyal Spark provides rewards, vouchers, tiers, analytics, CRM, and marketing automation \u2014 via REST, MCP, and the merchant portal."
      },
      {
        "title": "Autonomous Server Wallets",
        "description": "Each agent gets a Coinbase MPC wallet on Base. No private keys to manage \u2014 sign transactions server-side with enterprise-grade security."
      },
      {
        "title": "Network Effect & Liquidity",
        "description": "A standalone token is an island. Tokens on Loyal Spark have real utility through vouchers and P2P escrow swaps (REST for merchants, MCP for holders) \u2014 not a DEX order book."
      },
      {
        "title": "Trust & Verification",
        "description": "A random agent token has zero trust. Tokens issued through a verified protocol with audit history carry built-in credibility."
      },
      {
        "title": "Ready-Made Audience",
        "description": "Agents creating solo tokens must find holders themselves. Through Loyal Spark, agents access existing merchant customer bases instantly."
      },
      {
        "title": "Humans and Agents, Same Protocol",
        "description": "Merchants run programs in the web portal; AI agents run the same loop via REST and MCP (lsk_/rwk_) with fee-first mint calldata and prepaid USDC rails (subscriptions, x402, MPP)."
      },
      {
        "title": "Composability via Single API",
        "description": "Create program \u2192 set up tiers \u2192 launch referrals \u2192 automate minting \u2192 track analytics. All through one REST API or MCP Server."
      },
      {
        "title": "Pay-as-you-go Pricing",
        "description": "Pay $0.01 USDC at POST /x402-gateway/register-agent for a Free plan lsk_ key (200 calls/month, 1,000 mint tokens/month, all 5 scopes), pay per call in USDC via x402 or MPP, or subscribe to Pro ($49/mo) or Enterprise ($129/mo) via POST https://api.loyalspark.online/verify-agent-plan-payment with x-api-key lsk_ (actions get_payment_info, verify_payment). A Shopify store plan is a separate ceiling (its 45-day trial uses the approved plan's limits). Subscriptions and per-call payments are in USDC on Base; the mint protocol fee is separate and paid in your own loyalty tokens (1.25% Free, 0.5% Pro, 0.25% Enterprise)."
      }
    ],
    "analogy": "Think Shopify vs. coding your own store. You could deploy a token yourself, but why build rewards infrastructure from scratch when a protocol exists?"
  },
  "quickstart": {
    "steps": [
      "1. Go to https://loyalspark.online/merchant and sign in (Google, email via Coinbase, or a wallet)",
      "2. Open 'AI Agents' tab \u2192 Register an agent \u2192 Get API key (lsk_...)",
      "3. Read the Skills guide: https://loyalspark.online/.well-known/skills/00-getting-started.md",
      "4. Use the API key in x-api-key header for REST or MCP calls",
      "5. Create a server wallet: POST https://api.loyalspark.online/agent-wallet (see Edge Function docs)",
      "6. Start minting tokens, creating rewards, and managing programs!"
    ]
  },
  "contact": {
    "website": "https://loyalspark.online",
    "docs": "https://loyalspark.online/api-docs",
    "email": "admin@loyalspark.online",
    "twitter": "https://x.com/Loyal_Spark"
  },
  "tags": [
    "loyalty",
    "rewards",
    "onchain",
    "base",
    "erc20",
    "a2a",
    "marketplace",
    "mcp",
    "cdp",
    "mpc-wallet",
    "ai-agents"
  ]
}
