References and API
The formats Latchkey reads and writes: references in your files, the protocol between the command-line tool and the app, and the files it keeps on disk.
Use the command-line tool. latchkey is the supported interface, from any language. The socket protocol below is how it talks to the app; it changes only by adding optional fields, but scripts that speak it directly also take on its approval rules.
References
| Form | Where | Becomes |
|---|---|---|
latchkey://ID | Values in env files and in the environment of latchkey run | The item’s value |
latchkey-file://ID | Values in env files and in the environment of latchkey run | The path of a temporary file holding the value, mode 0600, deleted when the command exits |
A latchkey:// reference can sit inside a longer value, as in postgres://app:latchkey://shop/production/DB_PASSWORD@db/shop; each one is replaced. A latchkey-file:// reference must be the whole value. ID is NAME or project/environment/NAME, each part letters, digits, _, - and ., at most 64 bytes.
DATABASE_URL=latchkey://shop/development/DATABASE_URL
SENTRY_DSN=latchkey://SENTRY_DSN
ASC_KEY_PATH=latchkey-file://shop/production/ASC_P8The broker protocol
The app listens on a Unix socket at ~/Library/Application Support/Latchkey/broker.sock, mode 0600 in a 0700 folder. A client connects, writes one JSON object followed by a newline, and reads one JSON object followed by a newline. Keys are sorted; dates are ISO 8601. Requests say nothing about their caller. The broker asks the kernel instead: the caller’s working folder, command line and parent processes, and, by code signature, whether it’s Latchkey’s own command-line tool. The approval panel and the log show those, and grants are matched against the real folder. A signed latchkey also checks that the socket belongs to the Latchkey app before it sends anything.
Requests are handled one at a time. A request that needs approval waits until you answer, so allow for that in timeouts.
{"op":"status"}{"info":{"approval":"Touch ID, password","caller":"Latchkey's command-line tool (signature checked)","grants":"0","items":"17","socket":"/Users/you/Library/Application Support/Latchkey/broker.sock","storage":"iCloud Keychain storage (sync status not verified)"},"ok":true}Operations
op | Fields | Returns |
|---|---|---|
status | info | |
list | secrets: item metadata, never values | |
check | names, intended (the command to test command-limited grants against) | agentSafe, granted (with the covering grants), needsApproval, missing. Never asks, never values |
get | names | values, masked (names to hide in output), denied, missing |
set | names (one), value, kind, agentSafe, note, service | ok |
update | names, kind, agentSafe, note, service | ok |
rm | names | ok, or missing |
move | names, project ("" for shared), environment | moved: old ID to new ID |
import | items, replace, source | added, replaced, skipped |
history | names (one) | versions, never values |
deleted | versions of deleted items | |
version | version: a version ID from history | values, after approval (always asks) |
restore | version | ok |
forget | names | ok |
grants | grants | |
grant | names, folder (default: where the caller runs), duration (seconds), session, commands (lists of words), uses | grants |
revoke | names: a grant ID, or ["all"] | info.revoked, or missing |
links | names: optional scope | links |
link | names: the scope, target | links |
unlink | names: the link ID | ok |
remote-status | names: the scope | remoteStatus |
push | names: the scope, link, only | pushResults |
origin: "mcp" marks a request from latchkey mcp: the approval panel says an agent asked, and a grant it asks for must be its own folder, for the agent’s session, and nothing in production or a whole project. The label is the request’s own claim: it adds limits, never permissions. Unknown op values are refused.
Responses
Every response has ok. When it’s false, error says why: bad input, a change you didn’t approve, a keychain failure. Reads report per item instead: get answers ok: true with denied for items you refused and missing for IDs that don’t exist, and if anything was denied, no values are released at all. The command-line tool maps these to exit codes 77 and 66.
{"denied":["shop/production/STRIPE_KEY"],"masked":[],"ok":true,"values":{}}The item shape
What list returns in secrets, and what latchkey list --json prints:
[
{
"agentSafe" : false,
"kind" : "password",
"name" : "shop/development/DATABASE_URL",
"note" : "",
"service" : "Neon",
"updatedAt" : "2026-11-10T21:52:37Z",
"usedIn" : [
"/Users/you/Projects/shop/.env.local"
]
}
]| Field | Meaning |
|---|---|
name | The item ID |
kind | token, password, key or value |
agentSafe | Read without asking |
note | Free text |
service | Who issued it, optional |
usedIn | Files that reference it, recorded on import and move, optional |
updatedAt | When the value or settings last changed |
The grant shape
{
"created": "2026-11-10T20:00:00Z",
"createdBy": "zsh › claude",
"expires": "2026-11-10T22:00:00Z",
"folder": "/Users/you/Projects/shop",
"id": "k3v9q2",
"names": ["shop/development/*"],
"repo": "/Users/you/Projects/shop/.git"
}repo is the repository’s common .git folder, present when the folder is in one; commands run from any of its worktrees are covered.
The access log
~/Library/Application Support/Latchkey/access.jsonl, mode 0600: one JSON object per line for every read, change and refusal. Never values.
{"chain":["zsh","claude","Terminal"],"command":"latchkey run -- npm test","cwd":"/Users/you/Projects/shop","decision":"allowed (grant k3v9q2)","names":["shop/development/DATABASE_URL"],"op":"get","time":"2026-11-10T20:14:03Z"}| Field | Meaning |
|---|---|
time | When |
op | The operation |
names | Item IDs involved |
decision | What happened: allowed and why, denied, refused |
chain | The calling process and its parents, nearest first |
cwd | The folder the caller ran in, from the kernel |
command | The caller’s command line, from the kernel |
program | The calling program’s path, when it isn’t Latchkey’s signed command-line tool |
prev, mac | The keyed hash (HMAC-SHA256) of the entry before and of this one. latchkey log --verify checks the chain against a key and head only Latchkey can read |
Files and storage
| Where | What |
|---|---|
iCloud Keychain, access group TEAM.io.snackstud.latchkey | Items (service latchkey), earlier values (latchkey.history) and remote links (latchkey.remote), as generic passwords. Synced to your Macs. |
~/Library/Application Support/Latchkey/broker.sock | The broker socket |
~/Library/Application Support/Latchkey/access.jsonl | The access log |
Keychain, service latchkey.grants | Grants in effect, on this Mac only, changeable only by Latchkey |
/Applications/Latchkey.app/Contents/Helpers/latchkey | The command-line tool, linked from ~/.local/bin/latchkey |