---
title: "Api Learn Activity Log Emit"
method: POST
path: "/api/learn/activity-log"
tags: ["Education"]
---

# Api Learn Activity Log Emit

`POST /api/learn/activity-log`

## Request

- Base URL: `https://www.oxfordledge.com` (the document declares no server; this is the origin it was published from)
- URL: `https://www.oxfordledge.com/api/learn/activity-log`
- Auth: none declared

Fire-and-forget INSERT of one user activity event.

Accepts JSON: {kind: str, ref_type?: str, ref_id?: str, meta?: dict}.

Validates kind against the closed enum + payload size + meta-as-
object before delegating to pg_emit_user_activity. Returns
{ok: bool, id: int|None}. The client never retries on ok=false
(the writers use fire-and-forget .catch() pattern, see
learning-paths.ts / reading-list.ts / glossary.ts).

Loss tolerance is acceptable here because the reading log is a
best-effort historical record, not a billing or auth surface
(CHAOS §2.1 review). Server-side INSERT failures are captured by
Sentry via the routes/api_errors.py middleware.

## Response `200`

Successful Response

- ActivityLogEmitResponse: `POST /api/learn/activity-log` response shape. Fire-and-forget contract: the FE writers (learning-paths.ts, reading-list.ts, glossary.ts) use `keepalive: true` and `.catch()` to swallow errors. The response shape here is for completeness / test ergonomics -- the FE never reads it. On INSERT success `ok=true` + `id=<bigserial>`; on any failure `ok=false` + `id=null` (including PG-unavailable / brownfield pre-v113 / CHECK constraint violation / FK orphan). The route ALWAYS returns 200 so the client .catch() never fires (loss tolerance per CHAOS §2.1).
  - `ok` boolean, required: True iff the INSERT succeeded. False on any DB error (PG unavailable, brownfield pre-v113, CHECK constraint violation, FK orphan).
  - `id` integer, nullable: The new row's BIGSERIAL id on success; None on failure. Unused by the current FE writers (fire-and-forget) but surfaced for test + future dedupe needs.

---

[API](https://skmtc.dev/oxfordledge/apis/oxford-ledge-api.md) · [All operations](https://skmtc.dev/oxfordledge/apis/oxford-ledge-api/llms.txt) · [OpenAPI document](https://skmtc.dev/oxfordledge/apis/oxford-ledge-api/revisions/e832a1260f0b?raw)
