---
title: "Exchange a cookie session for raw Supabase tokens"
method: POST
path: "/auth/cli-exchange"
tags: ["Auth"]
---

# Exchange a cookie session for raw Supabase tokens

`POST /auth/cli-exchange`

## Request

- Base URL: `https://api.mnemom.ai/v1`
- URL: `https://api.mnemom.ai/v1/auth/cli-exchange`
- Auth: API key in cookie `mnemom_session`

One-shot endpoint called by the SPA during the CLI login flow (browser → localhost handoff). Requires a valid `mnemom_session`. Returns access + refresh tokens in the JSON body. Does not modify cookies.

## Response `200`

Tokens returned.

- object
  - `access_token` string, required: Supabase JWT.
  - `refresh_token` string, required
  - `expires_in` integer, required: Seconds until access_token expires.
  - `user_id` string, uuid, required
  - `user_email` string, email, nullable

## Other responses

- `401`: Authentication required
- `403`: Cross-origin write refused (`cross_origin_rejected`). A state-changing request that carries the browser session cookie must come from a first-party origin (`Origin`, or failing that `Referer`) and must not send a form-style body (text/plain, urlencoded, multipart) the operation does not declare. Bearer and API-key callers are never subject to this check.
- `429`: Rate-limit exceeded. The global per-IP limiter (100 requests/minute, applied to every `/v1/*` route) rejected this request. Back off until the window resets — `Retry-After` carries the cooldown in seconds and `X-RateLimit-Reset` the absolute reset time.
- `500`: Server error — request was well-formed but the server failed to fulfill it. Typically a downstream dependency (DB / RPC / external API) returned an unexpected error.
- `503`: An upstream dependency is currently unavailable. The request was not processed; retry after the cooldown window.

---

[API](https://skmtc.dev/mnemom/apis/mnemom-api.md) · [All operations](https://skmtc.dev/mnemom/apis/mnemom-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mnemom/apis/mnemom-api/revisions/274b7a6ea182?raw)
