# Contact memory API

> Inspect and correct what AI agents remember about contacts: facts, todos and suppressions.

Inspect and correct what the AI agents (personas) remember about contacts: facts, todos,
do-not-learn suppressions and the episodes they came from. Memory is per (contact, persona).

- Base path: `/memory/v1/`; Connect/gRPC `pingx.memory.v1.MemoryService`.
- Auth: `Authorization: Bearer <key>`; `memory:read` for List/Get, `memory:write` for everything else
  (`memory` = both). The org comes from the key only; another org's contact is "not found".
- Writes are applied synchronously. If the memory backend is briefly unavailable you get
  UNAVAILABLE (503); it is safe to retry.

| RPC | REST | Scope |
|---|---|---|
| ListContactActivity | `GET /memory/v1/contacts?search=&includeTest=&pageSize=&pageToken=` | read |
| GetContactMemory | `GET /memory/v1/contacts/{contactId}/memory?agentId=` | read |
| GetFactProvenance | `GET /memory/v1/contacts/{contactId}/personas/{agentId}/facts/{factId}/provenance` | read |
| ListRecentMessages | `GET /memory/v1/contacts/{contactId}/messages?pageSize=` | read |
| ListTestContacts | `GET /memory/v1/test-contacts` | read |
| CreateTestContact | `POST /memory/v1/test-contacts` | write |
| ForgetFact | `POST .../personas/{agentId}/facts/{factId}:forget` | write |
| AmendFact | `POST .../personas/{agentId}/facts/{factId}:amend` | write |
| RenewFact | `POST .../personas/{agentId}/facts/{factId}:renew` | write |
| CloseTodo | `POST .../personas/{agentId}/todos/{todoId}:close` | write |
| ReopenTodo | `POST .../personas/{agentId}/todos/{todoId}:reopen` | write |
| LiftSuppression | `POST .../personas/{agentId}/suppressions:lift` | write |
| ForgetAllForPersona | `POST .../personas/{agentId}/memory:forgetAll` | write, destructive |
| ClearForPersona | `POST .../personas/{agentId}/memory:clear` | write, destructive |
| EraseSubject | `POST /memory/v1/contacts/{contactId}:erase` | write, destructive |

(`...` = `/memory/v1/contacts/{contactId}`.)

## Irreversible operations

`ForgetAllForPersona` (soft-deletes every active fact of one persona; no bulk undo), `ClearForPersona`
(hard-deletes one persona's facts, todos, rules and episodes) and `EraseSubject` (right to be forgotten,
all personas, writes an erasure marker) cannot be undone through the API. Each requires
`"confirm": true` in the body, otherwise INVALID_ARGUMENT and nothing is sent to the backend.

## Notes

- Write ids (`agentId`, `factId`, `todoId`) must be > 0; `AmendFact.factValue`, `CloseTodo.evidence`
  and `LiftSuppression.factKey` are required; `RenewFact.expiresAt` must be RFC 3339.
- Pagination: `ListContactActivity` returns `nextPageToken` (opaque); `ListRecentMessages` is the N
  most recent (`pageSize`, default 50, max 200), not paginated.
- Results of writes: `affected` rows; 0 means nothing matched.

