SuperPay Agent Commerce API

API Reference

Interactive reference for POST /v1/agent/recommend. Get your sandbox key at /for-agents.

POST /v1/agent/recommend Returns the user's cards ranked by reward value for the given transaction.

Authentication

Authorization: Bearer sp_agent_xxxxxxxx_…
# or
X-SuperPay-Key: sp_agent_xxxxxxxx_…

Request body

FieldTypeRequiredDescription
amountnumberrequiredUSD amount (0 < amount ≤ 1,000,000)
cardsobject[]requiredUser's card portfolio — see card schema below
mccstringoptionalISO 18245 4-digit MCC; takes precedence over category
categorystringoptionalSpend category fallback (groceries, dining, gas, travel, …)
merchant_namestringoptionalMerchant display name for name-based category resolution

Card object schema (each element of cards[])

FieldTypeRequiredDescription
idstringrequiredYour internal card ID — returned unchanged in response
issuerstringrequiredCard issuer name, e.g. "Chase", "Citi"
reward_typestringrequiredOne of: cashback | points | miles
base_ratenumberrequiredBase earn rate as a percentage (e.g. 2 for 2% cashback, 1.5 for 1.5x points)
category_bonusesobject[]optionalArray of {category, rate} bonus overrides

Response shape

{
  "recommendation_id": "9f8b2c…",
  "category": "groceries",
  "amount_cents": 8745,
  "top_cards": [
    {
      "rank": 1,
      "id": "amex_bcp",
      "issuer": "American Express",
      "reward_type": "cashback",
      "reward_rate": 6,
      "reason": "6% on groceries",
      "estimated_reward_cents": 524,
      "estimated_reward_display": "$5.24"
    },
    { "rank": 2, … },
    { "rank": 3, … }
  ],
  "top_card": { … }
}

Error codes

StatusCodeMeaning
400INVALID_AMOUNTamount missing, ≤ 0, or > $1,000,000
400INVALID_CARD_DATAOne or more cards failed validation; see card_errors[]
401MISSING_API_KEYNo key in Authorization or X-SuperPay-Key header
401INVALID_API_KEYKey not recognized or hash mismatch
401API_KEY_REVOKEDKey revoked — rotate or contact hello@superpayrewards.com
403ORIGIN_NOT_ALLOWEDBrowser request from unregistered origin (production keys)
429RATE_LIMITEDOver 300 req/min; see Retry-After header
500INTERNAL_ERRORSuperPay-side failure — safe to retry with backoff

Code examples

curl -X POST https://superpayrewards.com/v1/agent/recommend \
  -H "Authorization: Bearer sp_agent_xxxxxxxx_..." \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 87.45,
    "mcc": "5411",
    "merchant_name": "Whole Foods",
    "cards": [
      {
        "id": "amex_bcp",
        "issuer": "American Express",
        "reward_type": "cashback",
        "base_rate": 1,
        "category_bonuses": [{ "category": "groceries", "rate": 6 }]
      },
      { "id": "citi_dc", "issuer": "Citi", "reward_type": "cashback", "base_rate": 2 }
    ]
  }'
const res = await fetch('https://superpayrewards.com/v1/agent/recommend', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.SUPERPAY_AGENT_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    amount: 87.45,
    mcc: '5411',
    merchant_name: 'Whole Foods',
    cards: [
      { id: 'amex_bcp', issuer: 'American Express', reward_type: 'cashback',
        base_rate: 1, category_bonuses: [{ category: 'groceries', rate: 6 }] },
      { id: 'citi_dc', issuer: 'Citi', reward_type: 'cashback', base_rate: 2 },
    ],
  }),
});
const { top_cards, category } = await res.json();
// top_cards[0].reason → "6% on groceries"
// Pass directly to your agent's response.
import os, requests

resp = requests.post(
    'https://superpayrewards.com/v1/agent/recommend',
    headers={
        'Authorization': f"Bearer {os.environ['SUPERPAY_AGENT_KEY']}",
        'Content-Type': 'application/json',
    },
    json={
        'amount': 87.45,
        'mcc': '5411',
        'merchant_name': 'Whole Foods',
        'cards': [
            {'id': 'amex_bcp', 'issuer': 'American Express',
             'reward_type': 'cashback', 'base_rate': 1,
             'category_bonuses': [{'category': 'groceries', 'rate': 6}]},
            {'id': 'citi_dc', 'issuer': 'Citi',
             'reward_type': 'cashback', 'base_rate': 2},
        ],
    },
    timeout=10,
)
best = resp.json()['top_cards'][0]
print(best['reason'])  # → "6% on groceries"
// OpenAI tool definition
{
  "type": "function",
  "function": {
    "name": "get_best_payment_card",
    "description": "Returns the optimal credit card for a purchase based on reward rates. Always call before the user pays.",
    "parameters": {
      "type": "object",
      "properties": {
        "amount":        { "type": "number", "description": "Purchase amount in USD" },
        "merchant_name": { "type": "string", "description": "Merchant or store name" },
        "mcc":           { "type": "string", "description": "ISO 18245 MCC if available" }
      },
      "required": ["amount"]
    }
  }
}

// In your tool handler, fetch user cards from memory, then:
const result = await getBestCard({ amount, merchantName, mcc, cards: userCards });
// Inject result.bestCard.reason into the assistant message.

Try it

Sandbox key required. Get a free key at /for-agents#signup, then paste it below.
Sandbox key
Response
// Response will appear here
GET /api/agent-partner/me Returns your partner profile: name, email, key prefix, key tier, and status.
GET https://superpayrewards.com/api/agent-partner/me
Authorization: Bearer sp_agent_xxxxxxxx_…

// Response
{
  "id": 42,
  "name": "Acme AI",
  "contact_email": "dev@acme.ai",
  "api_key_prefix": "sp_agent_ab12cd34",
  "key_tier": "sandbox",
  "status": "active",
  "created_at": "2026-07-21T10:00:00.000Z"
}
POST /api/agent-partner/rotate-key Rotates your API key. Old key is revoked immediately. New plaintext is returned once — store it immediately.
POST https://superpayrewards.com/api/agent-partner/rotate-key
Authorization: Bearer sp_agent_xxxxxxxx_…

// Response
{
  "message": "Key rotated successfully.",
  "new_key": "sp_agent_newprefix_…",
  "new_key_prefix": "sp_agent_newprefix"
}

Full guide at /agent-partner-guide · Terms at /agent-partner-terms · Contact hello@superpayrewards.com