You are helping me build an integration with the Endless Pursuit API: anything that tracks a person (a watch, a desktop timer, a gym app, a script) writes logs into their Endless Pursuit days, the same logs the app writes, so their day card, streak, circle and challenges follow. Everything you need is below. The full contract (OpenAPI 3.1) is https://www.endlesspursuit.app/developers/openapi.yaml; the docs are https://www.endlesspursuit.app/developers. Base URL: https://www.endlesspursuit.app/api/v1. All paths below are relative to it. # How to work 1. Before writing code, ask me: what tracker or data I want to sync into Endless Pursuit, which language and platform, and whether this is just for my own account (a personal access token is enough) or an app other people connect (OAuth). 2. Ask for the fewest scopes that do the job. Writing only? `logs:write` alone. Add `logs:read` only to read logs back. 3. OAuth: implement PKCE (S256) correctly: a fresh random code_verifier (43–128 chars) per sign-in, code_challenge = base64url(SHA-256(verifier)) without padding, a random `state` checked on return. Desktop apps listen on a loopback redirect (`http://127.0.0.1:/callback`, the exact URI registered). 4. Store tokens securely (the OS keychain or credential store, or encrypted at rest on a server). Never log them, never put them in URLs, never commit them. 5. On every write send an `Idempotency-Key` (a new UUID per logical write, reused on its retries) and, for anything from another system, a stable `external_id` (and `source` with a personal token). 6. Use `POST /logs/batch` (up to 100 per call) for backfills and syncs. 7. Respect the rate limit: on `429`, wait `Retry-After` seconds, then retry; watch `X-RateLimit-Remaining`. 8. On `401`: refresh the access token once (store the new refresh token first); if refreshing fails (`invalid_grant`), send the person through consent again. 9. Give the person a Disconnect that calls `POST /oauth/revoke` with the refresh token and deletes the stored tokens. 10. Handle errors gracefully: show `error.message` to the person, keep `X-Request-Id` in logs, treat `already` and `covered` as success, and never retry a `4xx` other than `409 idempotency_busy` and `429`. # Testing a script on my own account (personal access token) 1. For a script on my own account: run `GET /me` first and check it answers 200 JSON (an HTML page means a wrong base URL). 2. Use a test `source` (e.g. `my-script-test`) and unique external ids, at times earlier today (check each answer’s `day` is my local today; avoid the first hours after midnight) that can’t clash with my real logs. Create, send again (expect `"outcome": "already"`; a focus block that overlaps one I already have answers `"covered"`), list back by `source`, then delete everything the test made and list again to confirm it’s gone. # Testing an app other people connect (OAuth) 1. Register the app: `POST /apps` with my personal access token that has `apps:write` (I make it in the Endless Pursuit app under Settings → API access). Use a loopback or test redirect URI. 2. Connect it with my own Endless Pursuit account. The app is in development, so at most 2 accounts can connect it. 3. Run an end-to-end check and show me the output: create a log, send the same `external_id` again and see `"outcome": "already"`, change it with PATCH, list it back with `GET /logs?source=…&external_id=…`, delete it, then disconnect (revoke) and confirm the old token answers 401. 4. Clean up everything the test created. # Delivery 1. A README with setup steps, every environment variable (client id, redirect URI, and where tokens are stored), how to run it, and screenshots of connecting, a synced log and disconnecting. 2. When it works, help me ask for review so anyone can connect it: `POST /apps/{client_id}/review` with `description` (what it does, why each scope), `scopes`, `privacy_url` (https), `media_urls` (1–10 https screenshots or a video of the whole flow, connecting and disconnecting included), `contact_email`, and optional `notes`. Check it against the quality standard first. # Quality standard (every app must meet it to be approved) - correct idempotency and no duplicates - rate limits respected - fewest scopes - a privacy policy - no selling or ad use of Endless Pursuit data - honest naming - a working disconnect - graceful errors # Log shape Every log the API returns: { id, module, started_at, ended_at|null, day, minutes, private, note|null, live, shows_up, facts: {key: number}, source: { kind, name, external_id, yours }, created_at, editable_until, editable, , split_into? }. # The API ## Quickstart Make a personal access token in the app: **Settings → API access**. Pick what it may do, copy it (it’s shown once) and keep it out of your code. Who am I: ``` export EP_TOKEN=ep_pat_… curl "https://www.endlesspursuit.app/api/v1/me" \ -H "Authorization: Bearer $EP_TOKEN" ``` Response: ``` { "id": "5d0c4a52-8f1e-4b7a-9a43-0e6f2b9c1d77", "username": "alex", "display_name": "Alex Morgan", "timezone": "Europe/London", "token": { "kind": "personal", "scopes": ["logs:read", "logs:write", "modules:read", "profile:read"], "app": null } } ``` Then log a run. It lands on today’s card, and counts for the streak and the km challenge. Log a run: ``` curl https://www.endlesspursuit.app/api/v1/logs \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "module": "running", "started_at": "2026-12-03T06:30:00Z", "minutes": 28, "activity": { "sport": "run", "distance_km": 5.2, "title": "Morning run" } }' ``` Response, 201: ``` { "id": "0b6c2f1e-3d4a-4c1b-8e2f-7a9d5c3b1e60", "module": "running", "started_at": "2026-12-03T06:30:00Z", "day": "2026-12-03", "minutes": 28, "private": false, "shows_up": true, "facts": { "km": 5.2, "run_minutes": 28, "activity_minutes": 28 }, "source": { "kind": "api", "name": "api", "external_id": null, "yours": true }, "created_at": "2026-12-03T07:01:12Z", "editable_until": "2026-12-04T07:01:12Z", "editable": true, "activity": { "sport": "run", "distance_km": 5.2, "title": "Morning run" }, "outcome": "created" } ``` Every call carries `Authorization: Bearer `. Bodies and answers are JSON, errors included: an HTML answer means a wrong URL. Times are ISO 8601 with a zone (`Z` or `+01:00`); a log’s `day` is its start in the person’s time zone (`timezone` from `GET /me`). ## Tokens and scopes Two kinds of token, the same API. - `ep_pat_…`: **Personal access token.** For your own scripts and devices, on your own account. Made in the app under Settings → API access, revoked there too. No review needed. - `ep_at_…`: **OAuth access token.** For an app other people connect. The person approves it, the app gets an hour-long access token and a refresh token. See [OAuth for apps](https://www.endlesspursuit.app/developers#oauth). Endless Pursuit’s own desktop and watch trackers may also send the person’s app session; that’s for first-party apps only. Each token carries scopes. A call outside them answers `403 scope_missing`. Ask for the fewest you need. - `profile:read`: Name, username and time zone (`GET /me`). - `modules:read`: Modules, exercises, projects and custom trackers. - `logs:read`: Reading logs. - `logs:write`: Adding, changing and deleting logs; making and changing trackers; sending signals. - `apps:write`: Registering and managing OAuth apps, asking for review. Personal tokens only; an app can never ask for it. ## Logging each module One endpoint for everything: `POST /logs`. Send the `module`, when it happened, and the module’s own object. The numbers on the day card (`km`, `volume_kg`…) are worked out from it the way the app does; read them back in `facts`. Fact keys differ by module and sport (a run adds `km` and `run_minutes`, a walk `walk_km`, focus `focus_minutes` and `focus_blocks`); `GET /modules` lists each module’s. - `focus`: `focus` - `training`: `workout` (workouts) - `running`: `activity` (Activities: runs, walks, hikes, rides, swims) - `nutrition`: `meal` - `weight`: `weight` - `reading`: `reading` - `custom`: `tracker` (custom trackers) **When:** `started_at` and `ended_at`, or either one with `minutes`. Nothing means now. Nothing may start more than five minutes in the future. `minutes` is the time spent (focused minutes, moving time), 0 to 1440; it defaults to the gap between start and end and may be less than it. Optional on every log: `note` (up to 280 characters, only its owner reads it), `private`, `source` and `external_id` (up to 200 characters). ### Focus `focus` A block of focused work. `about` says what it was for (up to 60 characters). `minutes` is the focused time, 1 to 720. `style` is `free`, `pomodoro` or `past`; `rounds` counts pomodoros. Add `project_id` (from `GET /projects`) and `task_id` to put it on one of the person’s projects. Focus never double-counts: see [the overlap rule](https://www.endlesspursuit.app/developers#focus). Request: ``` curl https://www.endlesspursuit.app/api/v1/logs \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "module": "focus", "started_at": "2026-12-03T08:00:00Z", "ended_at": "2026-12-03T08:55:00Z", "minutes": 50, "source": "desk-timer", "external_id": "session-1842", "focus": { "about": "Landing copy", "style": "pomodoro", "rounds": 2 } }' ``` ### Workout `training` Exercises come from `GET /exercises`, each with how it’s tracked (weight and reps, reps, time or distance). A set takes `kg`, `reps`, `seconds`, `metres`, `rpe`, `warmup`, `at`. Volume, sets, reps and personal records follow; warm-ups count to volume, not to sets or reps. Request: ``` curl https://www.endlesspursuit.app/api/v1/logs \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "module": "training", "started_at": "2026-12-03T17:00:00Z", "ended_at": "2026-12-03T17:58:00Z", "workout": { "title": "Push day", "exercises": [ { "id": "bench_press", "sets": [ { "kg": 60, "reps": 8, "warmup": true }, { "kg": 100, "reps": 5 }, { "kg": 100, "reps": 4, "rpe": 9 } ] }, { "id": "push_up", "sets": [{ "reps": 20 }, { "reps": 18 }] } ] } }' ``` ### Activity `running` `sport` is `run`, `trail_run`, `walk`, `hike`, `ride`, `mountain_bike` or `swim`. Distance in `distance_km` or `distance_m`; `minutes` is moving time; `climb_m`, `title`, `effort` (1–10) are optional. A walk is `"module": "running"` with `"activity": { "sport": "walk", "distance_km": 1 }`. The route is a Google encoded polyline (precision 5); others see it with 200 m cut off each end. `map_hidden` keeps the map to its owner. Request: ``` curl https://www.endlesspursuit.app/api/v1/logs \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "module": "running", "started_at": "2026-12-03T06:30:00Z", "minutes": 28, "source": "garmin-sync", "external_id": "garmin-17012345", "activity": { "sport": "run", "distance_km": 5.2, "climb_m": 40, "title": "Morning run", "route": { "polyline": "_p~iF~ps|U_ulLnnqC_mqNvxq`@" } } }' ``` A 1 km walk, response (trimmed): ``` { …, "module": "running", "minutes": 15, "facts": { "walk_km": 1, "activity_minutes": 15 }, "activity": { "sport": "walk", "distance_km": 1 }, "outcome": "created" } ``` ### Meal `nutrition` Send `items` (each `name`, `kcal`, and optional `grams`, `protein_g`, `carbs_g`, `fat_g`), or one set of totals (`name`, `kcal`, `protein_g`, `carbs_g`, `fat_g`). `slot` (`breakfast`, `lunch`, `dinner`, `snack`) defaults from the time of day. A meal never counts as showing up. Request: ``` curl https://www.endlesspursuit.app/api/v1/logs \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "module": "nutrition", "meal": { "slot": "lunch", "items": [ { "name": "Chicken rice bowl", "grams": 450, "kcal": 640, "protein_g": 45, "carbs_g": 70, "fat_g": 16 }, { "name": "Flat white", "kcal": 110, "protein_g": 6, "carbs_g": 9, "fat_g": 5 } ] } }' ``` ### Weight `weight` Kilograms, 20 to 400. Request: ``` curl https://www.endlesspursuit.app/api/v1/logs \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "module": "weight", "weight": { "kg": 80.4 } }' ``` ### Reading `reading` Pages read. With `book_id` (one of the person’s books) the book’s page moves on. Request: ``` curl https://www.endlesspursuit.app/api/v1/logs \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "module": "reading", "minutes": 30, "reading": { "pages": 18 } }' ``` ### Custom trackers `custom` Anything with a number: glasses of water, cold showers, words written. Make the tracker once (`agg` is how a day’s values add up: `sum`, `max` or `last`), then log to its `id`. `GET /trackers` lists the person’s own. Make a tracker: ``` curl https://www.endlesspursuit.app/api/v1/trackers \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "name": "Water", "unit": "glasses", "mode": "body", "agg": "sum" }' ``` Log to it: ``` curl https://www.endlesspursuit.app/api/v1/logs \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "module": "custom", "tracker": { "tracker_id": "6a1d1d2e-6f0b-4c9e-9d6a-0f3c3f1f5b10", "value": 2 } }' ``` ## Focus never double-counts The phone, a desktop tracker and a watch can all report the same hours. A focus log only fills time no other focus log of the person already covers: - Untouched: it lands as sent. - Overlapped: each free stretch of at least 5 minutes lands, with its share of the minutes. The answer is the first piece; `split_into` lists the ids of the others (their external ids are yours with `#2`, `#3`… added). - Fully covered: nothing lands. The answer is `200` with `"outcome": "covered"` and no log. Response, 200 (fully covered): ``` { "outcome": "covered", "external_id": "session-1843" } ``` ## Batches `POST /logs/batch` takes up to 100 logs. Each lands or fails on its own, and the answer lists every item in the order sent: `created`, `already`, `dismissed`, `covered` or `invalid` (with its `error`). Made for syncing and backfills: send `external_id` with each. Request: ``` curl https://www.endlesspursuit.app/api/v1/logs/batch \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "logs": [ { "module": "weight", "started_at": "2026-12-01T07:00:00Z", "source": "my-scale", "external_id": "scale-981", "weight": { "kg": 80.6 } }, { "module": "weight", "started_at": "2026-12-02T07:00:00Z", "source": "my-scale", "external_id": "scale-982", "weight": { "kg": 80.4 } } ] }' ``` Response, 200: ``` { "data": [ { "index": 0, "outcome": "created", "external_id": "scale-981", "log": { "id": "…" } }, { "index": 1, "outcome": "already", "external_id": "scale-982", "log": { "id": "…" } } ] } ``` ## Reading logs `GET /logs` lists the person’s logs, newest first. Filter by `module`, `since`, `until`, `source` and `external_id` (with `source`); `limit` is 1 to 100 (30 by default). `GET /logs/{id}` reads one. Request: ``` curl "https://www.endlesspursuit.app/api/v1/logs?module=running&since=2026-11-01T00:00:00Z&limit=50" \ -H "Authorization: Bearer $EP_TOKEN" ``` Response: ``` { "data": [ { "id": "0b6c2f1e-…", "module": "running", "day": "2026-12-03" } ], "next_cursor": "eyJ0IjoiMjAyNi0xMi0wM1QwNjozMDowMFoifQ" } ``` For the next page, send `next_cursor` back as `cursor` with the same filters. It’s `null` on the last page. ## Projects, signals and health days `GET /projects` lists the person’s projects still going, for a focus block’s `project_id`. Request: ``` curl "https://www.endlesspursuit.app/api/v1/projects" \ -H "Authorization: Bearer $EP_TOKEN" ``` Response: ``` { "data": [ { "id": "3c1f…", "name": "Landing page", "kind": null, "shipped": false, "due_on": "2026-12-20" } ] } ``` `POST /signals` sends what the person is doing, moment to moment (an app in front, steps, standing). Endless Pursuit turns signals into prompts like “Log that hour of focus?”, so the person decides what becomes a log. Up to 500 a call. The same `kind`, `device_id` and `started_at` update the one signal, so resending is safe. Signals older than 7 days or in the future are dropped quietly. Request: ``` curl https://www.endlesspursuit.app/api/v1/signals \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "signals": [ { "kind": "activity", "device_id": "mac-mini-office", "started_at": "2026-12-03T09:00:00Z", "ended_at": "2026-12-03T09:40:00Z", "category": "coding", "label": "Xcode" } ] }' ``` Response: ``` { "accepted": 1, "received": 1 } ``` `POST /health/days` keeps steps, sleep, heart and mindful minutes: one log a day for each, the same ones the phone fills from Apple Health and Health Connect. Send a day again as its totals grow and your day is updated in place (the 24-hour rule doesn’t lock it). A day Apple Health, Health Connect or another source already keeps is left alone (`kept`): one source per day. These logs never count as showing up. Read them back with `GET /logs?module=steps`; their numbers are in `health_day`. Request: ``` curl https://www.endlesspursuit.app/api/v1/health/days \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "source": "my-ring", "days": [ { "day": "2026-12-03", "steps": 8420, "distance_m": 6100, "sleep_min": 432, "sleep_start": "2026-12-02T23:05:00Z", "sleep_end": "2026-12-03T06:40:00Z", "resting_hr": 51, "mindful_min": 10 } ] }' ``` Response: ``` { "data": [{ "day": "2026-12-03", "steps": "created", "sleep": "created", "heart": "created", "mindful": "created" }] } ``` ## Retries and duplicates **Idempotency keys.** Send an `Idempotency-Key` header (any unique string up to 200 characters; a UUID is ideal) on every POST and PATCH. A retry with the same key and the same request within 24 hours gets the first answer back, marked `Idempotent-Replayed: true`. The same key with a different request is `422 idempotency_mismatch`; while the first is still being handled, `409 idempotency_busy`. A 5xx answer isn’t kept, so it can be retried with the same key. **`external_id` and `source`.** For logs that come from another system, send the id it knows them by. The same `external_id` from the same `source` lands once, ever: sending it again answers `200` with the full existing log plus `"outcome": "already"` (your id is at `source.external_id`; nothing in the body you sent is applied, so change a log with PATCH). `source` is yours to name for personal tokens (`garmin-sync`, `my-script`; lowercase letters, digits, `_`, `.`, `-`, 2–40 characters; default `api`). For OAuth apps the source is always the app. Find one: ``` curl "https://www.endlesspursuit.app/api/v1/logs?source=garmin-sync&external_id=garmin-17012345" \ -H "Authorization: Bearer $EP_TOKEN" ``` ## Changing and deleting A log can be changed for 24 hours after it reached Endless Pursuit (`editable_until` on every log), then it locks: `409 log_locked`. Deleting is allowed any time. Backfilling is fine: a log about last month, sent today, is open to change until tomorrow. A log still live in the app (a session going on) can’t be changed. `PATCH /logs/{id}` takes only what changes. The module’s object is merged one level deep (a new title keeps the distance); arrays such as sets and meal items are replaced whole. The module can’t change. Rename a run: ``` curl -X PATCH https://www.endlesspursuit.app/api/v1/logs/0b6c2f1e-3d4a-4c1b-8e2f-7a9d5c3b1e60 \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "activity": { "title": "Hills" } }' ``` Delete it: ``` curl -X DELETE https://www.endlesspursuit.app/api/v1/logs/0b6c2f1e-3d4a-4c1b-8e2f-7a9d5c3b1e60 \ -H "Authorization: Bearer $EP_TOKEN" ``` - An OAuth app may change or delete only the logs it wrote (`403 not_your_log`). A personal token may change any of its owner’s logs the API can reach. - A log the person deleted in the app stays deleted. Sending it again answers `409 log_dismissed` (`dismissed` in a batch). - A log deleted through the API by its writer can be sent again later with the same `external_id`. ## Privacy - A token only ever reads and writes its owner’s own logs. Nobody else’s, ever. - `"private": true` keeps a log’s numbers to its owner. It still counts as showing up. - A log’s note is only ever read by its owner. - The journal and the vision board are never reachable through the API. - People see every connected app in Settings → API access and can disconnect it any time. - Endless Pursuit data is never sold or used for ads, and apps that connect must hold to the same. ## Rate limits 120 calls a minute per personal token, or per app and person. Every answer says where you stand; past the limit it’s `429 rate_limited` with `Retry-After` in seconds. Syncing lots of logs? Use [batches](https://www.endlesspursuit.app/developers#batch). - `X-RateLimit-Limit`: Calls allowed a minute. - `X-RateLimit-Remaining`: Calls left this minute. - `X-RateLimit-Reset`: When the minute ends, in Unix seconds. - `Retry-After`: On a 429: seconds to wait. ## Errors Every error has the same shape, and every answer carries an `X-Request-Id`. `field` names the input that’s wrong, as a path (`activity.distance_km`), when there is one. Response, 409: ``` { "error": { "code": "log_locked", "message": "This log is past its 24 hours and can no longer be changed. You can still delete it.", "request_id": "req_7f3a2c" } } ``` - `400 invalid_request`: The body or query can’t be read, or a field is wrong (see `field`). - `401 token_invalid`: No token, or a wrong, expired or revoked one. - `403 scope_missing`: The token doesn’t carry the scope this call needs. - `403 account_inactive`: The token’s account isn’t active. - `403 not_your_log`: An OAuth app tried to change a log it didn’t write. - `404 not_found`: No such thing, or not the token owner’s. - `409 log_locked`: Past its 24 hours. It can still be deleted. - `409 log_dismissed`: The person deleted this log in the app; it stays deleted. - `409 idempotency_busy`: The first request with this key is still being handled. - `422 idempotency_mismatch`: This key was used for a different request. - `422 …`: Validation: `log_in_future`, `module_closed`, `exercise_unknown`, `book_not_found`, `project_not_found`, `fact_not_a_number` and others. - `429 rate_limited`: Too many calls. Wait for `Retry-After`. - `503 api_paused`: The API is paused for a while. Try again later. The OAuth endpoints answer in the RFC 6749 shape instead: `{ "error": "invalid_grant", "error_description": "…" }` (`invalid_request`, `invalid_grant`, `unsupported_grant_type`, `invalid_client`). ## OAuth for apps For an app other people connect: the authorization code flow with PKCE (S256 only). Phone and desktop apps are public clients and prove themselves with PKCE alone; an app with a server that can keep a secret is confidential and also gets a `client_secret`. ### 1. Register the app With a personal token that has `apps:write` (made in the app under Settings → API access). Redirect URIs match exactly: https; http only on `127.0.0.1`, `localhost` or `[::1]` (desktop apps, e.g. `http://127.0.0.1:8765/callback`, with the port you listen on); or an app scheme with a dot (`com.example.app:/callback`). `homepage_url` and `logo_url` (a square picture) are https only. Request: ``` curl https://www.endlesspursuit.app/api/v1/apps \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "name": "Desk Timer", "description": "Logs focus sessions from your Mac.", "homepage_url": "https://desktimer.example", "redirect_uris": ["http://127.0.0.1:8765/callback"], "confidential": false }' ``` Response, 201 (trimmed): ``` { "client_id": "epc_3f9a1c0d2b7e4a6f8c1d", "name": "Desk Timer", "redirect_uris": ["http://127.0.0.1:8765/callback"], "confidential": false, "status": "development", "dev_max_users": 2, "users": 0, "review": null } ``` Keep the `client_id` (`epc_…`). With `"confidential": true` the answer also carries the `client_secret`, once; `POST /apps/{client_id}/secret` makes a new one. A new app is in development: see [review](https://www.endlesspursuit.app/developers#review). ### 2. Send the person to approve it Make a random `code_verifier` (43 to 128 characters), and send its SHA-256, base64url without padding, as `code_challenge`. `scope` is space-separated, from `profile:read`, `modules:read`, `logs:read` and `logs:write`. `state` comes back as sent; check it. Authorization URL (one line): ``` https://www.endlesspursuit.app/oauth/authorize ?response_type=code &client_id=epc_3f9a1c0d2b7e4a6f8c1d &redirect_uri=http%3A%2F%2F127.0.0.1%3A8765%2Fcallback &scope=logs%3Aread%20logs%3Awrite &state=af0ifjsldkj &code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM &code_challenge_method=S256 ``` The person signs in, sees your app’s name and what it may do, and allows it. On a phone with the app, the link opens in the app. Then they come back to your `redirect_uri` with `?code=…&state=…`, or `?error=access_denied&state=…` if they said no. ### 3. Swap the code for tokens Form-encoded (JSON works too). The code is good once, for ten minutes. Confidential clients add `client_secret`, in the body or with HTTP Basic. Request: ``` curl https://www.endlesspursuit.app/api/v1/oauth/token \ -d grant_type=authorization_code \ -d client_id=epc_3f9a1c0d2b7e4a6f8c1d \ -d code=THE_CODE \ --data-urlencode redirect_uri=http://127.0.0.1:8765/callback \ -d code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk ``` Response: ``` { "access_token": "ep_at_…", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "ep_rt_…", "scope": "logs:read logs:write" } ``` ### 4. Refresh, and revoke Access tokens last an hour; refresh tokens 90 days. Refresh tokens rotate: each refresh gives a new pair and ends the old refresh token, and using an old one again ends the whole connection. Always store the new refresh token before using the new access token. Refresh: ``` curl https://www.endlesspursuit.app/api/v1/oauth/token \ -d grant_type=refresh_token \ -d client_id=epc_3f9a1c0d2b7e4a6f8c1d \ -d refresh_token=ep_rt_… ``` Revoking the refresh token ends the app’s connection to the person: that’s your Disconnect button. Unknown tokens answer 200 too. Revoke: ``` curl https://www.endlesspursuit.app/api/v1/oauth/revoke \ -d token=ep_rt_… \ -d token_type_hint=refresh_token \ -d client_id=epc_3f9a1c0d2b7e4a6f8c1d ``` ## Going public: review A new app is in **development**: at most 2 people can connect it, so you can build and test it on your own account. The next person sees “still being built” on the consent screen (`oauth_app_in_development`). Someone already connected can always approve again. When it’s ready, ask for review with a personal token that has `apps:write`: what it does and why it needs each scope, the scopes, an https privacy policy, 1 to 10 https links to screenshots or a short video of the whole flow (connecting and disconnecting included), and a contact email. One request at a time. Request: ``` curl https://www.endlesspursuit.app/api/v1/apps/epc_3f9a1c0d2b7e4a6f8c1d/review \ -H "Authorization: Bearer $EP_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "description": "Desk Timer logs focus sessions from your Mac. logs:write adds them; logs:read checks what is already there.", "scopes": ["logs:read", "logs:write"], "privacy_url": "https://desktimer.example/privacy", "media_urls": ["https://desktimer.example/review/connect-and-disconnect.mp4"], "contact_email": "dev@desktimer.example", "notes": "Install, press Connect, focus for 5 minutes, then Disconnect in Settings." }' ``` The Endless Pursuit team looks at it and approves it, or rejects it with notes: fix what they say and ask again. `GET /apps` shows `status` and the latest review’s `admin_notes`. - `development`: New. At most 2 people. - `in_review`: Waiting for the team. Still capped. - `approved`: Anyone can connect it. - `rejected`: See the notes, fix, ask again. Still capped. - `revoked`: Switched off by Endless Pursuit. Every connection ended. ## Quality standard Every app must meet it to be approved, and keep meeting it: - Correct idempotency and no duplicates. - Rate limits respected. - Fewest scopes. - A privacy policy. - No selling or ad use of Endless Pursuit data. - Honest naming. - A working disconnect. - Graceful errors. Personal access tokens are for your own account and need no review. ## Reference Paths are relative to `https://www.endlesspursuit.app/api/v1`. The full contract, every field and example, is the [OpenAPI file](https://www.endlesspursuit.app/developers/openapi.yaml). - `GET /me` (profile:read): The person the token belongs to, and what it may do. Response: { id, username, display_name|null, timezone (IANA), token: { kind: "personal"|"oauth", scopes: [], app: name|null } } - `GET /modules` (modules:read): Modules the API writes, with the person’s installed ones marked. Response: { data: [{ id, name, mode: body|work|mind, input (the object a log carries), installed, enabled, shows_up, facts: [{ key, label, unit, agg }] }] } - `GET /exercises` (modules:read): The exercise library workouts use. Response: { data: [{ id: "bench_press", name, kind: strength|conditioning|mobility, tracking: weight_reps|reps|time|distance }] } - `GET /projects` (modules:read): The person’s projects still going, for a focus block’s `project_id`. Response: { data: [{ id, name, kind|null, shipped, due_on|null }] } - `GET /logs` (logs:read): The person’s logs, newest first. Request: query: module, since, until (ISO times), source, external_id (with source), limit 1–100 (30), cursor Response: { data: [Log], next_cursor|null } - `POST /logs` (logs:write): Log something. Request: LogInput: { module, started_at?, ended_at?, minutes?, note?, private?, source?, external_id?, } Response: 201 Log + outcome "created"; 200 Log + outcome "already"; 200 { outcome: "covered", external_id } (focus fully covered) - `POST /logs/batch` (logs:write): Log up to 100 things at once. Request: { logs: [LogInput] } (1–100) Response: { data: [{ index, outcome: created|already|dismissed|covered|invalid, external_id|null, log?, error? }] } - `GET /logs/{id}` (logs:read): One log. Response: Log - `PATCH /logs/{id}` (logs:write): Change a log, within 24 hours of it landing. Request: any LogInput field but module, source, external_id; the module object merges one level deep, arrays replace whole Response: Log - `DELETE /logs/{id}` (logs:write): Delete a log, any time. Response: 204 - `GET /trackers` (modules:read): The person’s custom trackers. Response: { data: [{ id, name, unit|null, mode, agg: sum|max|last, removed, created_at }] } - `POST /trackers` (logs:write): Make a custom tracker. Request: { name (1–40), unit? (≤16), mode?: body|work|mind (mind), agg?: sum|max|last (sum) } Response: 201 Tracker - `PATCH /trackers/{id}` (logs:write): Rename a tracker, or change its unit or mode. Request: same fields as POST Response: Tracker - `DELETE /trackers/{id}` (logs:write): Remove a tracker. Its logs stay. Response: 204 - `POST /health/days` (logs:write): Steps, sleep, heart and mindful minutes: one log a day per module, updated as the day grows. Request: { source?, days: [{ day (YYYY-MM-DD, the person’s zone), steps?, distance_m?, flights?, active_kcal?, exercise_min?, stand_hours?, sleep_min?, in_bed_min?, sleep_start?, sleep_end?, resting_hr?, hrv_ms?, vo2max?, mindful_min? }] } (1–60) Response: { data: [{ day, steps|sleep|heart|mindful: created|updated|unchanged|kept|dismissed|paused }] } - `POST /signals` (logs:write): Presence signals: what the person is doing, moment to moment. Request: { source?: "api", signals: [{ kind: activity|motion|steps|stand|watch|presence, started_at, ended_at? (≤24 h later), device_id?, category? ("coding"), label? ("Xcode"), value?, meta? (≤1 KB) }] } (1–500) Response: { accepted, received } - `POST /oauth/token`: Swap a code or a refresh token for tokens. Request: form: grant_type=authorization_code (code, redirect_uri, code_verifier) | refresh_token (refresh_token); client_id; client_secret (confidential only) Response: { access_token: "ep_at_…", token_type: "Bearer", expires_in: 3600, refresh_token: "ep_rt_…", scope: "logs:read logs:write" } - `POST /oauth/revoke`: Revoke a token. Request: form: token, token_type_hint?, client_id, client_secret? Response: 200 - `GET /apps` (apps:write): Your OAuth apps, with their status and latest review. Response: { data: [App] } - `POST /apps` (apps:write): Register an OAuth app. Request: { name (2–60), description?, homepage_url? (https), logo_url? (https, square), redirect_uris: [] (1–10, exact), confidential? } Response: 201 App: { client_id, name, description, homepage_url, logo_url, redirect_uris, confidential, users, status, dev_max_users, review, created_at, client_secret? (once) } - `PATCH /apps/{client_id}` (apps:write): Change an app’s name, links or redirect URIs. Request: same fields as POST but confidential Response: App - `DELETE /apps/{client_id}` (apps:write): Delete an app, ending every connection to it. Response: 204 - `POST /apps/{client_id}/secret` (apps:write): A new client secret. The old one stops working. Response: App with client_secret (once) - `POST /apps/{client_id}/review` (apps:write): Ask for review, to go public. Request: { description (20–2000: what it does, why each scope), scopes: [], privacy_url (https), media_urls: [https] (1–10), contact_email, app_name?, notes? } Response: App, status "in_review"