apply_referral
Apply a referral code for a referred user, issuing the configured credits to the referee and the referrer. credit_type_id picks the credit type's program (default: the project's default program). defer_referrer_credits pays only the referee now; the referral stays pending until complete_referral pays the referrer. A user can be referred once per program (without credit_type_id: in the default program); a credit_type_id retry with the same code replays (replayed: true): errors 400 ALREADY_REFERRED, SELF_REFERRAL, INVALID_REFERRAL_CODE, or program inactive. Costs 1 CRD (platform credit) per call, charged even when the call is then rejected (a 429 RATE_LIMITED costs nothing). Error results include request_id; quote it to support.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | Cred API key (optional if set via the x-api-key header) | |
| user_id | Yes | External user ID of the referred user | |
| project_id | No | Cred project ID (optional; the API key already identifies the project) | |
| x402_payment | No | Base64 x402 PaymentPayload, only when a previous call failed with an x402 PaymentRequired because the account is out of CRD | |
| referral_code | Yes | The referrer's code | |
| credit_type_id | No | Credit type whose program pays | |
| defer_referrer_credits | No | Hold the referrer's credits until complete_referral |