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

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](/api-reference/authentication#cookie-based-authentication-browser-web-ui-clients).

## Authentication

<ParamField header="Authorization" type="string">
  `Bearer <key>` — required unless the request originates from a loopback client. See [Management Endpoint Authentication](/api-reference/authentication#management-endpoint-authentication-agent-lifecycle).
</ParamField>

<ParamField header="X-Api-Key" type="string">
  Alternative to `Authorization: Bearer` — same credential.
</ParamField>

## Path Parameters

<ParamField path="agent_id" type="string" required>
  The unique identifier of the agent to activate.
</ParamField>

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

<ResponseExample>
  ```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": "..."
      }
    }
  }
  ```
</ResponseExample>

## Next Steps

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

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