# Namespaces

8 calls. Every request needs the `Authorization` header: see [the overview](https://docs.maitento.com/reference.md).

## `namespaces.list`

```http
GET /namespaces
```

Every namespace of the tenant.

**Who can call it:** Admins and members, with an API key or a portal session. [Try it in the API playground](https://docs.maitento.com/playground/?call=GET%20%2Fnamespaces).

**Response:** [`Namespace`](https://docs.maitento.com/reference/types/namespace.md)`[]` (200)

```bash title="curl"
curl -X GET "https://api.maitento.com/namespaces" \
  -H "Authorization: $MAITENTO_AUTH"
```
```ts title="TypeScript"
const namespaces = await mt.namespaces.list();
```
```python title="Python"
mt.namespaces.list()
```

## `namespaces.create`

```http
POST /namespaces
```

Creates a namespace.

**Who can call it:** Admins and members, with an API key or a portal session. [Try it in the API playground](https://docs.maitento.com/playground/?call=POST%20%2Fnamespaces).

**Request body:** [`NamespaceCreateOrUpdateRequest`](https://docs.maitento.com/reference/types/namespace-create-or-update-request.md)

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | yes | The namespace's name, 1 to 200 characters, unique within the tenant. |

**Response:** [`Namespace`](https://docs.maitento.com/reference/types/namespace.md) (200)

```bash title="curl"
curl -X POST "https://api.maitento.com/namespaces" \
  -H "Authorization: $MAITENTO_AUTH" \
  -H "Content-Type: application/json" \
  -d '{"name":"..."}'
```
```ts title="TypeScript"
const namespace = await mt.namespaces.create({ name: "support" });
```
```python title="Python"
mt.namespaces.create("demo")
```

## `namespaces.delete`

```http
DELETE /namespaces/by-id/{id}
```

Deletes an empty namespace (a 400 `api:namespace:delete:not-empty` lists what remains).

**Who can call it:** Admins and members, with an API key or a portal session. [Try it in the API playground](https://docs.maitento.com/playground/?call=DELETE%20%2Fnamespaces%2Fby-id%2F%7Bid%7D).

**Path parameters**

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | `uuid` | yes |  |

**Response:** no body (204)

```bash title="curl"
curl -X DELETE "https://api.maitento.com/namespaces/by-id/<id>" \
  -H "Authorization: $MAITENTO_AUTH"
```
```ts title="TypeScript"
await mt.namespaces.delete("b5f3d1a9-7e6c-4b4a-9a2e-8c0d1f3e5a7b");
```
```python title="Python"
mt.namespaces.delete("0f1e2d3c-4b5a-4968-8776-655443322110")
```

## `namespaces.getById`

```http
GET /namespaces/by-id/{id}
```

The namespace with this id. Throws `NotFoundError` when there is none.

**Who can call it:** Admins and members, with an API key or a portal session. [Try it in the API playground](https://docs.maitento.com/playground/?call=GET%20%2Fnamespaces%2Fby-id%2F%7Bid%7D).

**Path parameters**

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | `uuid` | yes |  |

**Response:** [`Namespace`](https://docs.maitento.com/reference/types/namespace.md) (200)

```bash title="curl"
curl -X GET "https://api.maitento.com/namespaces/by-id/<id>" \
  -H "Authorization: $MAITENTO_AUTH"
```
```ts title="TypeScript"
const namespace = await mt.namespaces.getById("b5f3d1a9-7e6c-4b4a-9a2e-8c0d1f3e5a7b");
```
```python title="Python"
mt.namespaces.get_by_id("0f1e2d3c-4b5a-4968-8776-655443322110")
```

## `namespaces.rename`

```http
PUT /namespaces/by-id/{id}
```

Renames a namespace.

**Who can call it:** Admins and members, with an API key or a portal session. [Try it in the API playground](https://docs.maitento.com/playground/?call=PUT%20%2Fnamespaces%2Fby-id%2F%7Bid%7D).

**Path parameters**

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | `uuid` | yes |  |

**Request body:** [`NamespaceCreateOrUpdateRequest`](https://docs.maitento.com/reference/types/namespace-create-or-update-request.md)

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | yes | The namespace's name, 1 to 200 characters, unique within the tenant. |

**Response:** [`Namespace`](https://docs.maitento.com/reference/types/namespace.md) (200)

```bash title="curl"
curl -X PUT "https://api.maitento.com/namespaces/by-id/<id>" \
  -H "Authorization: $MAITENTO_AUTH" \
  -H "Content-Type: application/json" \
  -d '{"name":"..."}'
```
```ts title="TypeScript"
await mt.namespaces.rename("b5f3d1a9-7e6c-4b4a-9a2e-8c0d1f3e5a7b", { name: "customer-support" });
```
```python title="Python"
mt.namespaces.rename("0f1e2d3c-4b5a-4968-8776-655443322110", "demo-2")
```

## `namespaces.webAccess`

```http
GET /namespaces/by-id/{id}/web-access
```

The namespace's web-access settings (its default web-download partition).

**Who can call it:** Admins and members, with an API key or a portal session. [Try it in the API playground](https://docs.maitento.com/playground/?call=GET%20%2Fnamespaces%2Fby-id%2F%7Bid%7D%2Fweb-access).

**Path parameters**

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | `uuid` | yes |  |

**Response:** [`WebAccessSettings`](https://docs.maitento.com/reference/types/web-access-settings.md) (200)

```bash title="curl"
curl -X GET "https://api.maitento.com/namespaces/by-id/<id>/web-access" \
  -H "Authorization: $MAITENTO_AUTH"
```
```ts title="TypeScript"
const settings = await mt.namespaces.webAccess("b5f3d1a9-7e6c-4b4a-9a2e-8c0d1f3e5a7b");
```
```python title="Python"
mt.namespaces.web_access("0f1e2d3c-4b5a-4968-8776-655443322110")
```

## `namespaces.setWebAccess`

```http
PUT /namespaces/by-id/{id}/web-access
```

Replaces the namespace's web-access settings (Tenant.Admin).

**Who can call it:** Tenant admins only, with an API key or a portal session. [Try it in the API playground](https://docs.maitento.com/playground/?call=PUT%20%2Fnamespaces%2Fby-id%2F%7Bid%7D%2Fweb-access).

**Path parameters**

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | `uuid` | yes |  |

**Request body:** [`WebAccessSettingsInput`](https://docs.maitento.com/reference/types/web-access-settings.md#in-a-request)

| Field | Type | Required | Description |
|---|---|---|---|
| `defaultWebDownloadPartitionId` | `uuid \| null` |  | The temporary partition web downloads go to by default. Null: none is set here (sending null clears it). |

**Response:** [`WebAccessSettings`](https://docs.maitento.com/reference/types/web-access-settings.md) (200)

```bash title="curl"
curl -X PUT "https://api.maitento.com/namespaces/by-id/<id>/web-access" \
  -H "Authorization: $MAITENTO_AUTH" \
  -H "Content-Type: application/json" \
  -d '{"defaultWebDownloadPartitionId":"..."}'
```
```ts title="TypeScript"
await mt.namespaces.setWebAccess("b5f3d1a9-7e6c-4b4a-9a2e-8c0d1f3e5a7b", { defaultWebDownloadPartitionId: "d6e5f4a3-b2c1-4d0e-9f8a-7b6c5d4e3f2a" });
```
```python title="Python"
mt.namespaces.set_web_access("0f1e2d3c-4b5a-4968-8776-655443322110", default_web_download_partition_id="4b5c6d7e-8f9a-4b0c-9d1e-2f3a4b5c6d7e")
```

## `namespaces.get`

```http
GET /namespaces/by-name/{name}
```

The namespace with this NAME. Throws `NotFoundError` when there is none.

**Who can call it:** Admins and members, with an API key or a portal session. [Try it in the API playground](https://docs.maitento.com/playground/?call=GET%20%2Fnamespaces%2Fby-name%2F%7Bname%7D).

**Path parameters**

| Name | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | yes |  |

**Response:** [`Namespace`](https://docs.maitento.com/reference/types/namespace.md) (200)

```bash title="curl"
curl -X GET "https://api.maitento.com/namespaces/by-name/<name>" \
  -H "Authorization: $MAITENTO_AUTH"
```
```ts title="TypeScript"
const namespace = await mt.namespaces.get("support");
```
```python title="Python"
mt.namespaces.get("demo")
```
