{"openapi":"3.1.0","info":{"title":"Mahfouz API","version":"1","description":"Read and change Mahfouz vaults from an integration. Every answer but this document needs an OAuth access token minted for the resource `https://api.mahfouz.app/v1`. An error answers the envelope below; Cloudflare's own 502, 504 and 52x answers carry none."},"servers":[{"url":"https://api.mahfouz.app"}],"security":[{"oauth":["vaults:read"]}],"paths":{"/v1/openapi.json":{"get":{"operationId":"getOpenApi","summary":"This document.","security":[],"responses":{"200":{"description":"The OpenAPI document.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/me":{"get":{"operationId":"getMe","summary":"The Mahfouz account the token was granted by.","description":"Key a connection on `account.id`: the same account answers the same id from every grant and client, and two accounts never share one. It answers whatever the account's plan.","responses":{"200":{"description":"The grant's account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults":{"get":{"operationId":"listVaults","summary":"The vaults the token reaches.","responses":{"200":{"description":"The grant's vaults.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VaultList"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases":{"get":{"operationId":"listDatabases","summary":"A vault's databases, a page at a time.","description":"Every live database in the vault, at any depth (one inside another database's row included), in note-id order. A page resumes after the last database of the one before, so a retitle, move or delete never repeats or skips one; a database created during a walk may be missed until the next walk. A database whose block can't be read is listed, and its rows answer 422 `unsupported`.","parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"query","in":"query","required":false,"description":"A case-insensitive substring of the title. Trimmed; 1 to 256 characters after that.","schema":{"type":"string","minLength":1,"maxLength":256}},{"name":"cursor","in":"query","required":false,"description":"The `next_cursor` of the previous page. It holds under any `query` or `limit`.","schema":{"type":"string","minLength":1,"maxLength":512}},{"name":"limit","in":"query","required":false,"description":"At most this many databases, 100 when left out.","schema":{"type":"integer","minimum":1,"maximum":200,"default":100}}],"responses":{"200":{"description":"One page of databases.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DatabasesPage"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases/{database}/schema":{"get":{"operationId":"getDatabaseSchema","summary":"A database's views and the attributes its rows can hold.","description":"Every attribute the database uses: each property its block names, each key a view reads (its columns, grouping, dates, colours and Gantt relations) and each key a row holds, sorted by key, the built-in fields (`title`, `created`, `updated`, `created_by`, `updated_by`, `id`) left out. An attribute's type is its rollup or relation in the block first, then the vault's type, `text` when untyped. An option has no id: its `value` is the text rows hold, so renaming an option (which rewrites the type and every row in one commit) reads as one option gone and one new. A row may hold a value no option lists (written by hand). `GET …/rows` answers a multi-select's value as a list only when the row wrote it as one; a value written `a, b` comes back as text. `version` changes whenever anything here does: compare it to notice a change without comparing the whole answer. A database whose block can't be read, or with more than 1000 attributes, answers 422 `unsupported`, never part of its schema.","parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}}],"responses":{"200":{"description":"The database's schema.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DatabaseSchema"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases/{database}/subscriptions":{"get":{"operationId":"listSubscriptions","summary":"This connection's change subscriptions to a database.","description":"Only the subscriptions this grant made, active or disabled; never their secrets. A disabled one stays listed, with why, until it's deleted.","parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}}],"responses":{"200":{"description":"The subscriptions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionList"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}},"post":{"operationId":"createSubscription","summary":"Subscribe a callback to a database's changes.","description":"Mahfouz POSTs a signed `database.changed` notification to `callback_url` when a change from any writer (the apps, an agent, this API, a plain `git push`) lands in the database's rows or its own note, usually within a minute. It carries the database and vault ids and a `since` cursor, never row contents: read the changes with `GET …/rows?since=`. Notifications are signed as Standard Webhooks (`webhook-id`, `webhook-timestamp`, `webhook-signature`) with the `secret` this answer carries, once. The callback must be https on port 443 naming a public host. A failed delivery is retried with backoff for about 16 hours, then the subscription is disabled; a 410 disables it at once. Subscriptions end with the grant. Read access is enough.","parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionBody"}}}},"responses":{"201":{"description":"The subscription and its secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionCreated"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases/{database}/subscriptions/{subscription}":{"delete":{"operationId":"deleteSubscription","summary":"End a subscription.","parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"subscription","in":"path","required":true,"description":"The subscription's id.","schema":{"type":"string","minLength":1,"maxLength":128}}],"responses":{"204":{"description":"Deleted; nothing more is sent."},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases/{database}/rows":{"get":{"operationId":"listRows","summary":"A database's rows through one view, a page at a time; or, with `snapshot` or `since`, the sync feed.","description":"Without `snapshot` or `since`: one view's rows, filtered and sorted as the view is, paged by `cursor`. An offset cursor: a page can skip or repeat a row when rows are added, removed or re-sorted between pages.\n\nThe sync feed, for keeping a copy of a database: `snapshot=true` starts a snapshot of every row (no view's filter), in row-id order, paged by id. Each page reads the rows as they are at that request; what the cursor pins is the commit the snapshot started at, which the changes after it are read from. Each answer carries `next_cursor` and `has_more`; while `has_more` is true, call again at once with `since=<next_cursor>`. Once it's false, keep `next_cursor` and poll later with `since=<next_cursor>`: the answer is the rows changed since (as they are now) and the ids of rows removed since (deleted, moved out of the database, or replaced by another note at their path), in id order, paged the same way. A snapshot's last cursor reads changes from the commit the snapshot started at, so a row edited while you paged it comes back in the next read (and may come twice), and a row deleted before you reached it shows only as a removed id: `removed` can name a row you never saw. The cursor is the vault's git history, not a clock: it's stable whatever edits land meanwhile, and a row may come back more than once. Only a row's own note counts: a rollup whose value changed because a related row did isn't reported. When the commit a cursor names is no longer in the vault's history (the branch was force-pushed), or more than 10000 note files changed since, the answer is 410 `cursor_expired`: start a new snapshot. `view` and `cursor` aren't taken with `snapshot` or `since`.","parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"view","in":"query","required":false,"description":"A view's key (its name, or `#<index>`); the first view when left out. Not with `snapshot` or `since`.","schema":{"type":"string","minLength":1,"maxLength":256}},{"name":"cursor","in":"query","required":false,"description":"The `next_cursor` of the previous page, with the same `view`. Not with `snapshot` or `since`.","schema":{"type":"string","minLength":1,"maxLength":512}},{"name":"snapshot","in":"query","required":false,"description":"`true` starts the sync feed with a snapshot of every row.","schema":{"type":"string","enum":["true"]}},{"name":"since","in":"query","required":false,"description":"A sync feed answer's `next_cursor`: the snapshot's next page, or the changes since.","schema":{"type":"string","minLength":1,"maxLength":1400}},{"name":"limit","in":"query","required":false,"description":"At most this many rows (and removed ids, in the sync feed), 100 when left out.","schema":{"type":"integer","minimum":1,"maximum":200,"default":100}}],"responses":{"200":{"description":"One page of a view's rows, or of the sync feed.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/RowsPage"},{"$ref":"#/components/schemas/RowChanges"}]}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"410":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases/{database}/rows/{row}":{"get":{"operationId":"getRow","summary":"One row, with its body and version.","description":"The row as `GET …/rows` answers it, plus its Markdown body (the note below its frontmatter, raw: comment threads and suggestions are CriticMarkup in it) and `version`, also sent as `ETag`. The version changes whenever the row's file does (its body, an attribute or a comment); it isn't a git sha. A read can see the vault up to 5 seconds old, so a write with its `ETag` can meet a 412 it would have passed a moment later: read again and retry. An encrypted row answers `body: null` and `encrypted: true`.","parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"row","in":"path","required":true,"description":"The row note's id.","schema":{"type":"string","minLength":1,"maxLength":128}}],"responses":{"200":{"description":"The row.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RowWithBody"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}},"patch":{"operationId":"patchRow","summary":"Set or remove a row's attributes.","description":"Sets each attribute given a string or an array of strings, and removes each one given null. Send `If-Match` to write only while the row is as you read it, and `Idempotency-Key` to make a retry safe. The answer is the row as it is now, its `version` also sent as `ETag`; when the write changed the row, its `updated_by_client` is your client id, which the write's commit records.","security":[{"oauth":["vaults:read","vaults:write"]}],"parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"row","in":"path","required":true,"description":"The row note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"If-Match","in":"header","required":false,"description":"The row's `ETag` as a read answered it (or a listed row's `version`, quoted), or `*`: the write is refused with 412 `version_mismatch` (nothing written; the row's `ETag` now in the answer's header, unless the row is gone or was moved on GitHub) when the row's version is another, including when another change to the row reaches GitHub while this write saves. One strong entity tag only; a weak tag (`W/…`) or a list is 400. Without it the write is unconditional.","schema":{"type":"string","maxLength":132}},{"name":"Idempotency-Key","in":"header","required":false,"description":"1 to 128 printable ASCII characters naming this write. Within 24 hours, the same key with the same request answers the first answer again (status and `ETag` included, the row as it was then) without writing; with another request, 409 `idempotency_conflict`; while the first is still running, 503 `busy`. `If-Match` isn't part of the request it compares. A key is your grant's and its vault's: after you authorize again, the same key is a new request. An answer that saved nothing (an error with `landed: false`) isn't kept, so retrying runs it again. If the first call's outcome was lost, every repeat answers 500 `internal` with `landed: null`: read the row, then use a new key.","schema":{"type":"string","minLength":1,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchBody"}}}},"responses":{"200":{"description":"The row as it is now.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Row"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"412":{"description":"`version_mismatch`: the row's version isn't the one sent. Nothing was written.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases/{database}/rows/{row}/body":{"put":{"operationId":"putRowBody","summary":"Replace a row's body.","description":"Replaces the Markdown below the row's frontmatter, as an agent's rewrite does. A changed first heading changes the row's title (and renames its file); the answer names the title now. Refused with 422 `refused` when the row is in Suggesting mode, or when the new body would add, drop or change a comment thread (send back the threads as you read them; add comments with `POST …/comments`); 422 `unsupported` for an encrypted row. With `If-Match`, a change to the row on GitHub that lands while this write saves is a 412 too, never merged under it.","security":[{"oauth":["vaults:read","vaults:write"]}],"parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"row","in":"path","required":true,"description":"The row note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"If-Match","in":"header","required":false,"description":"The row's `ETag` as a read answered it (or a listed row's `version`, quoted), or `*`: the write is refused with 412 `version_mismatch` (nothing written; the row's `ETag` now in the answer's header, unless the row is gone or was moved on GitHub) when the row's version is another, including when another change to the row reaches GitHub while this write saves. One strong entity tag only; a weak tag (`W/…`) or a list is 400. Without it the write is unconditional.","schema":{"type":"string","maxLength":132}},{"name":"Idempotency-Key","in":"header","required":false,"description":"1 to 128 printable ASCII characters naming this write. Within 24 hours, the same key with the same request answers the first answer again (status and `ETag` included, the row as it was then) without writing; with another request, 409 `idempotency_conflict`; while the first is still running, 503 `busy`. `If-Match` isn't part of the request it compares. A key is your grant's and its vault's: after you authorize again, the same key is a new request. An answer that saved nothing (an error with `landed: false`) isn't kept, so retrying runs it again. If the first call's outcome was lost, every repeat answers 500 `internal` with `landed: null`: read the row, then use a new key.","schema":{"type":"string","minLength":1,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutBody"}}}},"responses":{"200":{"description":"The row's title and version now.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BodyWritten"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"412":{"description":"`version_mismatch`: the row's version isn't the one sent. Nothing was written.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases/{database}/rows/{row}/body/append":{"post":{"operationId":"appendRowBody","summary":"Append Markdown to a row's body.","description":"Adds `text` after a blank line at the end of the body (alone when the body is empty). Refused as `PUT …/body` is; with `If-Match`, so is a change to the row reaching GitHub while it saves.","security":[{"oauth":["vaults:read","vaults:write"]}],"parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"row","in":"path","required":true,"description":"The row note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"If-Match","in":"header","required":false,"description":"The row's `ETag` as a read answered it (or a listed row's `version`, quoted), or `*`: the write is refused with 412 `version_mismatch` (nothing written; the row's `ETag` now in the answer's header, unless the row is gone or was moved on GitHub) when the row's version is another, including when another change to the row reaches GitHub while this write saves. One strong entity tag only; a weak tag (`W/…`) or a list is 400. Without it the write is unconditional.","schema":{"type":"string","maxLength":132}},{"name":"Idempotency-Key","in":"header","required":false,"description":"1 to 128 printable ASCII characters naming this write. Within 24 hours, the same key with the same request answers the first answer again (status and `ETag` included, the row as it was then) without writing; with another request, 409 `idempotency_conflict`; while the first is still running, 503 `busy`. `If-Match` isn't part of the request it compares. A key is your grant's and its vault's: after you authorize again, the same key is a new request. An answer that saved nothing (an error with `landed: false`) isn't kept, so retrying runs it again. If the first call's outcome was lost, every repeat answers 500 `internal` with `landed: null`: read the row, then use a new key.","schema":{"type":"string","minLength":1,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppendBody"}}}},"responses":{"200":{"description":"The row's title and version now.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BodyWritten"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"412":{"description":"`version_mismatch`: the row's version isn't the one sent. Nothing was written.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/vaults/{vault}/databases/{database}/rows/{row}/comments":{"get":{"operationId":"listRowComments","summary":"A row's comment threads.","description":"Every comment thread in the row's body, in order. A thread's `id` follows its first comment: it stays while that comment does, whatever happens to the anchor or the replies, and changes if the first comment is edited in Mahfouz. `created_by_client` is the OAuth client id that wrote a comment through this API, null otherwise. An encrypted row answers 422 `unsupported`.","parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"row","in":"path","required":true,"description":"The row note's id.","schema":{"type":"string","minLength":1,"maxLength":128}}],"responses":{"200":{"description":"The threads and the row's version.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommentThreads"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}},"post":{"operationId":"addRowComment","summary":"Start a comment thread on a row.","description":"A thread by the connection's user, recording the OAuth client. With `quote`, anchored on that text, which must occur exactly once in the body outside comments and suggestions; without, a point thread in a paragraph of its own at the end of the body (an empty body included). Dated in UTC. Works in Suggesting mode; 422 `unsupported` for an encrypted row, 422 `refused` for a quote that isn't found once.","security":[{"oauth":["vaults:read","vaults:write"]}],"parameters":[{"name":"vault","in":"path","required":true,"description":"The vault's id: its GitHub repository's numeric id, as `GET /v1/vaults` lists it.","schema":{"type":"string","pattern":"^[1-9][0-9]{0,15}$"}},{"name":"database","in":"path","required":true,"description":"The database note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"row","in":"path","required":true,"description":"The row note's id.","schema":{"type":"string","minLength":1,"maxLength":128}},{"name":"If-Match","in":"header","required":false,"description":"The row's `ETag` as a read answered it (or a listed row's `version`, quoted), or `*`: the write is refused with 412 `version_mismatch` (nothing written; the row's `ETag` now in the answer's header, unless the row is gone or was moved on GitHub) when the row's version is another, including when another change to the row reaches GitHub while this write saves. One strong entity tag only; a weak tag (`W/…`) or a list is 400. Without it the write is unconditional.","schema":{"type":"string","maxLength":132}},{"name":"Idempotency-Key","in":"header","required":false,"description":"1 to 128 printable ASCII characters naming this write. Within 24 hours, the same key with the same request answers the first answer again (status and `ETag` included, the row as it was then) without writing; with another request, 409 `idempotency_conflict`; while the first is still running, 503 `busy`. `If-Match` isn't part of the request it compares. A key is your grant's and its vault's: after you authorize again, the same key is a new request. An answer that saved nothing (an error with `landed: false`) isn't kept, so retrying runs it again. If the first call's outcome was lost, every repeat answers 500 `internal` with `landed: null`: read the row, then use a new key.","schema":{"type":"string","minLength":1,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommentBody"}}}},"responses":{"201":{"description":"The thread and the row's version now.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommentAdded"}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"412":{"description":"`version_mismatch`: the row's version isn't the one sent. Nothing was written.","headers":{"ETag":{"description":"The row's version, quoted: send it as `If-Match`.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"$ref":"#/components/responses/Error"},"423":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"500":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}}},"components":{"securitySchemes":{"oauth":{"type":"oauth2","description":"Authorization code with PKCE. Send `resource=https://api.mahfouz.app/v1` on authorize and token.","flows":{"authorizationCode":{"authorizationUrl":"https://platform.mahfouz.app/mcp/authorize","tokenUrl":"https://platform.mahfouz.app/mcp/token","refreshUrl":"https://platform.mahfouz.app/mcp/token","scopes":{"vaults:read":"Read the vaults you pick.","vaults:write":"Change the vaults you allow edits in."}}}}},"responses":{"Error":{"description":"An error, as the envelope.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Account":{"type":"object","required":["id","login"],"additionalProperties":false,"properties":{"id":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$","description":"The Mahfouz account id, a lowercase UUIDv7: stable for the account (support can rarely move a person to another account), never the GitHub user id. Don't log or forward it."},"login":{"type":"string","description":"The GitHub login the account signed in with when it granted access; for display only, and stale after a GitHub rename."}}},"Me":{"type":"object","required":["account"],"additionalProperties":false,"properties":{"account":{"$ref":"#/components/schemas/Account"}}},"Vault":{"type":"object","required":["id","name","can_write","paused"],"additionalProperties":false,"properties":{"id":{"type":"string","description":"The GitHub repository's numeric id."},"name":{"type":"string","description":"`owner/repo` as GitHub named it at consent."},"can_write":{"type":"boolean"},"paused":{"type":"boolean","description":"The plan pauses this vault (past its repository limit)."}}},"VaultList":{"type":"object","required":["vaults"],"additionalProperties":false,"properties":{"vaults":{"type":"array","items":{"$ref":"#/components/schemas/Vault"}}}},"Database":{"type":"object","required":["id","title","path","kind","row_count","updated"],"additionalProperties":false,"properties":{"id":{"type":"string","description":"The database note's id: the `{database}` of its rows."},"title":{"type":"string"},"path":{"type":"string","description":"The database note's path in the vault."},"kind":{"type":"string","enum":["custom","tasks","people","daily"],"description":"`tasks`: task pages; `people`: the People database; `daily`: Daily notes; `custom`: any other."},"row_count":{"type":"integer","minimum":0,"description":"Its rows, before any view's filters."},"updated":{"type":"string","description":"When the database page itself last changed (not its rows)."}}},"DatabasesPage":{"type":"object","required":["databases","next_cursor"],"additionalProperties":false,"properties":{"databases":{"type":"array","items":{"$ref":"#/components/schemas/Database"}},"next_cursor":{"type":["string","null"],"description":"Pass as `cursor` for the next page; null on the last."}}},"SchemaOption":{"type":"object","required":["value","color"],"additionalProperties":false,"properties":{"value":{"type":"string","description":"The text rows hold for this option. Not an id: renaming the option changes it, on the type and on every row."},"color":{"type":["string","null"],"description":"The option's colour name (`gray`, `red`, …), or null."}}},"SchemaView":{"type":"object","required":["key","name","type","columns","group_by"],"additionalProperties":false,"properties":{"key":{"type":"string","description":"The view's key: the `view` rows takes."},"name":{"type":"string"},"type":{"type":"string","description":"`table`, `kanban`, `cards`, `calendar`, `gantt`, or another type kept as written."},"columns":{"type":"array","items":{"type":"string"},"description":"Its shown columns in order. May name built-in fields (`title`), which aren't among `attributes`."},"group_by":{"oneOf":[{"type":"null"},{"type":"object","required":["property","direction"],"additionalProperties":false,"properties":{"property":{"type":"string"},"direction":{"type":"string","enum":["ASC","DESC"]}}}]}}},"SchemaAttribute":{"type":"object","required":["key","label","type","options","format","relation","rollup"],"additionalProperties":false,"properties":{"key":{"type":"string","description":"The key rows hold it under."},"label":{"type":["string","null"],"description":"The block's `displayName` for it, or null."},"type":{"type":"string","enum":["text","number","checkbox","url","email","phone","date","datetime","select","multiselect","color","font","attachment","image","audio","video","relation","rollup"]},"options":{"description":"A `select`'s or `multiselect`'s options in their configured order; null for any other type.","oneOf":[{"type":"null"},{"type":"array","items":{"$ref":"#/components/schemas/SchemaOption"}}]},"format":{"type":["string","null"],"description":"A `date`'s or `datetime`'s display format, or null."},"relation":{"description":"A `relation`'s target and reverse key; null for any other type, and for a key the vault types Relation that this database's block holds no relation for.","oneOf":[{"type":"null"},{"type":"object","required":["target","reverse","target_text"],"additionalProperties":false,"properties":{"target":{"description":"The database its links land in, or null when the block's target names none.","oneOf":[{"type":"null"},{"type":"object","required":["id","title","kind"],"additionalProperties":false,"properties":{"id":{"type":"string"},"title":{"type":"string"},"kind":{"type":"string","enum":["custom","tasks","people","daily"]}}}]},"target_text":{"type":"string","description":"The block's target as written (`[[Authors]]`)."},"reverse":{"type":["string","null"],"description":"The target's key that links back, or null for a one-way relation."}}}]},"rollup":{"description":"A `rollup`'s definition; null for any other type. Its values come with the rows.","oneOf":[{"type":"null"},{"type":"object","required":["relation","property","function","result_type","error"],"additionalProperties":false,"properties":{"relation":{"type":"string","description":"The relation key it reads through."},"property":{"type":"string","description":"The key it reads on the related rows."},"function":{"type":"string"},"result_type":{"type":["string","null"],"description":"What its value reads as (`number`, `date`, `datetime`, `multiselect`), or null when it's invalid."},"error":{"type":["string","null"],"description":"Why it can't be computed (rows leave it out), or null."}}}]}}},"DatabaseSchema":{"type":"object","required":["id","title","path","kind","version","views","attributes"],"additionalProperties":false,"properties":{"id":{"type":"string"},"title":{"type":"string"},"path":{"type":"string","description":"The database note's path in the vault."},"kind":{"type":"string","enum":["custom","tasks","people","daily"]},"version":{"type":"string","pattern":"^[0-9a-f]{64}$","description":"Changes whenever anything else in this answer does."},"views":{"type":"array","items":{"$ref":"#/components/schemas/SchemaView"}},"attributes":{"type":"array","items":{"$ref":"#/components/schemas/SchemaAttribute"}}}},"Row":{"type":"object","required":["id","title","created","updated","attributes","version","created_by_client","updated_by_client"],"additionalProperties":false,"properties":{"id":{"type":"string"},"title":{"type":"string"},"created":{"type":"string","description":"When the row was created, as its note records it."},"updated":{"type":"string","description":"When the row was last changed, as its note records it."},"attributes":{"type":"object","description":"The row's attributes, typed; never a built-in field. `created_by` and `updated_by`, the commit authors, are built-ins the API doesn't return.","additionalProperties":true},"version":{"type":["string","null"],"description":"The row's version, as `GET …/rows/{row}` sends it in `ETag` (unquoted here): quote it to send as `If-Match`. Null when its file can't be read, and in a write's answer when the write merged with another change on GitHub (no `ETag` then): read the row again for its version."},"created_by_client":{"type":["string","null"],"description":"The OAuth client id whose API write created the row (the `Mahfouz-Client` trailer of the commit that added its file); null otherwise. No API op creates rows yet, so it's null unless the server couldn't follow a rename one of your writes made."},"updated_by_client":{"type":["string","null"],"description":"The OAuth client id of the row's last change (its latest commit's `Mahfouz-Client` trailer); null when a person, an agent or anything else made it. It names only the latest change: to recognize your own write in the sync feed, compare the row's `version` with the one your write answered."}}},"RowWithBody":{"type":"object","required":["id","title","created","updated","attributes","body","version","created_by_client","updated_by_client"],"additionalProperties":false,"properties":{"id":{"type":"string"},"title":{"type":"string"},"created":{"type":"string"},"updated":{"type":"string"},"attributes":{"type":"object","additionalProperties":true},"body":{"type":["string","null"],"description":"The Markdown below the frontmatter, raw; null for an encrypted row."},"encrypted":{"type":"boolean","const":true,"description":"Present, true, for an encrypted row."},"version":{"type":["string","null"],"description":"The row's version, as `ETag` sends it (unquoted here)."},"created_by_client":{"type":["string","null"],"description":"As a listed row's."},"updated_by_client":{"type":["string","null"],"description":"As a listed row's."}}},"PutBody":{"type":"object","required":["body"],"additionalProperties":false,"properties":{"body":{"type":"string","description":"The whole new body, at most 1 MB in UTF-8."}}},"AppendBody":{"type":"object","required":["text"],"additionalProperties":false,"properties":{"text":{"type":"string","minLength":1,"description":"Markdown to append; not blank. The body after it is at most 1 MB in UTF-8."}}},"BodyWritten":{"type":"object","required":["id","title","version"],"additionalProperties":false,"properties":{"id":{"type":"string"},"title":{"type":"string"},"version":{"type":["string","null"]}}},"CommentBody":{"type":"object","required":["text"],"additionalProperties":false,"properties":{"text":{"type":"string","minLength":1,"maxLength":10000,"description":"The comment. Stored on one line: line breaks become spaces, and it's trimmed."},"quote":{"type":["string","null"],"minLength":1,"maxLength":2000,"description":"Text of the body to anchor the thread on."}}},"CommentEntry":{"type":"object","required":["author","created","text","edited","created_by_client"],"additionalProperties":false,"properties":{"author":{"type":"string","description":"`@` and the GitHub login."},"created":{"type":"string","description":"`YYYY-MM-DD`."},"text":{"type":"string"},"edited":{"type":"boolean"},"created_by_client":{"type":["string","null"],"description":"The OAuth client id that wrote it through this API; null otherwise."}}},"CommentThread":{"type":"object","required":["id","anchor","resolved","entries"],"additionalProperties":false,"properties":{"id":{"type":"string"},"anchor":{"type":"string","description":"The anchored text; empty for a point thread."},"resolved":{"type":"boolean"},"entries":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/CommentEntry"}}}},"CommentThreads":{"type":"object","required":["threads","version"],"additionalProperties":false,"properties":{"threads":{"type":"array","items":{"$ref":"#/components/schemas/CommentThread"}},"version":{"type":["string","null"]}}},"CommentAdded":{"type":"object","required":["thread","version"],"additionalProperties":false,"properties":{"thread":{"$ref":"#/components/schemas/CommentThread"},"version":{"type":["string","null"]}}},"RowsPage":{"type":"object","required":["rows","next_cursor"],"additionalProperties":false,"properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/Row"}},"next_cursor":{"type":["string","null"],"description":"Pass as `cursor` for the next page; null on the last."}}},"RowChanges":{"type":"object","required":["rows","removed","next_cursor","has_more"],"additionalProperties":false,"properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/Row"},"description":"Rows as they are now: a snapshot's, or those changed since the cursor."},"removed":{"type":"array","items":{"type":"string"},"description":"Ids of rows removed since the cursor; always empty in a snapshot."},"next_cursor":{"type":"string","description":"Pass as `since`: at once while `has_more`, else on your next poll."},"has_more":{"type":"boolean","description":"Whether more of this snapshot or change set is waiting."}}},"SubscriptionBody":{"type":"object","required":["callback_url"],"additionalProperties":false,"properties":{"callback_url":{"type":"string","format":"uri","maxLength":2048,"description":"An https URL on port 443 naming a public host."}}},"Subscription":{"type":"object","required":["id","vault_id","database_id","callback_url","status","disabled_reason","created_at","pending","last_delivery"],"additionalProperties":false,"properties":{"id":{"type":"string"},"vault_id":{"type":"string"},"database_id":{"type":"string"},"callback_url":{"type":"string"},"status":{"type":"string","enum":["active","disabled"]},"disabled_reason":{"type":["string","null"],"enum":["failing","callback_gone",null],"description":"`failing`: every retry failed; `callback_gone`: the callback answered 410."},"created_at":{"type":"string","format":"date-time"},"pending":{"type":"boolean","description":"A notification is waiting to be sent or retried."},"last_delivery":{"oneOf":[{"type":"null"},{"type":"object","required":["at","ok","status","error"],"additionalProperties":false,"properties":{"at":{"type":"string","format":"date-time"},"ok":{"type":"boolean"},"status":{"type":["integer","null"]},"error":{"type":["string","null"]}}}]}}},"SubscriptionCreated":{"type":"object","required":["id","vault_id","database_id","callback_url","status","disabled_reason","created_at","pending","last_delivery","secret"],"additionalProperties":false,"properties":{"id":{"type":"string"},"vault_id":{"type":"string"},"database_id":{"type":"string"},"callback_url":{"type":"string"},"status":{"type":"string","enum":["active","disabled"]},"disabled_reason":{"type":["string","null"],"enum":["failing","callback_gone",null],"description":"`failing`: every retry failed; `callback_gone`: the callback answered 410."},"created_at":{"type":"string","format":"date-time"},"pending":{"type":"boolean","description":"A notification is waiting to be sent or retried."},"last_delivery":{"oneOf":[{"type":"null"},{"type":"object","required":["at","ok","status","error"],"additionalProperties":false,"properties":{"at":{"type":"string","format":"date-time"},"ok":{"type":"boolean"},"status":{"type":["integer","null"]},"error":{"type":["string","null"]}}}]},"secret":{"type":"string","pattern":"^whsec_","description":"The signing secret, answered only here."}}},"SubscriptionList":{"type":"object","required":["subscriptions"],"additionalProperties":false,"properties":{"subscriptions":{"type":"array","items":{"$ref":"#/components/schemas/Subscription"}}}},"PatchBody":{"type":"object","required":["attributes"],"additionalProperties":false,"properties":{"attributes":{"type":"object","minProperties":1,"description":"Key to value: a string sets it, an array of strings sets it as a list, null removes it.","additionalProperties":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}},{"type":"null"}]}}}},"Error":{"type":"object","required":["code","class","message","retryable","landed"],"additionalProperties":false,"properties":{"code":{"type":"string","enum":["indexing","busy","at_capacity","rate_limited","server_paused","github_unavailable","plan_has_no_agents","hours_cap_reached","repository_paused","repository_blocked","not_found","permission_denied","github_token_expired","note_changed","version_mismatch","idempotency_conflict","cursor_expired","invalid_argument","too_large","unsupported","not_saved","upgrading","unauthenticated","internal","refused"]},"class":{"type":"string","enum":["throttled","provider_unavailable","permission_lost","not_found","conflict","invalid_mapping","size_limit","unsupported","internal"]},"message":{"type":"string"},"retryable":{"type":"boolean"},"retry_after_s":{"type":"integer","minimum":1,"description":"Also sent as `Retry-After`."},"landed":{"type":["boolean","null"],"description":"false: nothing was saved; true: the change was saved before the error; null: unknown."}}}}}}