# Set the hosts a project's runs may reach.

> Replaces the project's own list (empty clears it).
> https://koi.dog/docs/api/projects/set-project-egress-hosts/

`PUT /api/v1/projects/{id}/egress-hosts` · Scope: `config`

Plain DNS host names only, lower-cased, repeats dropped, at most 32: no scheme, port, path, wildcard, IP address, single-label name or name for a private network (`422 validation_failed`, with what is wrong with each). The workspace's owner only, signed in as a person (the dashboard or a full CLI sign-in): a teammate is refused `403 owner_required`, an API key or a limited CLI sign-in `403 session_required` or `403 full_grant_required`. A change is on the timeline with who made it, and applies to runs and previews sent after it: one already sent keeps the list it was sent with. The timeline records the key ID, action and outcome.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The project's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Retry the same request with the same key. [Retry rules](https://koi.dog/docs/api/#retries). |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `hosts` | `array` | yes | Plain DNS host names (`npm.example.com`): lower-cased, repeats dropped, at most 32. Empty clears the list. At most 64 items. |

## Response.

200 OK · JSON object

- **422 validation_failed**: Each schema error appears in `details`.

## Request.

```sh
curl -X PUT "https://api.koi.dog/api/v1/projects/$ID/egress-hosts" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "hosts": [
        "npm.example.com",
        "maven.example.com"
      ]
    }'
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/projects/${process.env.ID}/egress-hosts`, {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    hosts: [
      "npm.example.com",
      "maven.example.com",
    ],
  }),
});
console.log(await res.json());
```

```python
import os

import requests

r = requests.put(
    f"https://api.koi.dog/api/v1/projects/{os.environ['ID']}/egress-hosts",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
    json={
        "hosts": [
            "npm.example.com",
            "maven.example.com",
        ],
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "projectId": "string",
  "hosts": []
}
```
