# Affiliate

URL: https://docs.hanzo.ai/docs/openapi/affiliate

> A partner program that pays commission on what your referrals spend.

Also for this capability: **API** · [CLI](https://docs.hanzo.ai/docs/cli/affiliate) · [MCP](https://docs.hanzo.ai/docs/mcp-tools/affiliate) · [SDKs](https://docs.hanzo.ai/docs/sdks)

A partner program that pays commission on what your referrals spend.

> [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|                |                                        |
| -------------- | -------------------------------------- |
| **Base URL**   | `https://api.hanzo.ai`                 |
| **Operations** | 10                                     |
| **Auth**       | `Authorization: Bearer $HANZO_API_KEY` |

## Specification

Specification pending — no HIP in [hanzoai/hips](https://github.com/hanzoai/hips) declares `capability: affiliate` yet. What this capability serves is below, from the API document; what it is — the store it owns, how it meters, what it publishes — is written as a HIP under HIP-0139.

## Four surfaces

| Surface  | Reaches this capability as                        | Coverage                                                                   |
| -------- | ------------------------------------------------- | -------------------------------------------------------------------------- |
| **REST** | `affiliate` at its own prefix                     | 10 operations                                                              |
| **CLI**  | `hanzo affiliate …`                               | 10 of 10                                                                   |
| **SDK**  | `AffiliateApi` in every published client          | 10 methods                                                                 |
| **MCP**  | tool `affiliate` on `https://api.hanzo.ai/v1/mcp` | 10 operations, 2 under the document's own id — ask `describe` for the rest |

## Quickstart

```bash
export HANZO_API_KEY=sk-...   # console.hanzo.ai → API keys
```

Then the first call — a read that needs nothing but the key. `GET /v1/affiliate`, operation `get_affiliate`:

**CLI**

```bash
hanzo affiliate get
```

**SDK**

**.ts**

```ts
import { Configuration, AffiliateApi } from 'hanzoai';

const api = new AffiliateApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getAffiliate();
```

**.py**

```python
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).get_affiliate()
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.AffiliateAPI.GetAffiliate(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::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::get_affiliate(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AffiliateApi;

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

var result = new AffiliateApi(client).getAffiliate();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/affiliate \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **affiliate** through the `affiliate` tool, which names its 10 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
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_affiliates"
         }
       }
     }'
```

Answers `200` with `object` — ok.

## Endpoints

| Endpoint                                                                                                  | What it does                                                                                                                                                                                                                                                |
| --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`POST /v1/affiliate/apply`](https://docs.hanzo.ai/docs/openapi/affiliate/post-affiliate-apply)           | 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.                                                                |
| [`POST /v1/affiliate/attribute`](https://docs.hanzo.ai/docs/openapi/affiliate/post-affiliate-attribute)   | Records the first-touch edge every later commission is computed from: the caller's org was referred by the affiliate that owns this code.                                                                                                                   |
| [`POST /v1/affiliate/click`](https://docs.hanzo.ai/docs/openapi/affiliate/post-affiliate-click)           | Counts a click on a share link.                                                                                                                                                                                                                             |
| [`GET /v1/affiliate/leaderboard`](https://docs.hanzo.ai/docs/openapi/affiliate/get-affiliate-leaderboard) | Answers the top affiliates by lifetime accrued commission, shown by OPT-IN HANDLE with aggregate figures only, plus the caller's own exact rank.                                                                                                            |
| [`GET /v1/affiliate/me/earnings`](https://docs.hanzo.ai/docs/openapi/affiliate/get-affiliate-me-earnings) | Answers the caller's own commission ledger: per period, the margin it earned against and the commission taken from that margin; and per referred org, that referral's aggregate contribution.                                                               |
| [`POST /v1/affiliate/me/handle`](https://docs.hanzo.ai/docs/openapi/affiliate/post-affiliate-me-handle)   | Sets the caller's public leaderboard display name, or clears it.                                                                                                                                                                                            |
| [`GET /v1/affiliate/me/links`](https://docs.hanzo.ai/docs/openapi/affiliate/get-affiliate-me-links)       | Answers the caller's share links, each with its URL and its funnel: clicks tracked, signups — orgs attributed with that code — and conversions, meaning how many of those signups have actually produced commission.                                        |
| [`POST /v1/affiliate/me/links`](https://docs.hanzo.ai/docs/openapi/affiliate/post-affiliate-me-links)     | Mints a new share link for the caller's own affiliate and answers it with its full URL, 201.                                                                                                                                                                |
| [`GET /v1/affiliate/me`](https://docs.hanzo.ai/docs/openapi/affiliate/get-affiliate-me)                   | Answers the richer self-view: the same lifetime accrued, pending and paid commission and payout history, plus the caller's downline broken out by upline LEVEL — direct, second, third — each with the rate paid at that level and how many orgs sit there. |
| [`GET /v1/affiliate`](https://docs.hanzo.ai/docs/openapi/affiliate/get-affiliate)                         | Answers the caller org's OWN affiliate standing: status, referral code and share link, commission rate, how many orgs it has referred, and its lifetime accrued, still-pending and already-paid commission in integer cents, with its payout history.       |

---

[All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
