> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moorcheh.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Namespace

> Delete a namespace using the Python client

## namespaces.delete

Removes a namespace and every item in it. The operation runs in the background. Use the returned `job_id` with [namespaces.delete\_job\_status](/on-prem/python-client/namespaces/delete-job-status) to poll until completion.

```python theme={null}
client.namespaces.delete(namespace_name: str) -> dict[str, Any]
```

**API:** `DELETE /namespaces/{namespace_name}` — see [Delete namespace](/on-prem/api-references/namespaces/delete)

### Parameters

<ParamField body="namespace_name" type="str" required>
  Name of the namespace to delete.
</ParamField>

**Returns:** `dict[str, Any]` — `status` and `job_id` for the async delete job.

**Raises:** `MoorchehApiError` — HTTP **404** when the namespace is not found.

### Examples

```python Delete Namespace theme={null}
from moorcheh import MoorchehClient

with MoorchehClient("http://localhost:8080") as client:
    resp = client.namespaces.delete("my-documents")
    job_id = resp["job_id"]
    print(f"Delete job started: {job_id}")
```

```python Poll Until Complete theme={null}
import time
from moorcheh import MoorchehClient

with MoorchehClient("http://localhost:8080") as client:
    resp = client.namespaces.delete("my-documents")
    job_id = resp["job_id"]

    while True:
        job = client.namespaces.delete_job_status("my-documents", job_id)
        if job["status"] in ("completed", "failed"):
            break
        time.sleep(0.5)
```

### Error Handling

```python Error Handling Example theme={null}
from moorcheh import MoorchehClient, MoorchehApiError

with MoorchehClient("http://localhost:8080") as client:
    try:
        resp = client.namespaces.delete("my-documents")
    except MoorchehApiError as e:
        if e.status_code == 404:
            print("Namespace not found")
        else:
            raise
```

| Status | Cause               |
| ------ | ------------------- |
| 404    | Namespace not found |

<Warning>
  Deleting a namespace frees global item quota for all items that were in it. This cannot be undone.
</Warning>

## Related Operations

* [Delete Job Status](/on-prem/python-client/namespaces/delete-job-status) — poll delete progress
* [Create Namespace](/on-prem/python-client/namespaces/create) — add a namespace
* [API: Delete namespace](/on-prem/api-references/namespaces/delete)
* [CLI: moorcheh namespace-delete](/on-prem/cli/namespaces/delete)
