# Create identities

URL: https://docs.hanzo.ai/docs/openapi/network/post-network-identities

> Puts the caller on the org's overlay as its own IAM subject.

`POST /v1/network/identities`

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

|               |                                              |
| ------------- | -------------------------------------------- |
| **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. Roles are a steward's to
take: a plain member joins with the org role alone, and asking for more is
403 before the controller is written.

An API key is refused 403: the fabric admits an IAM access token, a person's
or an application's, and a key has none to log in with.

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>".                                                                                                               |
| `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 claim an attribute another tenant's policy selects. |

## 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](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo network identities create
```

**SDK**

**.ts**

```ts
import { 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>"] });
```

**.py**

```python
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>"])
```

**.go**

```go
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
}
```

**.rs**

```rust
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?;
```

**.java**

```java
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();
```

**HTTP**

```bash
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**

MCP reaches **network** through the `network` tool, which names its 7 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_networks"
         }
       }
     }'
```

---

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