Records that the caller's org signed up through a referral code.
Records that the caller's org signed up through a referral code.
POST /v1/referral/claim
| Address | https://api.hanzo.ai/v1/referral/claim |
| Method | POST |
| Operation | post_referral_claim |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Records that the caller's org signed up through a referral code.
The REFEREE is the validated caller, never a client field, and the referrer is resolved from the code — so a caller can only ever attach THEMSELVES to someone else's code. Referring yourself is 400 and an unknown code is 404.
It is idempotent and first-touch: an org can be referred once, ever. A repeat call returns the referral already on file with created=false and 200, where the first call answers 201.
Recording a referral grants nothing, and neither does anything downstream of it: the edge later advances to qualified when the referee makes metered spend (POST /v1/admin/referral/sweep), and that is the end of it. No credit is ever issued from this package.
Request
1 field, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
code | body | string | — | Code is the referrer's referral code, as it appeared in their ?ref= link. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | claimView | ok |
200 body — 5 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
code | body | string | — | Code is the referral code the referral was recorded against. |
created | body | boolean | — | Created is true when this call recorded the referral and false when it found one already recorded for this referee — the idempotent replay. |
createdAt | body | integer | — | CreatedAt is when the referral was first recorded, as a Unix timestamp. |
id | body | string | — | ID is the referral's handle. |
status | body | string | — | Status is the referral's lifecycle state: "signup" until the referee makes metered spend, then "qualified", then "credited". |
Failure carries the platform error shape — see Errors.
Examples
hanzo referrals claimimport { Configuration, ReferralApi } from 'hanzoai';
const api = new ReferralApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postReferralClaim({ code: "<code>" });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import ReferralApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = ReferralApi(client).post_referral_claim(code="<code>")cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.ReferralAPI.PostReferralClaim(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, referral_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = referral_api::post_referral_claim(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.ReferralApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new ReferralApi(client).postReferralClaim();The method above is the one at the current release of the document. [email protected] (npm) and [email protected] (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. SDKs →
curl -X POST https://api.hanzo.ai/v1/referral/claim \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "<code>"
}'The door reaches referral through the referrals tool, which names its 4 operations with its own verbs — this one among them, under a name only the door declares. describe explains any of them:
curl -X POST https://api.hanzo.ai/v1/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "describe",
"arguments": {
"op": "list_admin_referral_bonuses"
}
}
}'How is this guide?