Replace referral

Updates the caller's referral code and returns the updated referral summary.

PUT /v1/referral

Addresshttps://api.hanzo.ai/v1/referral
MethodPUT
Operationput_referral
AuthAuthorization: Bearer $HANZO_API_KEY

Updates the caller's referral code and returns the updated referral summary.

Request

1 field, body application/json (required).

FieldInTypeRequiredDescription
codebodystring—Code is the custom referral code to assign to the caller's org (2-32 uppercase alphanumeric, hyphen, or underscore characters).

Response

StatusBodyMeaning
200referral.myReferralsok
defaultproblem-detailsrefused

200 body — 12 fields.

FieldInTypeAlwaysDescription
codebodystring—Code is the org's STABLE referral code — a deterministic function of the org id, so it never changes and never has to be stored to be reproduced.
countsbodyreferral.statusCounts—
counts.qualifiedbodyinteger (int64)—Qualified is how many referees have made metered spend.
counts.signupbodyinteger (int64)—Signup is how many referees have signed up but not yet spent.
counts.totalbodyinteger (int64)—Total is every referral this org has made.
linkbodystring—Link is the shareable signup link carrying the code, on the brand's own host.
referralsbodyreferral.myReferralView[]—Referrals is one row per org that signed up with this code.
referrals[].createdAtbodyinteger (int64)—CreatedAt is when the referral was recorded, as a Unix timestamp.
referrals[].idbodystring—ID is the referral's handle.
referrals[].qualifiedAtbodyinteger (int64)—QualifiedAt is when the referee first made metered spend, as a Unix timestamp; 0 while the referral is still pending.
referrals[].refereebodystring—Referee is the org that signed up with my code.
referrals[].statusbodystring—Status is the referral's lifecycle state: "signup" until the referee makes metered spend, then "qualified".

Failure carries the platform error shape — see Errors.

Examples

hanzo referral replace
import { Configuration, ReferralApi } from 'hanzoai';

const api = new ReferralApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.putReferral({ 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).put_referral(code="<code>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.ReferralAPI.PutReferral(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::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::put_referral(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.ReferralApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new ReferralApi(client).putReferral();
curl -X PUT https://api.hanzo.ai/v1/referral \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "code": "<code>"
     }'

MCP reaches referral through the referral tool, which names its 3 operations with its own verbs — this one among them, under a name only MCP 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_referrals"
         }
       }
     }'

Referral API · All Hanzo APIs · Interactive reference

Was this page useful?
Broken link or missing step? Drop it in #docs on Discord or open a PR.