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

> ## Agent Instructions
> Start with /introduction/getting-started. Use the Direct Query API (POST /api/lens/query) with the Newton Fusion model (text, image, and video reasoning) or the Newton Omega encoder (time-series embeddings). ATAI_API_ENDPOINT is the base URL https://platform.u1.archetypeai.app with no version path; every endpoint path begins with /api. Pages whose descriptions are marked (Archived) document the legacy Lens runtime — do not use them for new projects.

# Delete Package

> Delete a package by id once no agent runs from it remain

Requires [version 2.0.0](https://docs.archetypeai.app/release-notes/2.0.x.md#v2-0-0) or later of the Archetype platform.

## Overview

This endpoint deletes a package by its `pkg_` id. The blueprint it held is untouched.

A run keeps the package it came from for its whole history, so a package that agents have been
run from returns `409`. List those runs with [List
Agents](https://docs.archetypeai.app/api-reference/agents/instances/list-agents.md) and `package_id`, delete them, then delete
the package.

## Request

**package\_id** `string` *required*

Package `pkg_` id.

## Response

Returns `204 No Content` with an empty body on success.

```bash cURL theme={"system"}
curl -X DELETE "$ATAI_API_URL/api/agents/packages/pkg_01jcb2x7m4qv8n3h5t6rk9dzs0" \
  -H "Authorization: Bearer $ATAI_API_KEY"
```

```python Python theme={"system"}
import os
import requests

base_url = os.environ["ATAI_API_URL"]
api_key = os.environ["ATAI_API_KEY"]

response = requests.delete(
    f"{base_url}/api/agents/packages/pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
    headers={"Authorization": f"Bearer {api_key}"},
)

if response.status_code == 204:
    print("Package deleted")
else:
    print(f"Error: {response.json()['errors']}")
```

```javascript JavaScript theme={"system"}
const response = await fetch(
  `${process.env.ATAI_API_URL}/api/agents/packages/pkg_01jcb2x7m4qv8n3h5t6rk9dzs0`,
  {
    method: 'DELETE',
    headers: {
      'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
    }
  }
);

if (response.status === 204) {
  console.log('Package deleted');
} else {
  const body = await response.json();
  console.error('Error:', body.errors);
}
```

```json 204 - Package deleted theme={"system"}
```

```json 403 - Project cannot be modified theme={"system"}
{
  "errors": [
    {
      "code": "forbidden",
      "message": "The package's project cannot be modified.",
      "suggestion": null,
      "error_uid": "err-xxxxxxxx"
    }
  ]
}
```

```json 404 - Package not found theme={"system"}
{
  "errors": [
    {
      "code": "not_found",
      "message": "Package 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0' not found",
      "suggestion": null,
      "error_uid": "err-xxxxxxxx"
    }
  ]
}
```

```json 409 - Agents run from the package theme={"system"}
{
  "errors": [
    {
      "code": "conflict",
      "message": "package 'pkg_01jcb2x7m4qv8n3h5t6rk9dzs0' has agents run from it; delete them first (list them with `GET /api/agents/instances?package_id=pkg_01jcb2x7m4qv8n3h5t6rk9dzs0`)",
      "suggestion": null,
      "error_uid": "err-xxxxxxxx"
    }
  ]
}
```

## Important Notes

> [!NOTE]
>
> * A `409` means agents have been run from the package. Delete those runs first; the message links the [List Agents](https://docs.archetypeai.app/api-reference/agents/instances/list-agents.md) query that finds them.
> * Outside a project, a user who is not an org admin lists only their own runs. If other users' runs block the delete, the `409` message says so, and their owner or an org admin must delete them.
> * A `403` means you can see the package's project but cannot modify it.
> * A `404` means the package does not exist, belongs to another organization, or is in a project you cannot see.
> * Success returns `204` with no body. Check the status code rather than parsing a response.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.