Create identities
Puts the caller on the org's overlay as its own IAM subject.
POST /v1/network/identities
| Address | https://api.hanzo.ai/v1/network/identities |
| Method | POST |
| Operation | post_network_identities |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Puts the caller on the org's overlay as its own IAM subject.
The identity is the one whose externalId is the caller's sub, admitted by
the controller's "iam" auth policy: the caller logs in to the fabric with its
own IAM access token, and nothing is enrolled. It is named by the subject
unless a name is given, and carries the org's "org-<org>" role attribute plus
any supplied roles — each scoped to the org, and a "<service>-host" role
refused unless the org has published that service.
IDEMPOTENT: a caller who already has an identity gets the same one back, with any of these roles it lacked added — which is how one person's identity comes to serve every org they act in.
A write, so it does not degrade: an unconfigured deployment answers 503.
Request
2 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
name | body | string | — | Name is the identity's name within the org — a DNS label, stored on the fabric as "<name>.<org>". Absent, the identity is named by the caller's IAM subject. |
roles | body | string[] | — | Roles are extra role attributes for the identity, each scoped to the caller's org on the way in ("k3s-host" is written as "k3s-host.<org>") so no caller can… |
Response
| Status | Body | Meaning |
|---|---|---|
201 | network.identityView | created |
default | problem-details | refused |
201 body — 4 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
externalId | body | string | — | ExternalID is the IAM subject the identity logs in as: the controller admits a bearer whose sub equals it. |
id | body | string | — | ID is the identity's fabric id — the key DELETE addresses. |
name | body | string | — | Name is the identity's name within the org. |
roles | body | string[] | — | Roles are the identity's role attributes as the fabric holds them: the "org-<org>" of every org it was ensured in, plus any org-scoped roles. |
Failure carries the platform error shape — see Errors.
Examples
hanzo network identities createimport { Configuration, NetworkApi } from 'hanzoai';
const api = new NetworkApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postNetworkIdentities({ name: "<name>", roles: ["<roles>"] });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import NetworkApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = NetworkApi(client).post_network_identities(name="<name>", roles=["<roles>"])cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)
resp, _, err := client.NetworkAPI.PostNetworkIdentities(context.Background()).Execute()
if err != nil {
return err
}use hanzo_client::apis::{configuration::Configuration, network_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = network_api::post_network_identities(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.NetworkApi;
ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));
var result = new NetworkApi(client).postNetworkIdentities();The method above is the one at the current release of the document. [email protected] (npm) was 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/network/identities \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "<name>",
"roles": [
"<roles>"
]
}'MCP reaches network through the zt tool, which names its 4 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_mesh_services"
}
}
}'How is this guide?