> ## 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.

# Activate Agent

> Activate an agent to start a new session and obtain a session token for memory operations.

## Overview

Starts a new session for the specified agent and returns a JWT **session token** that authorizes subsequent memory operations (`remember`, `recall`, `answer`, etc.). The session is initialized with the server's default duration (typically 6 hours) and tracked in `~/.memanto/sessions/`.

The endpoint takes **no request body**; session duration is controlled by server configuration (`SESSION_DEFAULT_DURATION_HOURS`).

An agent has one session at a time. Activating while a session is live replaces it: the new token is returned and the previous token stops working, so any other client still using it gets `401` and must activate again.

In addition to returning `session_token` in the response body, this endpoint sets an `HttpOnly`, `SameSite=Strict` cookie (`memanto_session_token`) so browser clients can authenticate without reading the token from JavaScript. See [Cookie-Based Authentication](https://docs.memanto.ai/api-reference/authentication.md#cookie-based-authentication-browser-web-ui-clients).

## Authentication

**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.

## Path Parameters

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

The unique identifier of the agent to activate.

```bash cURL theme={null}
curl -X POST "http://localhost:8000/api/v2/agents/my-agent/activate"
```

```json 200 - OK theme={null}
{
  "session_id": "9f733fdb-ebf2-494e-8eb6-fb3320d6020d",
  "session_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "agent_id": "my-agent",
  "namespace": "memanto_agent_my-agent",
  "started_at": "2026-05-09T02:40:00.313078Z",
  "expires_at": "2026-05-09T08:40:00.313078Z",
  "pattern": "support",
  "status": "active"
}
```

```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 404 - Not Found theme={null}
{
  "detail": {
    "error": "AgentNotFound",
    "message": "Agent 'my-agent' not found",
    "details": {}
  }
}
```

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

## Next Steps

After activating an agent, store the returned `session_token` and use it in the `X-Session-Token` header for:

* [Remember](https://docs.memanto.ai/api-reference/data/remember.md) to store new memories
* [Recall](https://docs.memanto.ai/api-reference/search/recall.md) to search stored memories
* [Generate AI Answer](https://docs.memanto.ai/api-reference/ai/generate-ai-answer.md) to synthesize a grounded response
* [Get Current Session](https://docs.memanto.ai/api-reference/sessions/get-current-session.md) to inspect the active session


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