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

# Create Agent

> Create a new agent to establish a dedicated Moorcheh namespace for storing and retrieving memories.

## Overview

Create a new agent namespace for storing and retrieving memories. Each agent receives a unique `agent_id` which acts as an isolated context container in Moorcheh (`memanto_agent_{agent_id}`).

## Authentication

Memanto validates Moorcheh credentials **on the server** using `MOORCHEH_API_KEY` (environment / server configuration).

**Authorization** `string`

`Bearer <key>` — required unless the request originates from a loopback client. See [Management Endpoint Authentication](https://docs.memanto.ai/api-reference/authentication.md#management-endpoint-authentication-agent-lifecycle).

**X-Api-Key** `string`

Alternative to `Authorization: Bearer` — same credential.

**Content-Type** `string` *required*

Must be `application/json`

## Body

**agent\_id** `string` *required*

Unique agent identifier (alphanumeric, hyphens, underscores only).

**pattern** `string`

Agent pattern for memory organization. One of: `support`, `project`, `tool`. Defaults to `support`.

**description** `string`

Optional human-readable description of the agent.

```bash cURL theme={null}
curl -X POST "http://localhost:8000/api/v2/agents" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "customer-support",
    "pattern": "support",
    "description": "Handles customer inquiries"
  }'
```

```json 201 - Created theme={null}
{
  "agent_id": "customer-support",
  "namespace": "memanto_agent_customer-support",
  "pattern": "support",
  "description": "Handles customer inquiries",
  "created_at": "2026-05-04T10:30:00.000000",
  "last_session": null,
  "memory_count": 0,
  "session_count": 0,
  "status": "ready"
}
```

```json 401 - Unauthorized (Management Auth Required) theme={null}
{
  "detail": "Unauthorized. Agent management endpoints require either a loopback client or a valid management credential (Authorization: Bearer <key> or X-Api-Key)."
}
```

```json 409 - Conflict theme={null}
{
  "detail": {
    "error": "AgentAlreadyExists",
    "message": "Agent 'customer-support' already exists",
    "details": {}
  }
}
```

```json 422 - Validation Error theme={null}
{
  "detail": [
    {
      "type": "missing",
      "loc": [
        "body",
        "agent_id"
      ],
      "msg": "Field required",
      "input": {}
    }
  ]
}
```

```json 500 - Server Error theme={null}
{
  "detail": {
    "error": "InternalServerError",
    "message": "An unexpected error occurred",
    "details": {
      "original_error": "..."
    }
  }
}
```

Common causes of `500` include the server missing `MOORCHEH_API_KEY`, an invalid key (Memanto may fail at startup), or failure to create the namespace in Moorcheh.

## Next Steps

After creating a new agent, you can:

* [Activate Agent](https://docs.memanto.ai/api-reference/sessions/activate-agent.md) to start a session and obtain an operational token
* [List Agents](https://docs.memanto.ai/api-reference/agents/list-agents.md) to verify it was created
* [Get Agent](https://docs.memanto.ai/api-reference/agents/get-agent.md) to retrieve its configuration details


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