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

    Pricing Tiers - cred.diy API documentation

    Pricing Tiers

    Create pricing packages for your users to purchase credits. Pricing tiers define how many credits users get for a specific price. Prices are automatically normalized to 2 decimal places in responses and validated against Stripe's $0.50 minimum charge.

    List Pricing Tiers

    Retrieve all pricing tiers configured for your project.

    // List all pricing tiers for your project
    const response = await fetch(
      'https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/pricing-tiers',
      {
        headers: {
          'x-api-key': 'sk_live_your_api_key'
        }
      }
    );
    
    const result = await response.json();
    // { pricing_tiers: [{ id: '...', name: 'Starter', price: 9.99, credits: 100, ... }] }

    Create Pricing Tier

    Programmatically create a new pricing tier. Use the returned ID for checkout sessions.

    // Create a new pricing tier programmatically
    const response = await fetch(
      'https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/pricing-tiers',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'x-api-key': 'sk_live_your_api_key'
        },
        body: JSON.stringify({
          name: 'Pro Pack',
          description: 'Best value for power users',
          price: 29.99,
          credits: 500,
          currency: 'USD',
          billing_type: 'one_time',  // or 'subscription'
          is_popular: true,
          // Optional: restrict this tier to specific credit types.
          // Omit or pass [] to make the tier available for ALL credit types in the project.
          credit_type_ids: ['ct_abc123']
        })
      }
    );
    
    const result = await response.json();
    // { 
    //   success: true, 
    //   pricing_tier: { 
    //     id: 'tier_abc123',  // Use this ID for checkout
    //     name: 'Pro Pack', 
    //     price: 29.99, 
    //     credits: 500,
    //     ...
    //   } 
    // }

    Pricing Tier Fields

    FieldTypeDescription
    namestringDisplay name (e.g., "Starter Pack")
    pricenumberPrice in currency (≥ $0.50 or $0.00 for free). Returned as a 2-decimal string.
    creditsnumberNumber of credits included
    billing_typestring"one_time" or "subscription"
    is_popularbooleanHighlight as recommended
    credit_type_idsstring[]Credit types this tier can be purchased for. Empty array = applies to all active credit types in the project.

    Price Validation Rules

    • Minimum price is $0.50 (Stripe requirement) or exactly $0.00 for free tiers
    • Price-per-credit ratio must not exceed $1.00
    • Prices are stored at 4-decimal precision and returned as 2-decimal strings
    • Dashboard auto-formats prices to 2 decimal places on input

    Pro Tip

    Create pricing tiers in the dashboard for easy management, then use the API to fetch them for display in your app. Use the is_popular flag to highlight your best-value tier.

    Your first credit is one request away.

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