cred.diy/ docs
    Sign inGet an API key
    All documentation

    API Reference - cred.diy API documentation

    API Reference

    Complete reference for all API endpoints. Base URL: https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api

    Quick Start

    1. Generate an API key from the API Keys page (set an expiration date for security).
    2. Include your API key in the x-api-key header.
    3. Make requests to the endpoints below.

    Authentication

    All requests require an API key in the header. Rate limit: 100 requests/minute per key.

    curl -H "x-api-key: sk_live_your_api_key" https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/balance?user_id=user_123
    GET/balance

    Get the credit balance for a user. Supports email-first lookup for unified wallets.

    Query parameters

    • emailstringUser's email (preferred, takes priority over user_id)
    • user_idstringYour unique identifier for the user (required if email not provided)
    • credit_type_idstringFilter to specific credit type

    Example request

    # Preferred: use email for cross-app wallet lookup
    curl -X GET "https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/balance?email=user@example.com" \
      -H "x-api-key: sk_live_your_api_key"
    
    # Alternative: use user_id
    curl -X GET "https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/balance?user_id=user_123" \
      -H "x-api-key: sk_live_your_api_key"

    Response

    {
      "user_id": "user_123",
      "email": "user@example.com",
      "balances": [{
        "credit_type_id": "ct_abc123",
        "credit_type_name": "Tokens",
        "credit_type_symbol": "TKN",
        "balance": 75
      }]
    }

    Webhooks

    Configure webhooks to receive real-time notifications when credit events occur. Use the Test button in the dashboard to verify your endpoints.

    Available Events

    • credits.issued
    • credits.deducted
    • credits.refunded
    • purchase.completed
    • purchase.failed
    • swap.completed
    • referral.completed
    • balance.low
    • subscription.created
    • subscription.renewed
    • subscription.cancel_scheduled
    • subscription.canceled
    • subscription.payment_failed

    Verify the X-Cred-Signature header using HMAC-SHA256 with your webhook secret.

    Error Codes

    CodeDescription
    400Bad Request — invalid parameters or insufficient user credits (code: INSUFFICIENT_CREDITS)
    401Unauthorized — invalid or missing API key
    402Payment Required — insufficient platform credits (CRD)
    404Not Found — user or resource not found
    409Conflict — already processed (e.g. a refund that was already issued)
    429Rate Limit Exceeded — 100 requests/minute per key
    500Internal Server Error

    Your first credit is one request away.

    Create a project, copy an API key, and issue a credit from your server.