---
title: "Set Policy"
method: PUT
path: "/api/v2/agents/{agent_id}/policy"
tags: ["Sessions & Agents", "Memory Operations"]
---

# Set Policy

`PUT /api/v2/agents/{agent_id}/policy`

Replace the agent's expiry policy (Session-based).

Saving a policy does not expire anything on its own — run the apply
endpoint, or let the nightly sweep pick it up.

Requires:
- X-Session-Token: {session_token}

## Path parameters

- `agent_id` string, required

## Headers

- `x-session-token` string, nullable
- `X-Api-Key` string, nullable

## Cookies

- `memanto_session_token` string, nullable

## Request body

- MemoryPolicy — The full expiry policy for one agent.
  - `version` integer
  - `retention` object
  - `rules` PolicyRule[]
    - `name` string, required
    - `match` PolicyMatch — Conditions a memory must satisfy for a rule to fire. Every field that is set must match (AND). An empty match block matches every memory, which is how a catch-all rule is written.
      - `type` string[], nullable
      - `tags` string[], nullable
      - `source` string[], nullable
      - `provenance` string[], nullable
      - `confidence_below` number, nullable
    - `expire_after` string
  - `purge_expired_after` string

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/moorcheh-ai/apis/memanto-memory-that-ai-agents-love.md) · [All operations](https://skmtc.net/moorcheh-ai/apis/memanto-memory-that-ai-agents-love/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/moorcheh-ai/memanto-memory-that-ai-agents-love/revisions/f8fc41287ced/schema)
