---
title: "Explicitly close an active episode (triggers consolidation)"
method: POST
path: "/active-memory/close-episode"
tags: ["active-memory"]
---

# Explicitly close an active episode (triggers consolidation)

`POST /active-memory/close-episode`

## Request

- Base URL: `https://api.getmetacognition.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.getmetacognition.com/active-memory/close-episode`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/metacognition/apis/tex-api/docs/active-memory/close-episode/post.ts> (a function with typed inputs; its response is checked against the schema)

Mark the episode as closed in the Durable Object.

The Worker's DO alarm handler will pick up the closed episode on the next
decay check and enqueue it for consolidation.  Alternatively, the caller
can pass `reason="explicit"` to signal an intentional close vs. timeout.

## Request body

- CloseActiveEpisodeRequest
  - `agent_id` string, required
  - `user_hash` string, nullable: Hashed user ID. If omitted, backend derives it from authenticated org_id + effective user scope.
  - `scope_user_id` string, nullable: Optional effective user_id for agent/service tokens. If provided, user_hash must match server-derived hash for this user.
  - `episode_id` string, required
  - `reason` string, nullable

## Response `200`

Successful Response

- object

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/metacognition/apis/tex-api.md) - [All operations](https://skmtc.dev/metacognition/apis/tex-api/llms.txt) - [OpenAPI document](https://skmtc.dev/metacognition/apis/tex-api/revisions/3bef47e50f2e?raw)
