Hark Docs

Hark docs

Hark is an inbox on your phone for your scripts and AI agents. Anything that can make an HTTP request can send you a card, ask you a question and wait for the answer, show live progress, or ring an alarm. You answer with a tap, often straight from the notification, and your code gets the answer back.

This is the reference for Hark Cloud at https://api.harkapp.io. Everything is JSON over HTTPS, times are Unix epoch seconds, and IDs are strings.

Building with an AI agent?Give it llms.txt: a short summary of the API it can work from, with links to the rest. llms-full.txt is this whole page as Markdown.

Quick start#

  1. Install the Hark app and sign in with your email, or sign in at app.harkapp.io.
  2. Open Settings > API keys, make a key and copy it. It starts with hk_.
  3. Send yourself a card:
bashexport HARK_TOKEN=hk_...

curl -H "Authorization: Bearer $HARK_TOKEN" \
  -d '{"title": "Backup finished", "body": "412 GB in 38 minutes"}' \
  https://api.harkapp.io/api/messages

Ask a question and block until you answer (or 10 minutes pass):

bashcurl -H "Authorization: Bearer $HARK_TOKEN" \
  -d '{"agent": "deploy", "title": "Ship v2.14?", "choices": ["Deploy", "Cancel"], "timeout": "10m"}' \
  "https://api.harkapp.io/api/ask?wait=600"

The response is the question card. request.response.choice is "deploy" or "cancel", or the question has request.status: "expired" if nobody answered.

Set a timer:

bashcurl -H "Authorization: Bearer $HARK_TOKEN" \
  -d '{"in": "25m", "label": "Pomodoro"}' https://api.harkapp.io/api/alarms

For anything longer than a line, prefer an interactive card. This one is a chart you can tap (see Interactive cards for tabs, tables, sliders and more):

bashcurl -H "Authorization: Bearer $HARK_TOKEN" \
  -d '{"title": "Weekly sales", "blocks": [{"type": "chart", "data": [["Mon", 12], ["Tue", 18], ["Wed", 9]], "unit": "orders"}]}' \
  https://api.harkapp.io/api/messages

From PowerShell, use Invoke-RestMethod so the JSON isn't mangled by quoting:

powershell$h = @{ Authorization = "Bearer $env:HARK_TOKEN" }
Invoke-RestMethod -Method Post https://api.harkapp.io/api/messages -Headers $h `
  -ContentType "application/json" -Body (@{ title = "Hello"; body = "From PowerShell" } | ConvertTo-Json)

From Python, use the one-file client (section Python client):

pythonfrom hark import Hark                      # curl -O https://docs.harkapp.io/hark.py
h = Hark(token="hk_...", agent="deploy", name="Deploy bot", avatar="🚀")
h.send("Build passed", title="aux-web v2.14", state="ok")
ans = h.ask("Ship v2.14?", choices=["Deploy", "Cancel"], timeout="10m", wait=600)
if ans and ans["choice"] == "deploy":
    ...

Authentication#

Every endpoint except GET /api/health and GET /files/... needs a token. Send it any of these ways:

Authorization: Bearer hk_...
X-Hark-Token: hk_...
?token=hk_...              (query string; for EventSource, WebSockets and quick tests)

There are two kinds of token, both shaped hk_<account>_<secret>:

  • API keys are for scripts and agents. Make, name and revoke them in Settings > API keys. Revoking takes effect immediately.
  • Sessions are what the app and the web inbox get when you sign in. Only a session can make API keys or delete the account.

Keep keys secret: anyone with one can post to your phone and read your inbox. Don't put them in code you share, and use one key per machine or agent so you can revoke them separately.

Browsers can call the API directly: every response allows cross-origin requests.

Messages (cards)#

POST /api/messages#

Creates a card (201). If key matches an existing card from the same agent, updates that card instead (200). See Live cards.

fieldtypenotes
agentstringWho is posting. Lowercase a-z0-9._-, max 40; other text is turned into that form. Default api. Created on first use, and each agent gets its own thread.
agent_name, avatar, colorstringDisplay info for the agent. avatar is an emoji or one or two characters; color is a CSS color.
titlestringBold heading, up to 300 characters.
bodystringMarkdown-ish text: bold, italic, code, fenced code, lists, quotes, links, headings. Aliases: text, message. Up to 50,000 characters.
blocksarrayRich content, including tabs, tables and charts. See Blocks and Interactive cards.
imagestringAn https:// URL, a /files/... path from an upload, or a data:image/...;base64,... URL (stored for you). Shown in the card and as the notification's picture.
htmlstringFor what blocks can't show. Your own interactive HTML in a sandboxed iframe (scripts allowed, no access to Hark). Up to 500 KB. Sizes itself to its content. See Interactive HTML cards.
html_heightintFixed iframe height in pixels (40 to 2000) instead of auto-size.
jsonanyShown as a collapsible JSON tree.
linksarray["https://..."] or [{"url", "label"}], shown as chips. The first link becomes an "Open link" notification button. link (one) also works.
urlstringThe card's main link.
statestringidle, running, waiting, ok, warn, error or info. Shows a status pill; ok and error also tint the card.
progressnumber0 to 1 (or 0 to 100). A progress bar that glides between updates.
prioritystringmin, low, default, high or max: how loudly the phone notifies. Questions default to high.
notifyboolfalse puts the card in the inbox without a notification. Default true.
pinboolPut the card on the pinned board at the top of the feed.
tagsstring[]Up to 10 short tags.
keystringLive-card key.
reply_tostringID of the message this replies to.
request, choices, fields, timeout, deadline, on_expire, allow_text, placeholderMake the card a question. See Questions.

A card needs at least one of title, body, blocks, html, image, json, links or request. The body can also be form fields or plain text: curl -d "Backup done" ... posts a card whose body is Backup done.

The response is the stored message. If Hark had to drop or change something you sent, the response also has warnings, a list of what and why (see Warnings):

json{
  "id": "m_3f1c0a9b2e4d", "seq": 118, "agent": "deploy", "dir": "in", "key": null,
  "created": 1790000000.12, "updated": 1790000000.12, "seen": null, "pinned": false, "dismissed": false,
  "title": "Ship v2.14?", "body": "...", "priority": "high", "notify": true,
  "request": { "...": "see Questions" }
}

dir is in for cards posted to you and out for things you typed. seq is a strictly increasing cursor across the whole account.

POST /api/notify#

The same as POST /api/messages, but query-string and form fields are merged into the body, for tools that can only call a URL:

bashcurl -X POST "https://api.harkapp.io/api/notify?token=$HARK_TOKEN&title=Doorbell&message=Someone%20is%20at%20the%20door&priority=high"

GET /api/messages#

The newest page, returned oldest to newest. Returns {"messages": [...], "has_more": bool}.

querynotes
limit1 to 500, default 60.
beforeOnly messages with seq below this, for paging backwards.
agentOne agent's thread.
onlywaiting (open questions), pinned or unseen.
include_dismissed1 to include cards you swiped away.
qSearch: cards with every word somewhere in their title, body, tags (#travel), blocks, choices and answers, or an HTML card's visible text. Case and accents don't matter. Combine with agent and only; page with before.

GET, PATCH, DELETE /api/messages/{id}#

PATCH takes any content field from the table above, plus pinned, dismissed and seen: true. Changing an unanswered card updates its notification quietly; send "notify": true to buzz again. Marking a card seen, dismissing it or deleting it removes its notification from your phone.

POST /api/seen#

{"ids": ["m_...", ...]} or {"all": true}. Returns {"seen": [ids that changed]}.

POST /api/purge#

Permanently deletes every dismissed card. Returns {"deleted": n}.

Interactive cards#

Prefer an interactive card over text. If a card carries more than a sentence or two, send something the person can tap: tabs, a table they can sort and filter, a chart, a slider. People read Hark on a phone, often in a hurry, and a card they can explore beats paragraphs they have to scroll. Plain text is for short alerts. It isn't the default.

Build it from blocks first. The tabs, table and chart blocks, the range slider field, and visible conditions and {{templates}} (Card logic) cover most interactive cards in a few lines of JSON. Blocks match the app's theme in light and dark, are searchable, work offline, and can answer a question. Write html only for something blocks can't show.

Which one to send#

You haveSend
A one-line alert or statustitle and body
A report with several partsa tabs block, with a short title and body as the summary
Rows of resultsa table block: tap a column to sort, filter box from 9 rows
Numbers over time or by categorya chart block (bar or line): tap to read values
Numbers someone might want to play witha range field with {{templates}} in the blocks above it
A decision or value you need backchoices or fields, with blocks for the evidence
Something still runningA live card
Anything else: custom layouts, maps, gameshtml

Example: review with tabs and a decision#

json{"agent": "deploy", "title": "Ship aux.fan v2.14?", "body": "All tests pass. 4 migrations pending.",
 "blocks": [{"type": "tabs", "tabs": [
   {"label": "Changes", "blocks": [{"type": "list", "items": ["New checkout page", "Faster search"]}]},
   {"label": "Tests", "blocks": [
     {"type": "metric", "label": "passed", "value": "412"}, {"type": "metric", "label": "failed", "value": "0", "tone": "ok"},
     {"type": "table", "columns": ["Suite", "Tests", "Seconds"], "rows": [["checkout", 120, 41.5], ["search", 88, 12]]}]},
   {"label": "Risk", "blocks": [{"type": "kv", "items": {"Migrations": "4", "Rollback": "about 2 minutes"}}]}]}],
 "choices": [{"label": "Deploy", "style": "primary"}, "Cancel"], "timeout": "30m"}

Example: a what-if slider that answers#

The slider is a question field, so the value the person settles on comes back with the answer. The blocks above it recompute as they drag, and the reason box only appears when it's needed (and is only required then).

json{"agent": "billing", "title": "Cloud bill", "body": "At 8 servers you're on track for $336 this month.",
 "blocks": [
   {"type": "metric", "label": "Servers", "value": "{{servers}}"},
   {"type": "metric", "label": "A month", "value": "${{servers * 42}}"},
   {"type": "progress", "label": "Of the $500 budget", "value": "{{servers * 42 / 500}}"},
   {"type": "status", "text": "Over budget", "tone": "warn", "visible": {"field": "servers", "gt": 11}}],
 "fields": [{"name": "servers", "type": "range", "min": 1, "max": 20, "value": 8},
            {"name": "why", "label": "Why so many?", "required": true, "visible": {"field": "servers", "gt": 11}}],
 "choices": [{"label": "Apply", "style": "primary"}, "Cancel"]}

request.response.fields comes back as {"servers": 15, "why": "launch week"}, or just {"servers": 8} when the reason was never shown.

Example: a chart and a long list#

json{"agent": "ci", "title": "CI failed", "body": "4 tests failed on main.", "state": "error",
 "blocks": [
   {"type": "chart", "kind": "line", "labels": ["Mon", "Tue", "Wed", "Thu"],
    "series": [{"label": "Failures", "values": [0, 1, 0, 4]}, {"label": "Flaky", "values": [2, 1, 3, 2]}]},
   {"type": "table", "columns": [{"label": "Test", "key": "name"}, {"label": "Error", "key": "error"}],
    "rows": [{"name": "checkout total includes tax", "error": "expected 10.80, got 10.00"},
             {"name": "login rate limit", "error": "expected 429, got 200"}], "filter": true}]}

Interactive HTML cards#

For what blocks can't show, send your own HTML. It runs in a sandboxed frame with scripts allowed.

Answers still use choices and fields. HTML can't answer a Hark question, because it runs in a sandbox with no access to Hark. Put the evidence in html and the decision in native buttons, which also work from the notification and return the answer to your code. If the evidence fits in blocks, use blocks: they can react to the fields too.

Rules for good cards#

  • Always send a title, and a one-line body when it adds something. Notifications show those, never your HTML.
  • Design for a phone. Tap targets at least 44px tall, nothing that depends on hover, and no sideways scrolling.
  • Keep it self-contained. Put the CSS, JavaScript and data inline, so the card loads fast and needs no other server.
  • Follow the theme. The page supplies --hark-bg, --hark-text, --hark-link, and --hark-border for the selected Hark theme. Prefer transparent panels and inherited text. If you set a panel background, set its text color too, with at least 4.5:1 contrast. Hark repairs low-contrast text over solid backgrounds, including older cards; authors must ensure contrast over images and gradients. Do not rely on the OS prefers-color-scheme alone: Hark can use a different theme.
  • Don't count on storage or dialogs. localStorage, cookies, alert(), confirm() and prompt() don't work in the sandbox. Keep state in JavaScript variables, and expect it to reset when the card is redrawn, for example when it updates or the feed reloads.
  • Never put a Hark API key in the HTML. It's stored with the card and readable by anything the card loads.
  • Encode your data. Build the request with a JSON library rather than by hand. When you put data in a <script>, replace </ with <\/, and show untrusted text with textContent, not innerHTML.

Limits: up to 500 KB. The frame sizes itself to its content, up to 1600px tall. html_height sets a fixed height from 40 to 2000px instead, and the content scrolls inside it if it doesn't fit. Links open outside the app.

Example: a button that calls your own server#

For an action that shouldn't wait for a question, the card can fetch() your own server. The sandbox's origin is null, so your response must include Access-Control-Allow-Origin: *. A plain text/plain POST needs no preflight. Authorize it with a single-use token in the body, never your Hark key.

pythonfrom hark import Hark
h = Hark(agent="ops", name="Ops", avatar="🛠️")

HTML = """
<style>
  button { width: 100%; min-height: 44px; border: 0; border-radius: 10px; background: #ff8a00; color: #000;
           font: inherit; font-weight: 700; }
</style>
<button id="go">Restart worker</button>
<p id="out"></p>
<script>
  go.onclick = async () => {
    go.disabled = true;
    out.textContent = 'Restarting...';
    try {
      const r = await fetch('https://ops.example.com/restart', { method: 'POST', body: 'one-time-token' });
      out.textContent = r.ok ? 'Restarted' : 'Failed: ' + r.status;
    } catch (e) {
      out.textContent = 'Could not reach the server';
    }
    go.disabled = false;
  };
</script>
"""

h.send("Queue has been stuck for 10 minutes.", title="Worker stuck", state="warn", html=HTML)

Blocks#

blocks is a list of objects with a type. A bare string becomes a text block, and unknown types are shown as JSON instead of being rejected (with a warning). Up to 150 blocks, counting those inside tabs, and 1 MB; extra blocks are dropped. Any block can have a visible condition, and text in any block except code, log and json can hold {{templates}} (see Card logic).

typefieldsshows as
headingtextA small bold heading.
texttextMarkdown paragraphs.
quotetextA quoted line.
kvitems: {"k": "v"}, [["k", "v"]] or [{"label", "value"}]A two-column list.
metriclabel, value, delta?, tone?A big number. Metrics in a row sit side by side.
statustext, tone (ok, warn, error, info, idle)A colored status pill.
progressvalue (0 to 1), label?A labeled progress bar.
listitems, ordered?A bulleted or numbered list.
codetext (or lines), lang?Monospace with a copy button.
logtext (or lines)Like code, keeps the last 400 lines and colors error, warning and ok lines.
imageurl (or src, or base64 + content_type), caption?An image; tap to zoom.
linkurl, label?A link chip.
dividerA thin rule.
jsondataA collapsible JSON tree.
tabstabs: [{"label", "blocks": [...]}]Up to 8 tabs, each with its own blocks. Tabs can't hold tabs.
tablecolumns, rows, filter?, sort?A table. rows are lists of cells, or objects whose keys are the columns (columns can be [{"label", "key"}], and default to the first row's keys). Up to 12 columns and 500 rows. Tap a header to sort (sort: false turns it off); a filter box shows from 9 rows (filter: true or false to choose). Numbers line up on the right and sort as numbers. Cells take inline markdown.
chartdata or labels + series, kind?, unit?A bar (default) or line chart; tap to read values. data: [["Mon", 12], ...], {"Mon": 12} or [{"label", "value"}]. Or labels with series: [{"label", "values"}] (up to 4 series; null leaves a gap) or a single values. Up to 100 labels. unit is shown after values.
json{"agent": "nuc", "title": "NUC health", "blocks": [
  {"type": "metric", "label": "CPU", "value": "23%", "tone": "ok"},
  {"type": "metric", "label": "Disk", "value": "81%", "delta": "+4%", "tone": "warn"},
  {"type": "status", "text": "All services up", "tone": "ok"},
  {"type": "kv", "items": {"uptime": "41d", "load": "0.42"}},
  {"type": "log", "lines": ["backup ok", "warning: slow disk"]}
]}

Card logic#

A card with question fields can react to them, like a small form app, without any code:

  • visible on a block or a field shows it only when a condition holds: {"field": "plan", "eq": "pro"}. Operators: eq, neq, gt, gte, lt, lte, in (a list), and not: true to invert. With no operator it checks the field is set (not empty, off or 0). A list means all of them; {"any": [...]} means at least one; true and false work too.
  • {{templates}} in block text fill in from the fields: {{servers}}, {{servers * 42}}, {{round(total / count, 1)}}. They take field names, numbers, + - * / %, parentheses and round(x, digits), floor, ceil, abs, min, max. Numbers show with up to 2 decimals and thousands separators. A progress block's value can be one template giving 0 to 1.

While the question is open they follow what the person types; once it's answered they show the answer. A field hidden by its condition isn't required and isn't sent: Hark checks the conditions again when the answer comes in. A template that names something unknown is shown as written.

Warnings#

POST /api/messages, /api/ask, /api/notify and PATCH /api/messages/{id} accept what they can and add warnings to the response when something was dropped, changed or can't work: an unknown block or field type, a chart with fewer values than labels, a condition or template naming a field the card doesn't have. Each is one line saying where and why:

json"warnings": ["blocks[2]: unknown type 'tablez'; types: heading, text, ... Shown as JSON",
             "blocks[1]: no field named 'qty'; this card's fields: servers"]

The card is still posted. Warnings aren't stored, and there's no warnings key when everything was fine. If you're a model generating cards, read them and fix the next card.

Live cards#

Post again with the same agent and key and the existing card updates in place instead of a new one appearing. Use it for builds, downloads, renders, anything with progress. Only the fields you send change. The first post notifies (unless notify is false); later updates refresh the same notification quietly, at most every 2 seconds.

bashfor p in 10 40 75 100; do
  curl -s -H "Authorization: Bearer $HARK_TOKEN" \
    -d "{\"agent\": \"render\", \"key\": \"job-42\", \"title\": \"Rendering\", \"progress\": $p, \"state\": \"running\", \"notify\": false}" \
    https://api.harkapp.io/api/messages > /dev/null
  sleep 2
done
curl -s -H "Authorization: Bearer $HARK_TOKEN" \
  -d '{"agent": "render", "key": "job-42", "state": "ok", "body": "Done"}' https://api.harkapp.io/api/messages

Questions#

Any card can ask something. Top-level choices, fields, timeout, deadline, on_expire, allow_text and placeholder are shorthand for a request object:

json{
  "agent": "deploy",
  "title": "Ship aux.fan v2.14?",
  "body": "Build passed. 4 migrations pending.",
  "request": {
    "choices": [
      {"label": "Deploy", "style": "primary"},
      {"label": "Inspect"},
      {"id": "rollback", "label": "Roll back", "style": "danger", "confirm": "hold"}
    ],
    "timeout": "30m",
    "on_expire": "inspect"
  }
}
request fieldnotes
choicesUp to 8 buttons: strings or {id?, label, style?, confirm?}. id defaults to a slug of the label ("Roll back" becomes roll-back). style is default, primary or danger. confirm: "hold" needs a press and hold in the app and is never offered on the notification.
fieldsUp to 20 inputs: {name, label?, type?, required?, placeholder?, value?, options?, visible?}. type is text, textarea, number, range (a slider: min, max, step, default 0, 100, 1), select (needs options), toggle, date or time. visible shows the field only when a condition on the other fields holds (see Card logic). Blocks can show the values live with {{name}}.
allow_textA free-text answer box. On by default when there are no choices and no fields.
placeholderPlaceholder for the text box.
timeoutHow long until it expires: 90, "90s", "10m", "1h30m". Or deadline: an absolute time (epoch, ISO 8601, or "17:30" in your time zone).
on_expireA choice id to record automatically when it expires, with via: "timeout".

The first three choices without confirm: "hold" appear as buttons on the notification, so most questions can be answered without opening the app.

Answers#

request.status starts open and becomes answered, expired or cancelled. Once answered, or expired with on_expire:

json"response": {
  "choice": "deploy", "label": "Deploy",
  "fields": {"wake": "06:45", "gym": true},
  "text": "ship it",
  "at": 1790000123.4,
  "via": "notification"
}

via is app, notification, api, cli or timeout.

Waiting for the answer#

  • POST /api/ask?wait=SECONDS posts and blocks until the question is answered, expires or is cancelled, up to 3600 seconds. A plain {"title": "..."} with no choices or fields becomes a free-text question.
  • GET /api/messages/{id}/wait?timeout=60 long-polls an existing question (up to 3600 seconds) and returns the message as soon as it isn't open. If it times out, it returns the still-open message: loop until request.status isn't open.
  • Or give the agent a webhook and get a POST, or watch live updates.

Answering and withdrawing from code#

  • POST /api/messages/{id}/respond with {"choice": "deploy"} (an id or a label, any case), {"fields": {...}}, {"text": "..."} or a mix. Returns 409 if the question is no longer open.
  • POST /api/messages/{id}/cancel withdraws an open question (cancelled).

Webhooks#

Give an agent a webhook and Hark POSTs to it when you answer one of its questions, when one expires, and when you send the agent a chat message:

bashcurl -X PUT -H "Authorization: Bearer $HARK_TOKEN" \
  -d '{"name": "Deploy bot", "avatar": "🚀", "webhook": "https://example.com/hark", "secret": "s3cret"}' \
  https://api.harkapp.io/api/agents/deploy

The payload:

json{"event": "response", "agent": "deploy", "message": {"...": "the full message"}, "response": {"choice": "deploy"}, "sent_at": 1790000123.5}

event is response, expired or message. Headers: X-Hark-Event, and when the agent has a secret, X-Hark-Signature: sha256=<hex HMAC-SHA256 of the raw body>. Check it like this:

pythonimport hmac, hashlib
ok = hmac.compare_digest(sig, "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest())

A failed delivery is retried after 2 and 8 seconds. The outcome is saved on the message as delivery: {"ok", "at", "event", "error"} and shown on the card, so you can see in the app whether your agent got the answer.

Chat#

You can type to an agent in its thread in the app. That creates an out message in the agent's inbox. The image button next to the input (or pasting an image) attaches a picture: the message then has image set to a /files/... path, and body is the caption or null. Download it with your key, like any file (h.file(m["image"]) in Python).

  • Agents with a webhook get an event: "message" POST.
  • Agents without one long-poll: GET /api/agents/{id}/inbox?after=<seq>&wait=30 returns {"messages": [...], "cursor": <seq>} with the messages you sent after after, waiting up to wait seconds (max 300) for the first one. Pass cursor back as the next after; start with after=0&wait=0 to catch up.

Reply by posting an ordinary card with the same agent. POST /api/chat {"agent": "deploy", "text": "status?"} sends as you; agent: "me" is a note to yourself. Add "image" (a /files/... path from POST /api/files, an https:// URL, or a data:image/...;base64,... URL) to send a picture; text is then optional.

Agents#

Agents are created the first time something posts as them. Two are built in: me (your notes) and hark (system messages, alarms and reminders).

  • GET /api/agents: every agent with unread, waiting and its last message, most recently active first.
  • GET /api/agents/{id}
  • PUT or PATCH /api/agents/{id}: name, avatar, color, webhook, secret, muted. Muted agents still post cards but never notify.
  • DELETE /api/agents/{id}/messages: clears the thread. Deletes every card from that agent, takes their notifications off your phones, and keeps the agent and its settings. Works for me and hark too. Returns {"deleted": n}.
  • DELETE /api/agents/{id}: deletes the agent, its settings and all its cards. Not allowed for me and hark. The agent comes back if it posts again.

In the app, press and hold a thread to clear or delete it. Double-tap an agent's icon on the feed to jump into its thread.

Alarms and timers#

Alarms ring on your phone full screen, on the phone's own clock, so they work offline, with the screen off and in battery saver. Hark keeps the schedule; the app syncs it.

POST /api/alarms#

fieldnotes
inA timer: "25m", "1h30m", 90.
atAn alarm time: "07:30", "7am", "7:30pm", "tomorrow 9", ISO 8601 or epoch. A bare time means its next occurrence in your time zone. Aliases: time, when.
labelShown on the ring screen and the notification.
repeatdaily, weekdays, weekends, weekly, monthly, yearly, hourly, "mon,wed,fri", ["sat", "sun"], "every 2h", "every 2w" or {"every": "90m"}. weekly, monthly and yearly keep the day of the first at; they come back as days:N, monthly:DD and yearly:MM-DD (a 31st rings on the last day of shorter months, Feb 29 on Feb 28).
saytrue speaks the label when it rings, or a string to speak instead.
vibrateDefault true.
ring_seconds, snooze_minutesPer-alarm overrides of the account settings.
webhookA URL that gets {"event": "alarm.fired", "alarm": {...}} when it rings.

It returns the alarm:

json{"id": "a_91be2c0d77aa", "at": 1790006400.0, "state": "scheduled", "kind": "alarm", "label": "Wake up",
 "repeat": "weekdays", "repeat_text": "Weekdays", "vibrate": true, "created": 1790000000.0, "updated": 1790000000.0,
 "fired": null, "message_id": null}

state is scheduled, ringing, snoozed, done, missed or cancelled. If nobody stops a ringing alarm within ring_seconds (5 minutes by default) it becomes missed. Repeating alarms go back to scheduled at their next time after they're stopped or missed.

Type timer 2m, 10m, then 5m to Hark and it sets one timer per step, back to back, all at once (a multi-timer). Each step's alarm carries chain: {"id", "name", "step", "of"}; lists and cancels treat a chain as one thing. Save one with save multi-timer called pomodoro for 25m work, 5m break x4, then run it with start pomodoro; my multi-timers lists them and forget pomodoro deletes one.

Other alarm endpoints#

  • GET /api/alarms (?active=1 for only scheduled, snoozed and ringing). Each alarm carries upcoming: its next three repeat times.
  • GET /api/alarms/{id}
  • PATCH /api/alarms/{id}: any field above, plus enabled: true/false. Turning a finished alarm back on schedules its next time.
  • DELETE /api/alarms/{id}
  • POST /api/alarms/{id}/ack: stop a ringing alarm.
  • POST /api/alarms/{id}/snooze {"minutes": 5} (default: your snooze setting).

Times like 07:30 use the account's time zone, which the app sets when you sign in. See it with GET /api/config (tz) and change it with PATCH /api/account {"tz": "America/New_York"}.

Reminders#

An alarm interrupts at a time. A reminder makes sure something gets done: at its time Hark posts a card with Done and snooze buttons (15m, 30m, 1h, 2h; the notification shows Done, 15m and 30m). If it should escalate, an ordinary alarm rings when nobody taps Done in time. That alarm is scheduled on the phone up front, so it rings even offline; Done or a snooze removes or moves it, and stopping it counts as Done. Swiping the notification away doesn't. The third snooze in a row rings when it comes back, whatever the setting.

The user can also type reminders to Hark: run club tomorrow at 5, remind me in an hour to call Sam, pay rent friday at 9, make sure (escalates), water plants at 6pm, just a nudge (never rings), remind me 30 min before run club at 5, Sam's birthday March 3 (every year, at 9 AM), rent on the 1st of every month at 9am. Hark's "Reminder set" card has a Make sure button (or Don't ring when it already escalates) to change that after the fact.

Hark reads simple commands itself. When a typed message is harder than that, its text goes to a small model on Cloudflare Workers AI, which rewrites it as a plain command for Hark to read. Anything set that way has an Undo button, and anything it would cancel asks first. Only messages typed to Hark itself are read this way, never cards or other agents' messages.

POST /api/reminders#

fieldnotes
labelRequired. The card's title.
in / atWhen, like alarms: "2h", or "17:00", "tomorrow 9am", ISO 8601 or epoch, in your time zone.
beforeMove it earlier: "30m" reminds 30 minutes before at.
bodyExtra text on the card.
repeatSame as alarms: daily, weekdays, weekly, monthly, yearly (birthdays), "mon,wed,fri", "every 2h".
escalatetrue (your Missed reminders setting, or 15 min if that is off), false (never), or minutes (10) or a duration ("10m"). Default: your setting.
agentWhich agent the card comes from. Default hark.
bashcurl -s -H "Authorization: Bearer $HARK_TOKEN" -H 'Content-Type: application/json' \
  -d '{"label": "Review the PR", "at": "15:00", "escalate": true}' https://api.harkapp.io/api/reminders

It returns the reminder: {"id": "r_…", "label", "at", "state", "escalate", "repeat", "next_alarm", "open": [card ids], …}. state is scheduled, fired (card posted, waiting for Done), done, or back to scheduled for repeats. The card is a normal question: its answer comes back like any other (choice is done, 15m, 30m, 1h or 2h), including webhooks to the reminder's agent.

  • GET /api/reminders (?active=1 for scheduled or waiting ones), GET /api/reminders/{id}, DELETE /api/reminders/{id} (also removes its cards' alarms).
  • PATCH /api/reminders/{id} with label, body, escalate, at/in or repeat (null = once). A new time or repeat reschedules it (and brings back one that was done); a new escalate applies from the next card.
  • PATCH /api/config {"reminder_escalate_minutes": 15} sets the account default (0 = never).

Files#

POST /api/files?name=shot.png with the raw bytes as the body and a Content-Type header. Returns {"url": "/files/<account>/<name>", "size": n, "type": "image/png"}. Use the url in image or in image blocks. Up to 25 MB.

bashcurl -H "Authorization: Bearer $HARK_TOKEN" -H "Content-Type: image/png" \
  --data-binary @shot.png "https://api.harkapp.io/api/files?name=shot.png"

GET /files/... needs no token (the names can't be guessed), so notifications and the app can load images directly. For one-off images, a data:image/png;base64,... URL in image is simpler: Hark stores it for you.

Live updates#

Every change in your inbox is pushed to connected clients as it happens, the same events the app uses.

  • WebSocket: wss://api.harkapp.io/api/ws?token=.... Each frame is {"event": "...", "data": {...}}. Send ping and you get pong.
  • Server-sent events: GET /api/stream?token=..., with a comment ping every 15 seconds.
eventdata
hello{version, time, unread, waiting, total} on every connect.
message{op: "new" | "update" | "delete", message}
alarmThe alarm, or {id, deleted: true}.
agentThe agent, {id, deleted: true}, or the agent with cleared: true when its thread was cleared.
seen{ids: [...]}
resyncSomething changed in bulk (a purge); fetch again.

After a reconnect, fetch what you need again: events sent while you were away aren't replayed.

Account and settings#

  • GET /api/account: {id, email, tz, created, usage: {month, messages, limit}}.
  • PATCH /api/account {"tz": "Europe/London"}
  • GET /api/config: your settings, including tz, notify, snooze_minutes, alarm_ring_seconds and reminder_escalate_minutes.
  • PATCH /api/config: notify (notifications on or off for the whole account), snooze_minutes, alarm_ring_seconds, reminder_escalate_minutes (ring if a reminder isn't done after this many minutes; 0 = never), tz.
  • GET /api/info: unread and waiting counts, total messages, live client count.
  • POST /api/test-notification: sends a question with two buttons to your phones, to check the whole path.
  • GET /api/keys: your API keys and sessions, including revealable (no credential values). POST /api/keys {"name"} makes a key and returns it in token (needs a session). DELETE /api/keys/{id} revokes one.
  • POST /api/keys/{id}/reveal: returns {id, token} for an API key owned by the signed-in account (session only, never sessions themselves; response is not cached). API keys are encrypted at rest. Older hash-only keys return 409 until successfully used once after the upgrade; alternatively create a new key. Revocation removes the stored encrypted copy too.
  • POST /api/auth/logout: revokes the token it's called with.
  • DELETE /api/account {"confirm": "delete my account"}: erases everything (needs a session).

Location#

When Settings → Share location with agents is on in the Android app, the phone reports where it is in the background (about every 10 minutes, or after it moves a couple hundred meters). Only the latest fix is kept.

  • GET /api/location: {"location": {lat, lng, accuracy, at, age_seconds, device}}, or {"location": null} when sharing is off or nothing has been reported. accuracy is in meters; at is Unix seconds. Check age_seconds before trusting it.
  • POST /api/location {"lat", "lng", "accuracy", "at"}: what the app sends. A fix older than the stored one is ignored.
  • DELETE /api/location: forgets it (the app does this when sharing is turned off).

The app registers itself for push with POST /api/devices. GET /api/devices lists your phones, and POST /api/devices/{id}/test sends one a test push.

Settings → Copy to LLM copies the current full API reference as a ready-to-paste integration prompt. You choose whether to include an API key and select which key. Session credentials are never included. Without a key, the prompt uses the HARK_API_KEY environment variable placeholder.

Activity logs#

Open Activity logs from the feed or Settings on desktop or mobile. Filter by time range, severity, event kind, agent, resource ID, or detail text. Expand a row for full structured details, select Trace to follow its resource, and copy or download the loaded rows. Auto refresh is optional and pauses while a row is expanded.

GET /api/logs requires a signed-in session. Each account can see only its own records. Query parameters:

ParameterMeaning
from, toInclusive Unix timestamps in seconds.
kindExact event kind; repeat for multiple kinds (OR).
levelinfo, warn, or error.
agent, resourceExact agent ID or message/alarm/reminder/key ID.
qCase-insensitive substring of details, kind, resource or agent; accepts request IDs.
limitPage size, 1–500 (default 100).
beforeThe previous page's next cursor to load older events.

Response: {logs, total, kinds: [{kind, count}], next, retention_days, max_events}. Rows are newest first and contain {seq, at, kind, level, resource, agent, detail}. Counts describe all matches, before pagination. API responses from the inbox include X-Hark-Request-Id to match request diagnostics.

Recording covers authenticated inbox API requests (method, path, status, duration, actor and request ID), message/agent changes, questions and responses, alarms/reminders, key operations, timer errors, and push/webhook delivery attempts and retries. Push accepted means accepted by the push service, not proof of receipt on the phone. Message bodies, raw request bodies, auth headers and credentials are not captured; structured details redact known secret fields and token patterns. Logs do not include pre-upgrade history, rejected unauthenticated requests, or Worker-level sign-in/file endpoints. Keep your own downstream logs for events outside Hark.

Retention is 30 days with approximately 20,000 recent events per account (periodic pruning). Browsing logs does not generate new log rows. Copy/export includes the currently loaded rows, not unloaded pages.

Errors and limits#

Errors are {"error": "a readable message"} with a fitting status:

statusmeaning
400Bad input; the message says what's wrong.
401Missing or wrong token.
403The token can't do this (an API key where a session is needed).
404Not found.
405Wrong method for this path.
409The question is no longer open.
413Too large.
429Over a limit: slow down, or wait for next month.

Limits: 25,000 new cards a month per account, and 20 requests a second per key with bursts of 60. Request bodies up to 4 MB, uploads 25 MB, body 50,000 characters, html 500 KB, blocks 150 and 1 MB, 8 choices, 20 fields, 12 links. Inside blocks: 8 tabs, 12 table columns and 500 rows, 100 chart labels and 4 series. Over a limit inside blocks, the extra is dropped with a warning rather than an error.

Python client#

hark.py is one file using only the standard library. Download it next to your script:

bashcurl -O https://docs.harkapp.io/hark.py
pythonfrom hark import Hark

# Token from the argument or $HARK_TOKEN; URL from the argument, $HARK_URL, or Hark Cloud for hk_ keys.
h = Hark(token="hk_...", agent="nuc", name="NUC", avatar="◎")

h.send("Disk at 81%", title="NUC health", state="warn")

for pct in (0.2, 0.6, 1.0):                                   # a live card: same key, same card
    h.card("backup", title="Backing up", progress=pct, state="running", notify=False)

ans = h.ask("Prune old snapshots?", choices=["Prune", "Skip"], timeout="10m", wait=600)
if ans and ans["choice"] == "prune":
    ...

h.send(title="Screenshot", image=h.image("shot.png")["url"])
h.alarm("25m", "Pomodoro")
h.alarm("07:30", "Wake up", repeat="weekdays", say=True)

def on_message(m):                                            # you typed to this agent in the app
    if m.get("image"):
        open("from-phone.jpg", "wb").write(h.file(m["image"]))    # a picture you sent
    h.send(f"you said: {m['body']}", reply_to=m["id"])
h.listen(on_message)

ask(..., wait=N) returns the response (choice, label, fields, text, via, at) or None if nobody answered in time. Without wait it returns the message; call h.wait(message_id, timeout) later. Errors raise HarkError with status and message.

Self-hosting#

The same API runs on your own hardware: the Hark server is a small Python program with no dependencies that runs on a Raspberry Pi, a VPS, a NAS or an Android phone. Point the app at it with Use my own server instead on the sign-in screen. Everything in these docs applies, except the account, keys and limits sections; a self-hosted server has one token.