api

private writes · public docs

everything on this site is written through three routes that need a bearer secret. this page says how they work. it never shows the secret.

base url
https://aaranya.dev
format
JSON in, JSON out

auth

bearer secret
Authorization: Bearer <secret>

every call needs the bearer secret in the Authorization header.

the secret is kept in the site’s private repository and is never published, here or anywhere else.

a missing or wrong secret gets 401 with an empty body. the comparison is constant-time.

endpoints

the only routes that touch the database

POST /api/v1/events

append a batch of 1–500 events. all or nothing: one bad event and nothing is stored.

GET /api/v1/state

goals with targets and every hypothesis version, the latest reading per metric, ideas in the bank, and every metric defined so far.

GET /api/v1/events

raw history, oldest first.

since
YYYY-MM-DD · optional — events dated on or after this day
type
event type · optional — one type, or goal.*, idea.* or metric.*
limit
1–500 · optional — defaults to 500

rules

append-only
nothing is edited or deleted in place. a change is a new event, and the site shows the newest version.
ids
every event carries its own uuid. retrying a batch with the same ids never stores anything twice; repeats come back as duplicate.
dates
dates are the owner’s local dates (America/Los_Angeles), not the time of the call. backfilling is fine; dates after tomorrow are refused.
batches
send everything from one sitting in one call. each call wakes the database once.
numbers
log only numbers the owner gave. never estimate one.
refresh
after a write, the log and goals pages rebuild within a few seconds. the other pages are built from files and change on deploy.

events

14 types · POST /api/v1/events

reading · entry · entry.revise · metric.define · goal.open · goal.update · goal.target · goal.hypothesis · goal.archive · goal.replace · goal.delete · idea.add · idea.use · correction

reading

one value of one metric for one day. a newer reading for the same metric and day replaces it on the site.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"reading" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
metric
metric id · required — defined earlier with metric.define (or earlier in the same batch)
value
depends on the metric · required — checked against the metric’s shape
note
string · optional — up to 1,000 characters
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "reading",
  "date": "2026-10-23",
  "metric": "weight",
  "value": 187.4
}

entry

a dated line in the log: something shipped, a note, a luck event. a new project is just a new tag.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"entry" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
tag
lowercase tag · required — body, otto, surplus, riglab, book, luck, note, …
text
string · required — one line, up to 500 characters
data
object · optional — extra fields; { milestone: "M8" } on an otto entry marks a milestone
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "entry",
  "date": "2026-10-23",
  "tag": "otto",
  "text": "shipped v0.8.0 to prod",
  "data": {
    "milestone": "M8"
  }
}

entry.revise

change a log line. its newest version is replaced on the site and marked revised; the old row stays in the database.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"entry.revise" · required
target_id
uuid · required — the entry’s newest version
date
YYYY-MM-DD · optional
tag
lowercase tag · optional
text
string · optional
data
object · optional — merged into the old data
reason
string · optional
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "entry.revise",
  "target_id": "<entry id>",
  "text": "shipped v0.8.1 to prod",
  "reason": "wrong version"
}

metric.define

add a metric, or redefine one (the newest definition wins). there are no built-in metrics and no reserved names: every metric starts here.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"metric.define" · required
metric
snake_case id · required — 2–40 characters, e.g. steps
label
string · required — its name on the site
kind
number | count | bool | enum · required — the shape of its values
options
string[] · optional — enum only: the allowed values
mode
count | score · optional — number and count metrics; bool and enum draw as done or not
score
progress | ratio | closeness | at_least · optional — score mode: progress from the goal’s from; value ÷ target; full within 5%; full at 95% or more
average_days
2–30 · optional — score mode: score the rolling mean of the last N days; squares start after N readings
thresholds
[n, n, n, n] · optional — values for shades 1–4; quartiles of the logged days when absent
unit, short, min, max
optional · optional — display unit, short name, value bounds
rest, cadence, tag, source, darker
optional · optional — days off (0 = mon), how often, log tag, source line, what darker means
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "metric.define",
  "metric": "weight",
  "label": "weight, 7-day average",
  "short": "weight",
  "unit": "lb",
  "kind": "number",
  "mode": "score",
  "score": "progress",
  "average_days": 7,
  "tag": "body"
}

goal.open

start a goal: one lagging metric (y), a few leading ones (x) and a hypothesis (f v0).

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"goal.open" · required
date
YYYY-MM-DD · required — the window starts here
goal
slug · required — kebab-case goal id, e.g. cut-172
title
string · required
short
string · optional — its name on the log page
due
YYYY-MM-DD · optional
lagging
object: { metric, from?, target, rule? } · required — y: the outcome
leading
array of { metric, target?, rule? } · required — x: the inputs; may be empty
hypothesis
string · required — "if I do A for N days, B happens"; empty means not written yet
note
string · optional — up to 1,000 characters
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "goal.open",
  "date": "2027-02-15",
  "goal": "bulk-185",
  "title": "bulk to 185 lb",
  "lagging": {
    "metric": "weight",
    "from": 172,
    "target": 185
  },
  "leading": [
    {
      "metric": "calories"
    },
    {
      "metric": "training",
      "target": "5 a week"
    }
  ],
  "hypothesis": "if I eat at my bulk target and lift 5 days a week for 12 weeks, I reach 185 lb."
}

goal.update

rename a goal, or set, move or clear its due date.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"goal.update" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
goal
slug · required — kebab-case goal id, e.g. cut-172
title, short
string · optional
due
YYYY-MM-DD or null · optional — null clears it
note
string · optional — up to 1,000 characters
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "goal.update",
  "date": "2026-10-23",
  "goal": "cut-172",
  "due": "2027-02-15"
}

goal.target

a target for one of the goal’s metrics, from a given day on. targets belong to the goal, not the metric.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"goal.target" · required
goal
slug · required — kebab-case goal id, e.g. cut-172
metric
metric id · required
target
number or string · required
effective_from
YYYY-MM-DD · required — days are scored against the target in force that day
note
string · optional — up to 1,000 characters
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "goal.target",
  "goal": "cut-172",
  "metric": "calories",
  "target": 2000,
  "effective_from": "2026-10-23"
}

goal.hypothesis

a new version of f, optionally with a new y or x. every version is kept.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"goal.hypothesis" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
goal
slug · required — kebab-case goal id, e.g. cut-172
hypothesis
string · required
lagging
object: { metric, from?, target, rule? } · optional — only if y changed
leading
array · optional — only if x changed: the full new list
changed
string · required — what moved and why
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "goal.hypothesis",
  "date": "2026-10-23",
  "goal": "surplus-50m",
  "hypothesis": "if we merge 5+ PRs into surplus every day for 60 days, requests reach 15M a day.",
  "changed": "set N to 60 days and a first milestone of 15M a day."
}

goal.archive · only with the owner’s yes

end an active goal. it stays on the goals page with its final numbers.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"goal.archive" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
goal
slug · required — kebab-case goal id, e.g. cut-172
note
string · optional — up to 1,000 characters
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "goal.archive",
  "date": "2026-12-31",
  "goal": "write-daily"
}

goal.replace · only with the owner’s yes

end an active goal and point to the one that took over, like a cut becoming a bulk.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"goal.replace" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
goal
slug · required — kebab-case goal id, e.g. cut-172
by
slug · required — already open, or opened in the same batch
note
string · optional — up to 1,000 characters
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "goal.replace",
  "date": "2027-02-15",
  "goal": "cut-172",
  "by": "bulk-185"
}

goal.delete · only with the owner’s yes

hide a goal from the site. the readings it looked at stay, because they belong to the metric.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"goal.delete" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
goal
slug · required — kebab-case goal id, e.g. cut-172
note
string · optional — up to 1,000 characters
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "goal.delete",
  "date": "2026-10-23",
  "goal": "old-goal"
}

idea.add

put a post topic in the bank.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"idea.add" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
text
string · required
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "idea.add",
  "date": "2026-10-23",
  "text": "why every number gets the same calendar"
}

idea.use

take a topic out of the bank once it’s written.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"idea.use" · required
date
YYYY-MM-DD · required — the owner’s local date the event is about
idea_id
uuid · required — the idea.add event’s id
post
post slug · optional
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "idea.use",
  "date": "2026-10-24",
  "idea_id": "<idea id>"
}

correction

hide a mistaken entry or goal event from the site. readings don’t need one: send a newer reading instead.

id
uuid v4 · required — made by the client; sending the same id again is a safe no-op
type
"correction" · required
target_id
uuid · required
reason
string · required
{
  "id": "6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13",
  "type": "correction",
  "target_id": "<entry id>",
  "reason": "logged on the wrong day"
}

metrics

defined through the api

there are no built-in metrics. define each one with metric.define, then log readings against it; both can go in the same call.

kind sets the shape of a value: number, count (an integer of 0 or more), bool (true or false) or enum (one of its options).

mode sets the heatmap: count shades by size, bool fills a day when done, score shades by closeness to the goal’s target in force that day.

GET /api/v1/state lists every metric defined so far.

responses

200 the whole batch was accepted

{
  "stored": [
    "<id>"
  ],
  "duplicate": [
    "<id>"
  ]
}

422 one or more events failed a check; nothing was stored

{
  "errors": [
    {
      "index": 0,
      "path": "metric",
      "message": "unknown metric \"weight\"; define it first with metric.define"
    }
  ]
}

400 the body isn’t a JSON array

{
  "error": "body must be a JSON array of events"
}

401 missing or wrong bearer secret

500 server error; nothing was stored and retrying with the same ids is safe

{
  "error": "server error; nothing was stored. retrying with the same ids is safe."
}

examples

$SECRET stands in for the bearer secret

define a metric and log it in one call (weight was defined earlier, as in the metric.define example):

# the bearer secret is in the private repo; it is never written on this page
curl -sS -X POST https://aaranya.dev/api/v1/events \
  -H "Authorization: Bearer $SECRET" \
  -H 'Content-Type: application/json' \
  -d '[
    {"id":"6f1c2a4e-8b3d-4c5f-9a7e-2d4b6c8e0f13","type":"metric.define","metric":"cardio","label":"cardio","kind":"bool","tag":"body"},
    {"id":"0c9e7d2b-5a41-4f86-b3c2-7e1d9a6f4b20","type":"reading","date":"2026-10-23","metric":"cardio","value":true},
    {"id":"3e8f1a6c-2b7d-4c9e-8f0a-5d1b2c3e4f60","type":"reading","date":"2026-10-23","metric":"weight","value":187.4}
  ]'

read the current state before changing a goal:

curl -sS https://aaranya.dev/api/v1/state -H "Authorization: Bearer $SECRET"