# Create services

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

> Puts a name on the org's overlay: a fabric service forwarding to host:port on whichever of the org's devices carries the "<name>-host" role, dialable at "<name>.<org>.zt" by any of the org's identities — and by the cloud's own, which is what lets a BYO cluster's apiserver be attached to the fleet with a ".zt" kubeconfig.

`POST /v1/network/services`

> [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/services` |
| **Method**    | `POST`                                     |
| **Operation** | `post_network_services`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`     |

Puts a name on the org's overlay: a fabric service forwarding
to host:port on whichever of the org's devices carries the "\<name>-host"
role, dialable at "\<name>.\<org>.zt" by any of the org's identities — and by
the cloud's own, which is what lets a BYO cluster's apiserver be attached to
the fleet with a ".zt" kubeconfig.

Answers 201 with the service and its DNS name. The objects behind it are
created in dependency order and unwound on failure, so a half-published
service never lingers on the fabric. Publishing is a steward's act — an
admin of the org or its own machine client — and a plain member is 403.

A write, so it does not degrade: an unconfigured deployment answers 503.

## Request

3 fields, body `application/json` (required).

| Field  | In   | Type            | Required | Description                                                                                                                                     |
| ------ | ---- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `host` | body | string          | —        | Host is where the HOSTING identity forwards a connection — an address the host device itself can reach, "127.0.0.1" for a server on the device. |
| `name` | body | string          | —        | Name is the service's name within the org — a DNS label.                                                                                        |
| `port` | body | integer (int64) | —        | Port is the port beside Host, and the one the DNS name intercepts.                                                                              |

## Response

| Status    | Body                  | Meaning |
| --------- | --------------------- | ------- |
| `201`     | network.publishedView | created |
| `default` | problem-details       | refused |

`201` body — 3 fields.

| Field  | In   | Type   | Always | Description                                                                                                                |
| ------ | ---- | ------ | ------ | -------------------------------------------------------------------------------------------------------------------------- |
| `dns`  | body | string | —      | DNS is the name the fabric answers for this service — what a kubeconfig server, or any client on the org's overlay, dials. |
| `id`   | body | string | —      | ID is the fabric service's id.                                                                                             |
| `name` | body | string | —      | Name is the service's name within the org.                                                                                 |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo network services 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.postNetworkServices({ host: "<host>", name: "<name>" });
```

**.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_services(host="<host>", name="<name>")
```

**.go**

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

resp, _, err := client.NetworkAPI.PostNetworkServices(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_services(&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).postNetworkServices();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/network/services \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "host": "<host>",
       "name": "<name>"
     }'
```

**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)
