Enrolls the caller's OWN org as an affiliate at status `applied`, optionally…
Enrolls the caller's OWN org as an affiliate at status `applied`, optionally requesting a vanity code, and answers the record — 201 on the first apply,…
POST /v1/affiliate/apply
| Address | https://api.hanzo.ai/v1/affiliate/apply |
| Method | POST |
| Operation | post_affiliate_apply |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Enrolls the caller's OWN org as an affiliate at status applied,
optionally requesting a vanity code, and answers the record — 201 on the first
apply, 200 with created:false afterwards.
IDEMPOTENT, first apply wins: one affiliate per org, so re-applying never creates a second row and never resets an existing approval. Applying is not joining — no code is minted and nothing accrues until staff approve, which is where both the code and the commission rate come from.
The org is the validated caller's, never a field. A malformed vanity code is refused up front; the code is only REQUESTED here, and approval may mint a different one if the requested code is taken.
Request
1 field, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
requestedCode | body | string | — | RequestedCode is the vanity code the applicant asks for; approval may mint a different one if it is taken. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | application | ok |
201 | application | created |
200 body — 6 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
code | body | string | — | Code is the minted referral code. |
created | body | boolean | — | Created says whether THIS call made the row. false means the org had already applied and nothing changed — no second row, no reset of an existing approval. |
id | body | string | — | ID is the affiliate's server-minted handle, "aff_"-prefixed — the id staff approve, suspend, re-rate and pay against. |
rateBps | body | integer | — | RateBps is the direct (level 1) commission rate the row carries, in basis points OF Hanzo's margin (2000 = 20% of margin, never of the customer's bill). |
requestedCode | body | string | — | RequestedCode echoes the vanity code asked for, normalized to lower case. |
status | body | string | — | Status is "applied" for a row this call created. |
Failure carries the platform error shape — see Errors.
Examples
hanzo affiliates applyimport { Configuration, AffiliateApi } from 'hanzoai';
const api = new AffiliateApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postAffiliateApply({ requestedCode: "<requestedCode>" });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AffiliateApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AffiliateApi(client).post_affiliate_apply(requested_code="<requestedCode>")cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.AffiliateAPI.PostAffiliateApply(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, affiliate_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = affiliate_api::post_affiliate_apply(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AffiliateApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new AffiliateApi(client).postAffiliateApply();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/affiliate/apply \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"requestedCode": "<requestedCode>"
}'The door reaches affiliate through the affiliates tool, which names its 17 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_affiliates"
}
}
}'How is this guide?