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

    Signup Bonus - cred.diy API documentation

    Signup Bonus & Abuse Controls

    Free credits on signup attract account farms. POST /signup-bonus grants a project's bonus at most once per person and runs every check in one place, so each of your apps gets the same protection:

    • one bonus per user, and per normalized email (a.b+x@gmail.com counts as ab@gmail.com)
    • no bonus for throwaway inboxes (a ~64k-domain blocklist)
    • an optional Cloudflare Turnstile check (off by default; enable with Cred's shared widget or your own)
    • no bonus for accounts older than max_account_age_hours (48 by default)
    • caps per client IP per day, per project per hour and day, and optionally across all your projects
    • suspended users get nothing; suspending takes back what is left of their bonus

    1. Configure it (optional)

    Using it is your choice: you can keep granting signup credits your own way with /issue. If you use it, there is nothing to set up: send amount in the /signup-bonus call and the defaults below apply. Save settings only to change the limits. Saves are partial: only the fields you send change. Turnstile captcha is off by default — set require_turnstile: true to require a token checked with Cred's shared widget, or save your own turnstile_secret (write-only; reads show turnstile_source).

    // Once per project, from your server or a script
    await fetch('https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/signup-bonus-settings', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json', 'x-api-key': 'sk_live_your_api_key' },
      body: JSON.stringify({
        enabled: true,
        credit_type_id: 'ct_abc123',
        amount: 10,
        owner_max_per_day: 60 // across all your apps
      })
    });
    // GET /signup-bonus-settings → { "success": true, "settings": { ..., "turnstile_source": "off" } }
    // turnstile_source: "project" (your own secret), "shared" (Cred's widget) or "off"
    FieldTypeDescription
    enabledbooleanTurn the bonus on. Needs credit_type_id and an amount above 0
    credit_type_idstringAn active credit type in this project
    amountnumberCredits granted per person
    require_turnstilebooleanRequire a passing turnstile_token (default false). Set true to check tokens with Cred's shared widget, or save your own turnstile_secret
    turnstile_secretstring | nullOptional: your own Cloudflare Turnstile widget's secret key (stored encrypted, never returned). Saving one turns the check on; null removes it
    turnstile_actionstring | nullIf set, the token must come from a widget rendered with this action
    block_disposable_emailbooleanRefuse throwaway inboxes (default true)
    max_account_age_hoursintegerAccounts older than this never earn it (default 48). Age is from account_created_at or when Cred first saw the user, whichever is earlier
    max_per_ip_per_dayintegerBonuses per client IP in any 24 hours (default 2)
    max_per_hourintegerBonuses in this project in any hour (default 6)
    max_per_dayintegerBonuses in this project in any 24 hours (default 30)
    owner_max_per_hourinteger | nullBonuses across all your projects in any hour (default none)
    owner_max_per_dayinteger | nullBonuses across all your projects in any 24 hours (default none)

    2. Ask for the bonus from your server

    Call it right after signup (or on each session sync; repeats are cheap). Forward the person's IP so the per-IP cap works; if you enabled Turnstile, also pass the widget's token. Never call it from the browser with your API key.

    // Your server, after signup.
    const res = await fetch('https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/signup-bonus', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json', 'x-api-key': 'sk_live_your_api_key' },
      body: JSON.stringify({
        user_id: user.id,
        user_email: user.email,
        client_ip: req.headers.get('cf-connecting-ip') ?? clientIpFromXForwardedFor(req),
        account_created_at: user.created_at,
        amount: 10 // no setup needed: the default checks apply
      })
    });
    const { granted, amount, reason } = await res.json();
    FieldTypeDescription
    user_id *stringYour identifier for the user (created if new)
    user_emailstringStrongly recommended: the disposable-inbox check and one-per-email rule need it
    client_ipstringThe person's IP address (not your server's). Needed for the per-IP cap; also sent to Turnstile
    turnstile_tokenstringThe widget's token (single use). Required only when require_turnstile is true
    account_created_atstringISO 8601 signup time in your app, for the account age limit
    amountnumberCredits to grant. Sending it turns the bonus on with the default checks, so no settings call is needed
    credit_type_idstringCredit type for the bonus; defaults to the project's only active credit type

    A withheld bonus is still a 200: check granted. Nothing is recorded when it is withheld, so a person turned away by a busy cap can earn it on a later call while the account is new.

    { "success": true, "granted": true, "amount": 10, "credit_type_id": "ct_abc123",
      "transaction_id": "tx_123", "new_balance": 10 }
    
    // Withheld (still 200): "reason" is one of
    //   already_granted   this person (user or email) already had it
    //   disabled          no amount sent and no bonus configured for this project
    //   disposable_email  throwaway inbox
    //   unverified        missing or failed Turnstile token ("detail" says why)
    //   expired           account older than max_account_age_hours
    //   ip_limit          too many bonuses from this IP today
    //   busy              an hourly or daily cap is reached (possible farm)
    //   suspended         the user is suspended
    { "success": true, "granted": false, "reason": "busy", "amount": 0 }

    3. Suspend abusers

    A suspended user can't spend: /deduct (including shared fallback), escrow holds and /redeem return 403 USER_SUSPENDED. Suspending also takes back the unspent part of their signup bonus (never more than their balance) and stops it counting toward the caps, so a farm you have cleaned up doesn't hold the caps shut for real signups. Issuing and refunds still work.

    await fetch('https://eutdgemlrpvnxfkkpvlu.supabase.co/functions/v1/credits-api/users/suspend', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json', 'x-api-key': 'sk_live_your_api_key' },
      body: JSON.stringify({ user_id: 'user_123', reason: 'signup farm' })
      // revoke_signup_bonus: false keeps the bonus
    });
    // → { "success": true, "user_id": "user_123", "suspended_at": "...",
    //     "signup_bonus_revoked": true, "signup_bonus_revoked_amount": 10 }
    // POST /users/unsuspend { user_id } lifts it (a revoked bonus stays revoked).
    // GET /users shows suspended_at.

    Your first credit is one request away.

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