Skip to content
VYLK

HTTP API reference

Every route of the vylk server, with its headers, parameters, body, responses, and an example. Read the client protocol guide before you build offline sync or encryption.

Download the OpenAPI specification

Overview

The vylk server has an HTTP API. The vylk web app uses it, and you can use it to build your own client. Send requests to your own server, for example http://localhost:8080. The API has no version prefix. Test your client against each vylk release that you support.

Authentication

The session cookie from POST /api/login. Store cookies in a cookie jar and send them with each request. The API does not accept bearer tokens or API keys.

Encrypted vaults

Routes that read or write notes take the X-Vylk-Vault-Protocol header. Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Errors

Error responses carry this object. Branch on code. The error text can change between releases.

KeyValueDescription
errorstringMessage in English.
codestringStable error code.
note_idstringNote that the error concerns.
current_revisionintegerCurrent revision on the server.
epochintegerCurrent vault epoch.
retry_afterintegerSeconds to wait before the next attempt.
permanentbooleanTrue when a retry cannot succeed.
operation_indexintegerIndex of the invalid operation in operations. At least 0.
client_sequenceintegerclient_sequence of the invalid operation.
op_idstringop_id of the invalid operation.

Authentication

Sign in, sign out, and check a session.

Sign in

POST /api/login

Creates a session for this device. Call GET /api/vault/bootstrap first to learn the vault mode. When mode is legacy or preparing, send password. When mode is encrypted or cleaning, omit password and send proof or recovery_proof. If you send both proofs, the server checks only recovery_proof. The body limit is 16 KiB.

Request headers

KeyValueDescription
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
passwordstringServer password, VYLK_PASSWORD. Plaintext vault and encryption setup only.
proofstringProof derived from the encryption password. Encrypted vault only.
recovery_proofstringProof derived from the recovery key. Encrypted vault only.

Responses

StatusCodeDescription
200Signed in. The response sets the session and vylk-device cookies.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
401invalid_credentialsThe password or proof is wrong.
429login_rate_limitedToo many failed attempts from this client address. Wait for the number of seconds in retry_after.
500create_session_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringTwo cookies: session and vylk-device. Store both.
Retry-AfterstringSent with status 429. Seconds to wait before the next attempt.

Response body

KeyValueDescription
oktrue
versionstringvylk version of the server.
revisionstringBuild of the web app. Not a note revision.
instance_idstringIdentity of the server database. It changes only when the database is replaced.

Example request

curl -X POST 'http://localhost:8080/api/login' \
	-c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "password": "your-server-password"
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Set-Cookie: vylk-device=96bfb40c6de6030d4179116bd0231d99; Path=/; Max-Age=31536000; HttpOnly; SameSite=Lax
Set-Cookie: session=3fae6c640760d12fcd77c5f3d25f02fb; Path=/; Max-Age=15552000; HttpOnly; SameSite=Lax

{
  "instance_id": "95e9c24f3f492f0b776fa9f58b5837f0",
  "ok": true,
  "revision": "3a7403423c47610d",
  "version": "3.1.2"
}

Sign out

POST /api/logout

Signs out this device. The server revokes every session that shares this device's vylk-device cookie, so other tabs of the same browser profile sign out too. The response clears the session cookie even when the session is missing or expired. Sign-out does not upload pending edits. Keep them on the client.

Responses

StatusCodeDescription
204Signed out. The response has no body.
500logout_failedThe server could not complete the request.

Response headers

KeyValueDescription
Set-CookiestringExpires the session cookie.

Example request

curl -X POST 'http://localhost:8080/api/logout'

Example response

HTTP/1.1 204 No Content
Set-Cookie: session=; Path=/; Max-Age=0; HttpOnly; SameSite=Lax

Get the session status

GET /api/check

Returns the server identity and vault state for a valid session. Before you resume sync, compare instance_id, vault_mode, and vault_epoch with the values that you stored. revision identifies the build of the web app, not a note revision.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The session is valid.
401authentication_requiredThe request has no valid session cookie.
500vault_status_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
oktrue
versionstringvylk version of the server.
revisionstringBuild of the web app. Not a note revision.
instance_idstringIdentity of the server database. It changes only when the database is replaced.
vault_modestringlegacy: plaintext vault. preparing: encryption setup is converting notes. cleaning: the server is removing plaintext data. encrypted: encrypted vault. One of legacy, preparing, cleaning, encrypted.
vault_epochintegerCurrent vault epoch. 0 in a plaintext vault.

Example request

curl 'http://localhost:8080/api/check' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "instance_id": "95e9c24f3f492f0b776fa9f58b5837f0",
  "ok": true,
  "revision": "3a7403423c47610d",
  "vault_epoch": 0,
  "vault_mode": "legacy",
  "version": "3.1.2"
}

Devices

List signed-in devices and sign them out.

List devices

GET /api/devices

Lists the devices that have an active session, most recently active first. All tabs of one browser profile share a vylk-device cookie and appear as one device. The server updates last_seen_at at most every few minutes, so the value is approximate.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The active devices.
401authentication_requiredThe request has no valid session cookie.
500devices_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
devicesarray of DeviceActive devices.

Example request

curl 'http://localhost:8080/api/devices' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "devices": [
    {
      "id": "96bfb40c6de6030d4179116bd0231d99",
      "name": "Chrome on Linux",
      "last_seen_at": "2026-11-22T02:41:08Z",
      "current": true
    },
    {
      "id": "bab973f17508af32c70e314d45d17307",
      "name": "Chrome on Android",
      "last_seen_at": "2026-11-22T02:41:08Z",
      "current": false
    }
  ]
}

Sign out a device

DELETE /api/devices/{id}

Revokes every session of a device. The request succeeds for a well-formed ID that matches no device. Revocation cannot delete notes or keys that the device already stores. An offline device learns about the revocation when it reconnects.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Path parameters

KeyValueDescription
idstring, requiredDevice ID from GET /api/devices. This is not the sync queue device_id. Pattern: ^[a-f0-9]{32}$.

Responses

StatusCodeDescription
204The device is signed out. The response has no body.
400invalid_deviceid is not 32 lowercase hexadecimal characters.
401authentication_requiredThe request has no valid session cookie.
403vault_changes_disabledThe server runs with VYLK_DISABLE_VAULT_CHANGES set to true.
500device_signout_failedThe server could not complete the request.

Response headers

KeyValueDescription
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Example request

curl -X DELETE 'http://localhost:8080/api/devices/bab973f17508af32c70e314d45d17307' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 204 No Content

Notes

Read, save, and delete single notes, and search a plaintext vault.

List notes

GET /api/notes

Lists note summaries without note content, most recently updated first. Without limit, the response is an array of every note. With limit, the response is one page, and nextCursor points to the next page. In a plaintext vault, nextCursor is absent on the last page. In an encrypted vault, it is an empty string. In an encrypted vault, each summary holds an encrypted summary envelope in place of title, tags, and filename.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Query parameters

KeyValueDescription
limitintegerPage size. In a plaintext vault, the range is 1 to 100 and an empty value means no limit. In an encrypted vault, the range is 1 to 500 and an empty value is an error. From 1 to 500.
cursorstringnextCursor from the previous page. Treat the value as opaque.
tagstringReturns only notes with this exact tag. Plaintext vault only.

Responses

StatusCodeDescription
200The note summaries.
400invalid_page_limitlimit is not an integer in the allowed range.
400invalid_cursorcursor is not a value from a previous page.
401authentication_requiredThe request has no valid session cookie.
409client_search_requiredThe vault is encrypted. Decrypt the note summaries and search or filter them on the client.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500list_notes_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

Without limit. Every note.

An array of Note summary.

With limit.

KeyValueDescription
notesarray of Note summaryNote summaries.
nextCursorstringCursor for the next page. Absent or empty on the last page.

Example request

curl 'http://localhost:8080/api/notes?limit=1' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "notes": [
    {
      "id": "trip-notes",
      "title": "Trip notes",
      "filename": "trip-notes.md",
      "tags": "travel",
      "pinned": false,
      "created_at": "2026-11-22T02:41:07Z",
      "updated_at": "2026-11-22T02:41:07Z",
      "revision": 2
    }
  ],
  "nextCursor": "MjAyNi0xMS0yMlQwMjo0MTowN1oAdHJpcC1ub3Rlcw"
}

Save a note

POST /api/notes

Creates a note or replaces a note completely. Send the whole note each time, not a change. To update a note, send its id and the base_revision that you last read. To create a note with an ID that you chose, send base_revision 0. In a plaintext vault, you can omit id, and the server generates one. In an encrypted vault, you must send id, base_revision, epoch, summary, and body. The response returns the note summary without its content. A new note also returns status 200. The body limit is 4 MiB in a plaintext vault and 8 MiB in an encrypted vault. Clients that queue offline edits use POST /api/sync/push instead.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Request body

Plaintext vault.

KeyValueDescription
idstringNote ID. Omit it to let the server generate an ID. Pattern: ^[A-Za-z0-9_-]{1,64}$.
titlestringTitle. At most 512 bytes.
contentstringNote text in Markdown.
tagsstringComma-separated tags. At most 4096 bytes.
base_revisionintegerRevision that you last read. Required with id. Use 0 for a new note.

Encrypted vault.

KeyValueDescription
idstring, requiredNote ID that the client generated. Pattern: ^[A-Za-z0-9_-]{1,64}$.
summaryEnvelope, requiredEncrypted title and tags.
bodyEnvelope, requiredEncrypted note text.
epochinteger, requiredCurrent vault epoch. At least 1.
base_revisioninteger, requiredRevision that you last read. Use 0 for a new note.

Responses

StatusCodeDescription
200The note is saved.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400base_revision_requiredid is present and base_revision is missing. Plaintext vault only.
400invalid_note_idid does not match ^[A-Za-z0-9_-]{1,64}$. Plaintext vault only.
400note_metadata_too_longtitle exceeds 512 bytes or tags exceeds 4096 bytes. Plaintext vault only.
400invalid_encrypted_noteA required field is missing or an envelope is malformed. Encrypted vault only.
401authentication_requiredThe request has no valid session cookie.
409note_revision_conflictbase_revision is not the current revision. In a plaintext vault, current_revision holds the current revision.
409stale_vault_epochepoch is not the current vault epoch. Read GET /api/vault/keys again. Encrypted vault only.
423vault_migration_in_progressEncryption setup is converting notes. Note writes are paused until it finishes.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500save_note_failedThe server could not complete the request.
503note_file_recovery_blockedAn interrupted file operation needs recovery before this note can change. Keep the change and retry later.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

Note. Note metadata in a plaintext vault.

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
titlestringTitle. At most 512 bytes.
filenamestringFile name in the notes folder. Not an API path.
tagsstringComma-separated tags. The server trims them and removes duplicates. Tags are case-sensitive. At most 4096 bytes.
pinnedbooleanTrue when the note is pinned.
pin_orderintegerPosition among pinned notes. Absent when 0.
created_atstring (date-time)Creation time.
updated_atstring (date-time)Time of the last change.
revisionintegerRevision. Each change increases it by 1.

Encrypted note. Note metadata in an encrypted vault.

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
summaryEnvelopeEncrypted title and tags.
pinnedbooleanTrue when the note is pinned.
pin_orderintegerPosition among pinned notes. 0 when not pinned.
created_atstring (date-time)Creation time.
updated_atstring (date-time)Time of the last change.
revisionintegerRevision. Each change increases it by 1.
epochintegerVault epoch that encrypted the note.

Example request

curl -X POST 'http://localhost:8080/api/notes' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "id": "trip-notes",
  "base_revision": 1,
  "title": "Trip notes",
  "tags": "travel",
  "content": "# Trip notes\n\nBook the train. Pack light.\n"
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "id": "trip-notes",
  "title": "Trip notes",
  "filename": "trip-notes.md",
  "tags": "travel",
  "pinned": false,
  "created_at": "2026-11-22T02:41:07Z",
  "updated_at": "2026-11-22T02:41:07Z",
  "revision": 2
}

Get a note

GET /api/notes/{id}

Returns one note with its content. In an encrypted vault, the note holds summary and body envelopes in place of title, tags, filename, and content.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Path parameters

KeyValueDescription
idstring, requiredNote identifier. Pattern: ^[A-Za-z0-9_-]{1,64}$.

Responses

StatusCodeDescription
200The note.
401authentication_requiredThe request has no valid session cookie.
404note_not_foundNo note has this ID.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500load_note_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

Plaintext vault.

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
titlestringTitle. At most 512 bytes.
filenamestringFile name in the notes folder. Not an API path.
tagsstringComma-separated tags. The server trims them and removes duplicates. Tags are case-sensitive. At most 4096 bytes.
pinnedbooleanTrue when the note is pinned.
pin_orderintegerPosition among pinned notes. Absent when 0.
created_atstring (date-time)Creation time.
updated_atstring (date-time)Time of the last change.
revisionintegerRevision. Each change increases it by 1.
contentstringNote text in Markdown.

Encrypted vault.

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
summaryEnvelopeEncrypted title and tags.
pinnedbooleanTrue when the note is pinned.
pin_orderintegerPosition among pinned notes. 0 when not pinned.
created_atstring (date-time)Creation time.
updated_atstring (date-time)Time of the last change.
revisionintegerRevision. Each change increases it by 1.
epochintegerVault epoch that encrypted the note.
bodyEnvelopeEncrypted note text.

Example request

curl 'http://localhost:8080/api/notes/trip-notes' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "id": "trip-notes",
  "title": "Trip notes",
  "filename": "trip-notes.md",
  "tags": "travel",
  "pinned": false,
  "created_at": "2026-11-22T02:41:07Z",
  "updated_at": "2026-11-22T02:41:07Z",
  "revision": 2,
  "content": "# Trip notes\n\nBook the train. Pack light.\n"
}

Delete a note

DELETE /api/notes/{id}

Deletes a note at a known revision. A second identical request returns 404 or 409. It does not succeed again. Clients that queue offline edits use a note.delete operation in POST /api/sync/push instead.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Path parameters

KeyValueDescription
idstring, requiredNote identifier. Pattern: ^[A-Za-z0-9_-]{1,64}$.

Query parameters

KeyValueDescription
base_revisioninteger, requiredThe revision that you last read. At least 1.

Responses

StatusCodeDescription
204The note is deleted. The response has no body.
400base_revision_requiredbase_revision is missing.
400invalid_note_revisionbase_revision is not a positive integer.
401authentication_requiredThe request has no valid session cookie.
404note_not_foundNo note has this ID.
409note_revision_conflictbase_revision is not the current revision. In a plaintext vault, current_revision holds the current revision.
423vault_migration_in_progressEncryption setup is converting notes. Note writes are paused until it finishes.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
423vault_unavailableThe encrypted vault is not ready. Encrypted vault only.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500delete_note_failedThe server could not complete the request.
503note_file_recovery_blockedAn interrupted file operation needs recovery before this note can change. Keep the change and retry later.

Response headers

KeyValueDescription
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Example request

curl -X DELETE 'http://localhost:8080/api/notes/trip-notes?base_revision=1' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 204 No Content

Search notes

GET /api/search

Searches note titles and tags, not note content. Plaintext vault only. The server splits q at white space, uses the first eight words, and matches notes that contain every word as a prefix. The response holds at most 50 summaries, best match first. An empty q returns an empty array. A query without matches returns null.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Query parameters

KeyValueDescription
qstringSearch text, at most 256 bytes.

Responses

StatusCodeDescription
200The matching note summaries, or null.
400search_query_too_longq exceeds 256 bytes after the server trims white space.
401authentication_requiredThe request has no valid session cookie.
409client_search_requiredThe vault is encrypted. Decrypt the note summaries and search or filter them on the client.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500search_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

array or null.

Example request

curl 'http://localhost:8080/api/search?q=trip' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[
  {
    "id": "trip-notes",
    "title": "Trip notes",
    "filename": "trip-notes.md",
    "tags": "travel",
    "pinned": false,
    "created_at": "2026-11-22T02:41:07Z",
    "updated_at": "2026-11-22T02:41:07Z",
    "revision": 2
  }
]

List tags

GET /api/tags

Lists every tag in use, sorted without regard to case. Plaintext vault only.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Responses

StatusCodeDescription
200The tags.
401authentication_requiredThe request has no valid session cookie.
409client_search_requiredThe vault is encrypted. Decrypt the note summaries and search or filter them on the client.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500list_tags_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

An array of string.

Example request

curl 'http://localhost:8080/api/tags' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[
  "errands",
  "home",
  "travel"
]

Sync

Pull changes, fetch notes in batches, push queued edits, and receive change events.

List changes

GET /api/sync

Returns the note changes after sequence since, oldest first. Each change names a note and its new revision. A change with deleted true is a deletion. Save nextSequence only after you apply the changes locally, and pass it as since in the next request. While hasMore is true, request the next page. When resetRequired is true, the server no longer has the changes after since. Rebuild your copy from GET /api/notes, and keep your pending edits. The client protocol describes the full sync procedure.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Query parameters

KeyValueDescription
sinceintegerSequence of the last change that you applied. The response starts after it. Default: 0. At least 0.
limitintegerMaximum number of changes. Default: 100. From 1 to 500.

Responses

StatusCodeDescription
200A page of changes.
400invalid_sync_sequencesince is not a non-negative integer.
400invalid_page_limitlimit is not an integer from 1 to 500.
401authentication_requiredThe request has no valid session cookie.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500list_sync_changes_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
changesarray of ChangeChanges, oldest first.
nextSequenceintegerSequence to send as since in the next request.
hasMorebooleanTrue when more changes follow.
resetRequiredbooleanTrue when the server no longer has the changes after since. Present only when true.
instance_idstringIdentity of the server database.

Example request

curl 'http://localhost:8080/api/sync?since=0&limit=100' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "changes": [
    {
      "sequence": 1,
      "note_id": "32366a862b3447c4551e8bc031bcdbad",
      "revision": 1,
      "deleted": false,
      "changed_at": "2026-11-22T02:41:07Z"
    },
    {
      "sequence": 2,
      "note_id": "trip-notes",
      "revision": 1,
      "deleted": false,
      "changed_at": "2026-11-22T02:41:07Z"
    },
    {
      "sequence": 3,
      "note_id": "trip-notes",
      "revision": 2,
      "deleted": false,
      "changed_at": "2026-11-22T02:41:07Z"
    }
  ],
  "nextSequence": 3,
  "hasMore": false,
  "instance_id": "95e9c24f3f492f0b776fa9f58b5837f0"
}

Get notes by ID

GET /api/sync/notes

Returns up to 25 complete notes. The server counts IDs before it removes duplicates. IDs that match no note appear in missing. A returned note can have a newer revision than the change that you are applying. Do not let it replace a pending local edit.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.

Query parameters

KeyValueDescription
idsstringComma-separated note IDs, without spaces. An empty value returns empty arrays.

Responses

StatusCodeDescription
200The notes that exist and the IDs that do not.
400too_many_note_idsids holds more than 25 IDs.
400invalid_note_idAn ID does not match ^[A-Za-z0-9_-]{1,64}$.
401authentication_requiredThe request has no valid session cookie.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500load_notes_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
notesarray of Note with contentComplete notes.
missingarray of stringRequested IDs that match no note.

Example request

curl 'http://localhost:8080/api/sync/notes?ids=trip-notes,deleted-note' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "missing": [
    "deleted-note"
  ],
  "notes": [
    {
      "id": "trip-notes",
      "title": "Trip notes",
      "filename": "trip-notes.md",
      "tags": "travel",
      "pinned": false,
      "created_at": "2026-11-22T02:41:07Z",
      "updated_at": "2026-11-22T02:41:07Z",
      "revision": 2,
      "content": "# Trip notes\n\nBook the train. Pack light.\n"
    },
    {
      "id": "32366a862b3447c4551e8bc031bcdbad",
      "title": "Groceries",
      "filename": "32366a862b3447c4551e8bc031bcdbad.md",
      "tags": "home,errands",
      "pinned": false,
      "created_at": "2026-11-22T02:41:07Z",
      "updated_at": "2026-11-22T02:41:07Z",
      "revision": 1,
      "content": "- Milk\n- Eggs\n"
    }
  ]
}

Push operations

POST /api/sync/push

Applies queued offline edits in order. Each client queue has its own device_id. Its client_sequence numbers start at 1 and have no gaps. Retry a failed request with the same operations, sequence numbers, and op_id values. The server acknowledges operations that it already applied without applying them again. A status of 200 does not mean that every operation applied. Read the status of each acknowledgement. A conflict also uses its sequence number. Send an empty operations array to read expected_sequence. The request holds at most 100 operations. The body limit is 4 MiB in a plaintext vault and 8 MiB in an encrypted vault. Saves carry the complete note. The server does not merge text. The client protocol describes queue handling.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.
X-Vylk-Vault-Protocol1Set it to 1 when the vault is encrypted. Without it, the request fails with 426. A plaintext vault ignores the header.
X-Vylk-Instance-IDstringThe instance_id that you stored. When it does not match the server, the request fails with 409 before any write. Send this header from every client that queues edits.

Request body

Plaintext vault.

KeyValueDescription
device_idstring, requiredIdentifier of the client queue. Keep it for the lifetime of the queue. Pattern: ^[A-Za-z0-9_-]{1,128}$.
operationsarray of Operation, requiredOperations in queue order. At most 100.

Encrypted vault.

KeyValueDescription
device_idstring, requiredIdentifier of the client queue. Keep it for the lifetime of the queue. Pattern: ^[A-Za-z0-9_-]{1,128}$.
operationsarray of Encrypted operation, requiredOperations in queue order. At most 100.

Responses

StatusCodeDescription
200The server processed the operations. Read each acknowledgement.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400invalid_sync_requestdevice_id is invalid or operations holds more than 100 items.
400invalid_sync_operationAn operation is invalid. Do not retry it. Plaintext vault only.
400invalid_encrypted_operationAn operation is invalid or holds a plaintext field. Encrypted vault only.
401authentication_requiredThe request has no valid session cookie.
409The first client_sequence is not expected_sequence. The body is a push result. acknowledged can hold operations that the server applied earlier.
409server_instance_changedX-Vylk-Instance-ID does not match the server. The database changed. Do not resend the queue without a decision from the user.
409invalid_replayed_operationA retried client_sequence arrived with a different op_id or type.
409stale_vault_epochAn operation has an old epoch. epoch holds the current one. Encrypted vault only.
423vault_migration_in_progressEncryption setup is converting notes. Note writes are paused until it finishes.
423vault_maintenance_in_progressThe server is removing plaintext data after encryption setup.
423vault_unavailableThe encrypted vault is not ready. Encrypted vault only.
426encrypted_client_requiredThe vault is encrypted and the request has no X-Vylk-Vault-Protocol: 1 header.
500apply_sync_operation_failedThe server could not complete the request.
503note_file_recovery_blockedAn interrupted file operation needs recovery before this note can change. Keep the change and retry later.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
acknowledgedarray of AcknowledgementOne result for each operation that the server processed.
expected_sequenceintegerclient_sequence that the server expects next. At least 1.

Example request

curl -X POST 'http://localhost:8080/api/sync/push' \
	-b cookies.txt -c cookies.txt \
	-H 'X-Vylk-Instance-ID: 95e9c24f3f492f0b776fa9f58b5837f0' \
	-H 'Content-Type: application/json' \
	-d '{
  "device_id": "laptop-queue-1",
  "operations": [
    {
      "client_sequence": 1,
      "op_id": "op-1",
      "type": "note.save",
      "note_id": "reading-list",
      "base_revision": 0,
      "title": "Reading list",
      "tags": "books",
      "content": "- Dune\n"
    },
    {
      "client_sequence": 2,
      "op_id": "op-2",
      "type": "note.pin",
      "note_id": "reading-list",
      "base_revision": 1,
      "pinned": true
    },
    {
      "client_sequence": 3,
      "op_id": "op-3",
      "type": "note.save",
      "note_id": "trip-notes",
      "base_revision": 1,
      "title": "Trip notes",
      "tags": "travel",
      "content": "stale\n"
    }
  ]
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "acknowledged": [
    {
      "client_sequence": 1,
      "op_id": "op-1",
      "status": "applied",
      "revision": 1
    },
    {
      "client_sequence": 2,
      "op_id": "op-2",
      "status": "applied",
      "revision": 2,
      "pin_order": 1
    },
    {
      "client_sequence": 3,
      "op_id": "op-3",
      "status": "conflict",
      "current_revision": 2
    }
  ],
  "expected_sequence": 4
}

Stream events

GET /api/events

Opens a Server-Sent Events stream. The stream starts with retry: 3000, a server event, and a heartbeat event. It sends a heartbeat every 25 seconds. A change event has a type. notes or preferences: pull the changes. ai: list the AI configurations again. Pull the changes after each reconnect too. When the session ends, the server sends session-expired and closes the stream. The events have no IDs, and the server ignores Last-Event-ID. The stream does not carry note data and is not a durable feed.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The event stream stays open.
401authentication_requiredThe request has no valid session cookie.
500The server could not start the stream. The body is plain text.

Response headers

KeyValueDescription
Content-Typetext/event-streamMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-cacheResponses are not cached.
X-Accel-BufferingnoTells nginx not to buffer the stream.

Example request

curl 'http://localhost:8080/api/events' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: text/event-stream
Cache-Control: no-cache
X-Accel-Buffering: no

retry: 3000

event: server
data: {"revision":"3a7403423c47610d","version":"3.1.2"}

event: heartbeat
data: {}

event: change
data: {"type":"notes","sequence":7}

Preferences

Read and replace the preferences that every device shares.

Get preferences

GET /api/prefs

Returns the preferences shared by every device. Preferences are not encrypted. The server fills in defaults for unset fields. The response has no ETag header. Read revision from the body.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The preferences.
401authentication_requiredThe request has no valid session cookie.
500load_preferences_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
aiEnabledbooleanTurn on AI. When false, every /api/ai/ route returns 403, and the server ends every AI session. Default: false.
revisionintegerRevision. Each save increases it by 1.
autoSavebooleanSync changes automatically. Changes are always saved on the device. Default: true.
reduceMotionstringsystem follows the operating system. always turns off animations. never keeps them on. One of system, always, never. Default: system.
startViewstringView of a newly opened note. One of editor, preview, split, zen. Default: editor.
hideToolbarbooleanHide the formatting toolbar above the editor. Default: false.
hideSaveButtonbooleanHide the manual Save button. Default: true.
saveButtonLocationstringpanel puts the Save button in the editor toolbar. header puts it in the app header. One of "", panel, header. Default: panel.
collapseDetailsbooleanCollapse the title and tags fields when a note opens.
hideCursorHighlightbooleanTurn off the preview highlight of the block at the cursor.
interactivePreviewbooleanAllow toggling tasks and moving blocks in Split and Preview views. Default: true.
statusDisplaystringSync status display. The web app uses normal, compact, or off.
contentWidthstringWidth of the text column. One of "", compact, standard, wide, full.
zenPageWidthstringWidth of the page in Zen mode. One of "", compact, standard, wide, full.
themestringBuilt-in theme name, or a palette string that the client defines. The server does not interpret it.
accentColorstringCustom accent color. Empty means the theme color.
fontFamilystringInterface font.
fontFamilyGooglebooleanLoad fontFamily from Google Fonts.
fontSizestringInterface font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
editorFontFamilystringEditor font.
editorFontFamilyGooglebooleanLoad editorFontFamily from Google Fonts.
editorFontSizestringEditor font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
previewFontFamilystringPreview font.
previewFontFamilyGooglebooleanLoad previewFontFamily from Google Fonts.
previewFontSizestringPreview font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
zenFontFamilystringZen mode font. Default: Inter.
zenFontFamilyGooglebooleanLoad zenFontFamily from Google Fonts. Default: true.
zenFontSizestringZen mode font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem. Default: 1.25rem.
zenWordCountbooleanShow the word count in Zen mode. Default: true.
zenShowTitlebooleanShow the title in Zen mode. Default: true.
zenShowControlsbooleanShow the controls in Zen mode. Default: true.
zenInteractivePreviewbooleanStored for clients. The vylk web app does not use it.
shortcutPrefixShortcutKey press that starts a shortcut. Exactly one step. The default is Mod+E.
keyboardShortcutsobjectCustom shortcuts by action name, at most 64. null turns off the default shortcut for that action. Each value is Shortcut or null.
shortcutConfirmationSkipsobjectActions that run without a confirmation, at most 64. Each value is true.
_sync_patchobjectChanged fields. prefs.save operations only.
_sync_baseobjectPrevious values of the changed fields. prefs.save operations only.

Example request

curl 'http://localhost:8080/api/prefs' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "aiEnabled": false,
  "reduceMotion": "system",
  "revision": 2,
  "autoSave": true,
  "startView": "split",
  "hideToolbar": false,
  "hideSaveButton": true,
  "saveButtonLocation": "panel",
  "collapseDetails": false,
  "hideCursorHighlight": false,
  "interactivePreview": true,
  "contentWidth": "standard",
  "zenPageWidth": "standard",
  "fontFamilyGoogle": false,
  "fontSize": "1rem",
  "editorFontFamilyGoogle": false,
  "editorFontSize": "1rem",
  "previewFontFamilyGoogle": false,
  "previewFontSize": "1rem",
  "zenFontFamily": "Inter",
  "zenFontFamilyGoogle": true,
  "zenFontSize": "1.25rem",
  "zenWordCount": true,
  "zenShowTitle": true,
  "zenShowControls": true,
  "zenInteractivePreview": false,
  "shortcutPrefix": {
    "steps": [
      {
        "key": "e",
        "modifiers": [
          "Mod"
        ]
      }
    ]
  },
  "keyboardShortcuts": {},
  "shortcutConfirmationSkips": {},
  "theme": "dark"
}

Replace preferences

PATCH /api/prefs

Replaces all preferences. The method is PATCH, but the server does not merge fields. A field that you omit returns to its default. Read the current preferences, change the fields, and send the whole object with its revision in If-Match. The server ignores _sync_patch and _sync_base on this route. The body limit is 16 KiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.
If-MatchstringThe revision that you last read, with or without quotes. Without this header or with *, the server replaces the preferences without a revision check.

Request body

KeyValueDescription
aiEnabledbooleanTurn on AI. When false, every /api/ai/ route returns 403, and the server ends every AI session. Default: false.
revisionintegerRevision. Each save increases it by 1.
autoSavebooleanSync changes automatically. Changes are always saved on the device. Default: true.
reduceMotionstringsystem follows the operating system. always turns off animations. never keeps them on. One of system, always, never. Default: system.
startViewstringView of a newly opened note. One of editor, preview, split, zen. Default: editor.
hideToolbarbooleanHide the formatting toolbar above the editor. Default: false.
hideSaveButtonbooleanHide the manual Save button. Default: true.
saveButtonLocationstringpanel puts the Save button in the editor toolbar. header puts it in the app header. One of "", panel, header. Default: panel.
collapseDetailsbooleanCollapse the title and tags fields when a note opens.
hideCursorHighlightbooleanTurn off the preview highlight of the block at the cursor.
interactivePreviewbooleanAllow toggling tasks and moving blocks in Split and Preview views. Default: true.
statusDisplaystringSync status display. The web app uses normal, compact, or off.
contentWidthstringWidth of the text column. One of "", compact, standard, wide, full.
zenPageWidthstringWidth of the page in Zen mode. One of "", compact, standard, wide, full.
themestringBuilt-in theme name, or a palette string that the client defines. The server does not interpret it.
accentColorstringCustom accent color. Empty means the theme color.
fontFamilystringInterface font.
fontFamilyGooglebooleanLoad fontFamily from Google Fonts.
fontSizestringInterface font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
editorFontFamilystringEditor font.
editorFontFamilyGooglebooleanLoad editorFontFamily from Google Fonts.
editorFontSizestringEditor font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
previewFontFamilystringPreview font.
previewFontFamilyGooglebooleanLoad previewFontFamily from Google Fonts.
previewFontSizestringPreview font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
zenFontFamilystringZen mode font. Default: Inter.
zenFontFamilyGooglebooleanLoad zenFontFamily from Google Fonts. Default: true.
zenFontSizestringZen mode font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem. Default: 1.25rem.
zenWordCountbooleanShow the word count in Zen mode. Default: true.
zenShowTitlebooleanShow the title in Zen mode. Default: true.
zenShowControlsbooleanShow the controls in Zen mode. Default: true.
zenInteractivePreviewbooleanStored for clients. The vylk web app does not use it.
shortcutPrefixShortcutKey press that starts a shortcut. Exactly one step. The default is Mod+E.
keyboardShortcutsobjectCustom shortcuts by action name, at most 64. null turns off the default shortcut for that action. Each value is Shortcut or null.
shortcutConfirmationSkipsobjectActions that run without a confirmation, at most 64. Each value is true.
_sync_patchobjectChanged fields. prefs.save operations only.
_sync_baseobjectPrevious values of the changed fields. prefs.save operations only.

Responses

StatusCodeDescription
200The saved preferences, with a new revision.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400invalid_preferences_revisionIf-Match is not a positive integer.
400invalid_preferencesA field has a value outside its allowed set. error names the field.
401authentication_requiredThe request has no valid session cookie.
409preferences_revision_conflictIf-Match is not the current revision. current_revision holds the current revision.
500save_preferences_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
aiEnabledbooleanTurn on AI. When false, every /api/ai/ route returns 403, and the server ends every AI session. Default: false.
revisionintegerRevision. Each save increases it by 1.
autoSavebooleanSync changes automatically. Changes are always saved on the device. Default: true.
reduceMotionstringsystem follows the operating system. always turns off animations. never keeps them on. One of system, always, never. Default: system.
startViewstringView of a newly opened note. One of editor, preview, split, zen. Default: editor.
hideToolbarbooleanHide the formatting toolbar above the editor. Default: false.
hideSaveButtonbooleanHide the manual Save button. Default: true.
saveButtonLocationstringpanel puts the Save button in the editor toolbar. header puts it in the app header. One of "", panel, header. Default: panel.
collapseDetailsbooleanCollapse the title and tags fields when a note opens.
hideCursorHighlightbooleanTurn off the preview highlight of the block at the cursor.
interactivePreviewbooleanAllow toggling tasks and moving blocks in Split and Preview views. Default: true.
statusDisplaystringSync status display. The web app uses normal, compact, or off.
contentWidthstringWidth of the text column. One of "", compact, standard, wide, full.
zenPageWidthstringWidth of the page in Zen mode. One of "", compact, standard, wide, full.
themestringBuilt-in theme name, or a palette string that the client defines. The server does not interpret it.
accentColorstringCustom accent color. Empty means the theme color.
fontFamilystringInterface font.
fontFamilyGooglebooleanLoad fontFamily from Google Fonts.
fontSizestringInterface font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
editorFontFamilystringEditor font.
editorFontFamilyGooglebooleanLoad editorFontFamily from Google Fonts.
editorFontSizestringEditor font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
previewFontFamilystringPreview font.
previewFontFamilyGooglebooleanLoad previewFontFamily from Google Fonts.
previewFontSizestringPreview font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
zenFontFamilystringZen mode font. Default: Inter.
zenFontFamilyGooglebooleanLoad zenFontFamily from Google Fonts. Default: true.
zenFontSizestringZen mode font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem. Default: 1.25rem.
zenWordCountbooleanShow the word count in Zen mode. Default: true.
zenShowTitlebooleanShow the title in Zen mode. Default: true.
zenShowControlsbooleanShow the controls in Zen mode. Default: true.
zenInteractivePreviewbooleanStored for clients. The vylk web app does not use it.
shortcutPrefixShortcutKey press that starts a shortcut. Exactly one step. The default is Mod+E.
keyboardShortcutsobjectCustom shortcuts by action name, at most 64. null turns off the default shortcut for that action. Each value is Shortcut or null.
shortcutConfirmationSkipsobjectActions that run without a confirmation, at most 64. Each value is true.
_sync_patchobjectChanged fields. prefs.save operations only.
_sync_baseobjectPrevious values of the changed fields. prefs.save operations only.

Example request

curl -X PATCH 'http://localhost:8080/api/prefs' \
	-b cookies.txt -c cookies.txt \
	-H 'If-Match: 2' \
	-H 'Content-Type: application/json' \
	-d '{
  "aiEnabled": false,
  "reduceMotion": "system",
  "revision": 2,
  "autoSave": true,
  "startView": "split",
  "hideToolbar": false,
  "hideSaveButton": true,
  "saveButtonLocation": "panel",
  "collapseDetails": false,
  "hideCursorHighlight": false,
  "interactivePreview": true,
  "contentWidth": "standard",
  "zenPageWidth": "standard",
  "fontFamilyGoogle": false,
  "fontSize": "1rem",
  "editorFontFamilyGoogle": false,
  "editorFontSize": "1rem",
  "previewFontFamilyGoogle": false,
  "previewFontSize": "1rem",
  "zenFontFamily": "Inter",
  "zenFontFamilyGoogle": true,
  "zenFontSize": "1.25rem",
  "zenWordCount": true,
  "zenShowTitle": true,
  "zenShowControls": true,
  "zenInteractivePreview": false,
  "shortcutPrefix": {
    "steps": [
      {
        "key": "e",
        "modifiers": [
          "Mod"
        ]
      }
    ]
  },
  "keyboardShortcuts": {},
  "shortcutConfirmationSkips": {},
  "theme": "dark"
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "aiEnabled": false,
  "reduceMotion": "system",
  "revision": 3,
  "autoSave": true,
  "startView": "split",
  "hideToolbar": false,
  "hideSaveButton": true,
  "saveButtonLocation": "panel",
  "collapseDetails": false,
  "hideCursorHighlight": false,
  "interactivePreview": true,
  "contentWidth": "standard",
  "zenPageWidth": "standard",
  "fontFamilyGoogle": false,
  "fontSize": "1rem",
  "editorFontFamilyGoogle": false,
  "editorFontSize": "1rem",
  "previewFontFamilyGoogle": false,
  "previewFontSize": "1rem",
  "zenFontFamily": "Inter",
  "zenFontFamilyGoogle": true,
  "zenFontSize": "1.25rem",
  "zenWordCount": true,
  "zenShowTitle": true,
  "zenShowControls": true,
  "zenInteractivePreview": false,
  "shortcutPrefix": {
    "steps": [
      {
        "key": "e",
        "modifiers": [
          "Mod"
        ]
      }
    ]
  },
  "keyboardShortcuts": {},
  "shortcutConfirmationSkips": {},
  "theme": "dark"
}

Encryption

Read the vault status and keys, change credentials, and reset an encrypted vault.

Get the vault status

GET /api/vault/bootstrap

Returns the vault mode and the public key derivation settings. This route needs no session. Before you read cached notes or a remembered key, compare instance_id with the value that you stored. In a plaintext vault, vault_id, epoch, and kdf are absent. reset_available is true when the vault is encrypted and the server has a password. It does not account for VYLK_DISABLE_VAULT_CHANGES.

Responses

StatusCodeDescription
200The vault status.
500vault_status_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Cache-Controlno-storeResponses are not cached.

Response body

KeyValueDescription
modestringlegacy: plaintext vault. preparing: encryption setup is converting notes. cleaning: the server is removing plaintext data. encrypted: encrypted vault. One of legacy, preparing, cleaning, encrypted.
reset_availablebooleanTrue when POST /api/vault/reset can run.
instance_idstringIdentity of the server database. Compare it with the value that you stored.
require_strong_passwordsbooleanTrue when the client must reject weak encryption passwords.
versionstringvylk version of the server.
revisionstringBuild of the web app.
vault_idstringVault ID. Absent in a plaintext vault.
epochintegerCurrent vault epoch. Absent in a plaintext vault.
kdfobjectArgon2id settings for the password key. Absent in a plaintext vault.
kdf.algorithmargon2id13Key derivation function.
kdf.saltstringSalt. 16 bytes in unpadded base64url.
kdf.memoryKiBintegerMemory cost in KiB. From 19456 to 262144.
kdf.iterationsintegerTime cost. From 2 to 10.

Example request

curl 'http://localhost:8080/api/vault/bootstrap'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "epoch": 1,
  "instance_id": "95e9c24f3f492f0b776fa9f58b5837f0",
  "kdf": {
    "algorithm": "argon2id13",
    "iterations": 3,
    "memoryKiB": 65536,
    "salt": "V2OdE0GPomvMRSmaTi4urQ"
  },
  "mode": "encrypted",
  "require_strong_passwords": false,
  "reset_available": true,
  "revision": "3a7403423c47610d",
  "vault_id": "_czcXBKjH4EmmKKl2q1TDQ",
  "version": "3.1.2"
}

Get the wrapped keys

GET /api/vault/keys

Returns the two encrypted copies of the vault key. Decrypt wrapped_key with the key derived from the encryption password, or wrapped_recovery_key with the key derived from the recovery key.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The wrapped keys.
401authentication_requiredThe request has no valid session cookie.
409vault_not_encryptedThe vault is not encrypted.
500vault_status_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
vault_idstring16 random bytes in unpadded base64url. 22 characters.
epochintegerCurrent vault epoch.
wrapped_keyEnvelopeVault key, encrypted with the password key.
wrapped_recovery_keyEnvelopeVault key, encrypted with the recovery key.

Example request

curl 'http://localhost:8080/api/vault/keys' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "epoch": 1,
  "vault_id": "_czcXBKjH4EmmKKl2q1TDQ",
  "wrapped_key": {
    "v": 1,
    "nonce": "ax2sfi8tjylLhNvD",
    "ciphertext": "JFBvmyEO5qHYDZqu2zydVahTTMN6qBJcOF-SEOFKsbkwxEL1l99HqeU-fy0pejEe"
  },
  "wrapped_recovery_key": {
    "v": 1,
    "nonce": "LkRY8fymwwTd72ro",
    "ciphertext": "co7KXuXDSyRdINUo2PSFYQVcOCtteJC-eUjR0U7qJrqTUhm8Smln9c_vov2ZbTiJ"
  }
}

Change a credential

POST /api/vault/credentials

Replaces the encryption password or the recovery key. Encrypt the existing vault key again with the new credential. Do not generate a new vault key. With kind set to master, the request replaces the password, and you must send new key derivation settings. With kind set to recovery, the request replaces the recovery key. current_recovery selects which current credential proves access. It is independent of kind. On success, the server revokes the current session. Unless sign_out_other_devices is false, it also revokes every other session. Sign in again with the new credential. The body limit is 32 KiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
kindstring, requiredmaster replaces the encryption password. recovery replaces the recovery key. One of master, recovery.
current_proofstring, requiredProof derived from a current credential.
current_recoverybooleanTrue when current_proof comes from the recovery key. Default: false.
new_proofstring, requiredProof derived from the new credential.
wrapped_keyEnvelope, requiredExisting vault key, encrypted with the key derived from the new credential.
kdf_saltstringNew Argon2id salt. Required when kind is master.
kdf_memory_kibintegerArgon2id memory cost in KiB. Required when kind is master. From 19456 to 262144.
kdf_iterationsintegerArgon2id time cost. Required when kind is master. From 2 to 10.
sign_out_other_devicesbooleanRevoke the sessions of every other device. Default: true.

Responses

StatusCodeDescription
200The credential is changed. The response clears the session cookie.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400invalid_vault_credentialsA proof or wrapped_key is malformed, or kind is not master or recovery.
400invalid_vault_kdfThe key derivation settings are missing or out of range. kind is master only.
401authentication_requiredThe request has no valid session cookie.
401invalid_credentialscurrent_proof is wrong.
403vault_changes_disabledThe server runs with VYLK_DISABLE_VAULT_CHANGES set to true.
409vault_unavailableThe vault is not encrypted or is not ready.
500credential_change_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Set-CookiestringExpires the session cookie.

Response body

KeyValueDescription
oktrue

Example request

curl -X POST 'http://localhost:8080/api/vault/credentials' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "kind": "master",
  "current_proof": "p2_0cRkBqKE3CtQ6YlGru2jL-Bgg3UctyEN9ulTmE9g",
  "new_proof": "VXvVEOMZ9j8w1I2m0bWU0NFWGsZbunO00xlX-y3vkIY",
  "wrapped_key": {
    "v": 1,
    "nonce": "NbbNB6-2nRQ5JPqE",
    "ciphertext": "-5rrCT_2eq8jTGEXvIFKvXkuU2VIKIBKB38Dq1-4A7GGSoDy-HnFqU4G9dXH5vtY"
  },
  "kdf_salt": "V6xB-1M1KSMQgzBjJ6J4EQ",
  "kdf_memory_kib": 65536,
  "kdf_iterations": 3,
  "sign_out_other_devices": true
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Set-Cookie: session=; Path=/; Max-Age=0; HttpOnly; SameSite=Lax

{
  "ok": true
}

Reset the vault

POST /api/vault/reset

Replaces an encrypted vault with a new, empty vault. Use this route only when the encryption password and the recovery key are both lost. It does not decrypt anything. The request needs no session. It needs the server password, VYLK_PASSWORD, in password. Generate new vault credentials on the client, as for POST /api/vault/migration/start. The server moves the old database and encrypted notes to an archive and deletes the archive after 30 days. It deletes all notes and the change feed, revokes every session, and returns a new session. instance_id stays the same. vault_id changes, and epoch increases. The body limit is 32 KiB. If the response is lost, read GET /api/vault/bootstrap before you retry.

Request headers

KeyValueDescription
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
vault_idstring, requiredNew random vault ID.
kdf_saltstring, requiredNew random Argon2id salt. 16 bytes in unpadded base64url.
kdf_memory_kibinteger, requiredArgon2id memory cost in KiB. From 19456 to 262144.
kdf_iterationsinteger, requiredArgon2id time cost. From 2 to 10.
auth_proofstring, requiredProof derived from the encryption password.
recovery_proofstring, requiredProof derived from the recovery key.
wrapped_keyEnvelope, requiredVault key, encrypted with the password key.
wrapped_recovery_keyEnvelope, requiredVault key, encrypted with the recovery key.
passwordstring, requiredThe server password, VYLK_PASSWORD. Not the encryption password.

Responses

StatusCodeDescription
200The new vault is active. The response sets new session and vylk-device cookies.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400invalid_vault_resetA vault ID, salt, proof, envelope, or key derivation setting is invalid.
401invalid_credentialspassword is not VYLK_PASSWORD.
403vault_changes_disabledThe server runs with VYLK_DISABLE_VAULT_CHANGES set to true.
403vault_reset_unavailableThe server has no VYLK_PASSWORD.
409vault_reset_unavailableThe vault is not encrypted, or encryption setup is not finished.
429login_rate_limitedToo many failed attempts from this client address. Wait for the number of seconds in retry_after.
500vault_reset_failedThe server could not complete the request.
503note_file_recovery_blockedAn interrupted file operation needs recovery first.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringTwo cookies: session and vylk-device. Store both.
Retry-AfterstringSent with status 429. Seconds to wait before the next attempt.

Response body

KeyValueDescription
oktrue
vault_idstring16 random bytes in unpadded base64url. 22 characters.
epochintegerEpoch of the new vault.
archive_expires_atstring (date-time)Time when the server deletes the archive.

Example request

curl -X POST 'http://localhost:8080/api/vault/reset' \
	-H 'Content-Type: application/json' \
	-d '{
  "password": "your-server-password",
  "vault_id": "ZDjs0jd0FK2cJRMlqSpVKw",
  "kdf_salt": "kDc-l8DIgsH8T6R2uAtb3w",
  "kdf_memory_kib": 65536,
  "kdf_iterations": 3,
  "auth_proof": "KCEzRWwevRRVjHmKfFnHw0GvKOQWsLKY-2WDCV2twaw",
  "recovery_proof": "Ov1bHpA5nWSGG9S1pg8So2sZmkNHGVwcB1OGgTuckDw",
  "wrapped_key": {
    "v": 1,
    "nonce": "oLWV8NohFSiPWRKY",
    "ciphertext": "U5zN9F7iZcRfSBJxn9vPH1lDvR0VGTiy58cZ1X7MnMxEcn05llAjA57CWHNAB-PT"
  },
  "wrapped_recovery_key": {
    "v": 1,
    "nonce": "n1PUQNhS8_geJn5l",
    "ciphertext": "ZUvRpupL9JqEyK4qeZEptky5UfjmQoccKSa7EfDbZ0PfdTJcyzVxlxJOs4IAjSc_"
  }
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Set-Cookie: vylk-device=fdd91647e9dd809fdaf557291a2acd92; Path=/; Max-Age=31536000; HttpOnly; SameSite=Lax
Set-Cookie: session=81abd2fc412f40d7039912b972a6bb15; Path=/; Max-Age=15552000; HttpOnly; SameSite=Lax

{
  "archive_expires_at": "2026-12-22T02:41:08Z",
  "epoch": 2,
  "ok": true,
  "vault_id": "ZDjs0jd0FK2cJRMlqSpVKw"
}

Migration

Convert a plaintext vault to an encrypted vault. The routes run in the order listed.

Verify the password

POST /api/vault/setup/verify-password

Checks that password is the server password before encryption setup. Failed attempts count toward the sign-in rate limit. This route changes nothing on the server. It works before setup and while a started setup waits to resume.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
passwordstring, requiredThe server password, VYLK_PASSWORD.

Responses

StatusCodeDescription
200The password is correct.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
401authentication_requiredThe request has no valid session cookie.
403invalid_credentialsThe password is wrong.
403vault_changes_disabledThe server runs with VYLK_DISABLE_VAULT_CHANGES set to true.
409vault_setup_unavailableThe vault is already encrypted.
429login_rate_limitedToo many failed attempts from this client address.
500login_rate_limit_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.
Retry-AfterstringSent with status 429. Seconds to wait before the next attempt.

Response body

KeyValueDescription
oktrue

Example request

curl -X POST 'http://localhost:8080/api/vault/setup/verify-password' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "password": "your-server-password"
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "ok": true
}

Start encryption

POST /api/vault/migration/start

Starts converting a plaintext vault to an encrypted vault. Generate the vault ID, the salt, the vault key, the recovery key, both proofs, and both wrapped keys on the client. The server checks old_password, saves a backup of the notes, and pauses note writes. A repeated request with the same vault_id resumes the setup and keeps the credentials stored by the first request. Keep the setup secrets until POST /api/vault/migration/commit succeeds. No route cancels a started setup. The body limit is 32 KiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
vault_idstring, requiredNew random vault ID.
kdf_saltstring, requiredNew random Argon2id salt. 16 bytes in unpadded base64url.
kdf_memory_kibinteger, requiredArgon2id memory cost in KiB. From 19456 to 262144.
kdf_iterationsinteger, requiredArgon2id time cost. From 2 to 10.
auth_proofstring, requiredProof derived from the encryption password.
recovery_proofstring, requiredProof derived from the recovery key.
wrapped_keyEnvelope, requiredVault key, encrypted with the password key.
wrapped_recovery_keyEnvelope, requiredVault key, encrypted with the recovery key.
old_passwordstring, requiredThe server password, VYLK_PASSWORD.

Responses

StatusCodeDescription
200The setup is started. Upload the encrypted notes next.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400invalid_vault_setupold_password is wrong, or a vault ID, salt, proof, envelope, or key derivation setting is invalid.
401authentication_requiredThe request has no valid session cookie.
403vault_changes_disabledThe server runs with VYLK_DISABLE_VAULT_CHANGES set to true.
409vault_setup_already_startedThe vault is encrypted, or a setup with another vault_id is in progress.
409unexpected_note_filesThe notes folder holds files that the database does not list. error names the problem.
500vault_setup_failedThe server could not complete the request.
503note_recovery_pendingAn interrupted file operation needs recovery first.
503note_recovery_failedFile recovery failed. The server operator must fix it.
507migration_backup_failedThe server could not write the backup. Free disk space and retry with the same body.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
oktrue
epoch1Epoch of the new vault.

Example request

curl -X POST 'http://localhost:8080/api/vault/migration/start' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "vault_id": "_czcXBKjH4EmmKKl2q1TDQ",
  "kdf_salt": "V2OdE0GPomvMRSmaTi4urQ",
  "kdf_memory_kib": 65536,
  "kdf_iterations": 3,
  "auth_proof": "p2_0cRkBqKE3CtQ6YlGru2jL-Bgg3UctyEN9ulTmE9g",
  "recovery_proof": "l6nRkO9YgnXzpnilSnYfjT7ldRbz2ye-cc7Gulrv3Zc",
  "wrapped_key": {
    "v": 1,
    "nonce": "ax2sfi8tjylLhNvD",
    "ciphertext": "JFBvmyEO5qHYDZqu2zydVahTTMN6qBJcOF-SEOFKsbkwxEL1l99HqeU-fy0pejEe"
  },
  "wrapped_recovery_key": {
    "v": 1,
    "nonce": "LkRY8fymwwTd72ro",
    "ciphertext": "co7KXuXDSyRdINUo2PSFYQVcOCtteJC-eUjR0U7qJrqTUhm8Smln9c_vov2ZbTiJ"
  },
  "old_password": "your-server-password"
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "epoch": 1,
  "ok": true
}

Get the encryption progress

GET /api/vault/migration/status

Returns the vault mode and the number of notes that are uploaded and verified. Encryption can finish when verified_notes equals source_notes.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The progress.
401authentication_requiredThe request has no valid session cookie.
409vault_migration_not_startedEncryption setup has not started.
500vault_status_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
modestringlegacy: plaintext vault. preparing: encryption setup is converting notes. cleaning: the server is removing plaintext data. encrypted: encrypted vault. One of legacy, preparing, cleaning, encrypted.
backup_readybooleanTrue when the server has saved the backup.
source_notesintegerPlaintext notes to convert.
staged_notesintegerNotes with an uploaded encrypted copy.
verified_notesintegerUploaded copies that the client has verified.

Example request

curl 'http://localhost:8080/api/vault/migration/status' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "backup_ready": true,
  "mode": "preparing",
  "source_notes": 2,
  "staged_notes": 0,
  "verified_notes": 0
}

List notes to convert

GET /api/vault/migration/next

Lists up to 100 notes that have no verified encrypted copy, in ascending ID order. To read the next page, pass the last ID as after. An empty array means that every note is verified. When a note changes, its earlier verification no longer counts.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Query parameters

KeyValueDescription
afterstringThe last ID of the previous page. The response starts after it.

Responses

StatusCodeDescription
200The notes to convert.
401authentication_requiredThe request has no valid session cookie.
409vault_migration_not_readySetup has not started or the backup is not saved.
500vault_migration_list_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

An array of objects.

KeyValueDescription
[].idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
[].revisionintegerCurrent revision of the plaintext note.

Example request

curl 'http://localhost:8080/api/vault/migration/next' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[
  {
    "id": "reading-list",
    "revision": 2
  },
  {
    "id": "trip-notes",
    "revision": 2
  }
]

Upload an encrypted copy

POST /api/vault/migration/stage

Uploads the encrypted copy of one note. revision must match the plaintext note. A new upload for the same note replaces the copy and clears its verification. After the upload, read the copy back with GET /api/vault/migration/staged/{id} and verify it. The body limit is 8 MiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
idstring, requiredNote ID. 1 to 64 letters, digits, hyphens, or underscores.
revisioninteger, requiredRevision of the plaintext note. At least 1.
summaryEnvelope, requiredEncrypted title and tags.
bodyEnvelope, requiredEncrypted note text.

Responses

StatusCodeDescription
200The copy is stored.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400invalid_encrypted_noteid, revision, or an envelope is invalid.
401authentication_requiredThe request has no valid session cookie.
403vault_changes_disabledThe server runs with VYLK_DISABLE_VAULT_CHANGES set to true.
409vault_migration_not_readySetup has not started or the backup is not saved.
409vault_note_changedThe note does not exist or has another revision.
500vault_stage_failedThe server could not complete the request.
507vault_stage_failedThe server could not write the file.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
oktrue

Example request

curl -X POST 'http://localhost:8080/api/vault/migration/stage' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "id": "reading-list",
  "revision": 2,
  "summary": {
    "v": 1,
    "nonce": "WEX-YDY8-R2R8E51",
    "ciphertext": "5IGkqpAUUPCkD_LS96p4Bk10I1sloJgvBoDNiv5YOJp0BY_2_F0YFUtHJSjTy_q8soQoHV9_C4O2Oc9BxYnC6A"
  },
  "body": {
    "v": 1,
    "nonce": "p5ErQVu1FwrjfG5y",
    "ciphertext": "j2AABCqv8cUGf_xvNOCFt_RSv8hlXuGc37TQtrNP1pm3sv9OjF07Fmx_crOun2_xWQN1fixs4tXckyzXa4snZcM8DU3LL72zJVCrqkq661H1XZcxmkAbcRZWH5twN8hG"
  }
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "ok": true
}

Get an encrypted copy

GET /api/vault/migration/staged/{id}

Returns the uploaded encrypted copy of a note as the server stored it. Decrypt it and compare it with the plaintext note before you verify it.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Path parameters

KeyValueDescription
idstring, requiredNote identifier. Pattern: ^[A-Za-z0-9_-]{1,64}$.

Responses

StatusCodeDescription
200The encrypted copy.
401authentication_requiredThe request has no valid session cookie.
404staged_note_not_foundNo copy is uploaded for this ID.
500staged_note_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
revisionintegerRevision of the plaintext note.
summaryEnvelopeEncrypted title and tags.
bodyEnvelopeEncrypted note text.
epochintegerVault epoch.
body_hashstringSHA-256 of the stored body bytes, in lowercase hexadecimal. Not a hash of the Markdown.

Example request

curl 'http://localhost:8080/api/vault/migration/staged/trip-notes' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "body": {
    "v": 1,
    "nonce": "p5ErQVu1FwrjfG5y",
    "ciphertext": "j2AABCqv8cUGf_xvNOCFt_RSv8hlXuGc37TQtrNP1pm3sv9OjF07Fmx_crOun2_xWQN1fixs4tXckyzXa4snZcM8DU3LL72zJVCrqkq661H1XZcxmkAbcRZWH5twN8hG"
  },
  "body_hash": "21f8ba681e86f93e0af89edb6ea0ba755b6799460d35fe0d3b13a4dd4bba646c",
  "epoch": 1,
  "id": "reading-list",
  "revision": 2,
  "summary": {
    "v": 1,
    "nonce": "WEX-YDY8-R2R8E51",
    "ciphertext": "5IGkqpAUUPCkD_LS96p4Bk10I1sloJgvBoDNiv5YOJp0BY_2_F0YFUtHJSjTy_q8soQoHV9_C4O2Oc9BxYnC6A"
  }
}

Confirm an encrypted copy

POST /api/vault/migration/verify

Records that the client decrypted the uploaded copy and that it matches the plaintext note. Send the body_hash from GET /api/vault/migration/staged/{id}. The server checks only the hash and the revision. It cannot check the decryption. The body limit is 4 KiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
idstring, requiredNote ID. 1 to 64 letters, digits, hyphens, or underscores.
body_hashstring, requiredbody_hash from the uploaded copy. 64 lowercase hexadecimal characters.

Responses

StatusCodeDescription
200The copy is verified.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400invalid_verificationid is invalid or body_hash is not 64 characters.
401authentication_requiredThe request has no valid session cookie.
403vault_changes_disabledThe server runs with VYLK_DISABLE_VAULT_CHANGES set to true.
409vault_migration_not_readySetup has not started.
409vault_verify_mismatchThe hash does not match the stored copy, or the note changed.
500vault_verify_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
oktrue

Example request

curl -X POST 'http://localhost:8080/api/vault/migration/verify' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "id": "reading-list",
  "body_hash": "21f8ba681e86f93e0af89edb6ea0ba755b6799460d35fe0d3b13a4dd4bba646c"
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "ok": true
}

Finish encryption

POST /api/vault/migration/commit

Switches the vault to encrypted storage. Every note must have a verified copy. The request has no body. The server deletes the plaintext notes, the plaintext indexes, and the stored sync operations, and it revokes every session. Sign in again with the derived proof. Sync queue sequence numbers continue. Do not restart them at 1. If the response is 500 with vault_cleanup_pending, the switch succeeded. The server finishes the cleanup at its next start. Do not start a new setup.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The vault is encrypted.
401authentication_requiredThe request has no valid session cookie.
403vault_changes_disabledThe server runs with VYLK_DISABLE_VAULT_CHANGES set to true.
409vault_migration_not_readySetup has not started or the backup is not saved.
409vault_migration_incompleteSome notes have no verified copy.
409unexpected_note_filesThe notes folder holds files that the database does not list.
409vault_verify_failedAn encrypted file is missing or changed.
500vault_commit_failedThe switch failed. The vault is still in setup.
500vault_cleanup_pendingThe switch succeeded. Cleanup resumes when the server restarts.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.

Response body

KeyValueDescription
oktrue
modeencrypted

Example request

curl -X POST 'http://localhost:8080/api/vault/migration/commit' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
  "mode": "encrypted",
  "ok": true
}

AI

Configure AI providers and edit notes with AI. Every route needs the aiEnabled preference. The client protocol describes the request flow and its limits.

Get AI capabilities

GET /api/ai/capabilities

Returns whether the client can turn model thinking on and off, and a display name for the provider. Both values describe the default configuration, and only when it is checked. Without a checked default, thinking_controllable is false and provider_name is a generic phrase. The server can read model metadata from the provider, but it does not generate a response.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The capabilities.
400ai_request_failedAI was turned off during the request, or the server could not read the configurations.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Response body

KeyValueDescription
thinking_controllablebooleanTrue when requests can set thinking.
provider_namestringName and model of the default configuration, for display.

Example request

curl 'http://localhost:8080/api/ai/capabilities' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "provider_name": "OpenRouter (openai/gpt-4.1-mini)",
  "thinking_controllable": false
}

List AI configurations

GET /api/ai/configurations

Returns every AI configuration, in order of creation. Responses never contain API keys. has_key tells whether a key is saved.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Responses

StatusCodeDescription
200The configurations.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.
500ai_storage_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Response body

An array of AI configuration.

Example request

curl 'http://localhost:8080/api/ai/configurations' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

[
  {
    "output_profile": "",
    "id": "93e426f2feca1406629434a9891ce6d7",
    "name": "OpenRouter",
    "url": "https://openrouter.ai/api/v1",
    "model": "openai/gpt-4.1-mini",
    "has_key": true,
    "checked": true,
    "is_default": true,
    "revision": 1,
    "context_tokens": 0,
    "concurrency": 0
  },
  {
    "output_profile": "",
    "id": "5ac56143516b29c821e302682e246296",
    "name": "Ollama on desktop",
    "url": "http://192.168.1.20:11434/v1",
    "model": "qwen3:8b",
    "has_key": false,
    "checked": true,
    "is_default": false,
    "revision": 2,
    "context_tokens": 32768,
    "concurrency": 2
  }
]

Create an AI configuration

POST /api/ai/configurations

Saves a new configuration. With a test_token, the configuration is saved as checked. Without one, it is saved unchecked, and sessions cannot use it until POST /api/ai/configurations/{id}/check succeeds. The first successful check on a server makes that configuration the default when no default exists. A server holds at most 32 configurations. The body limit is 24 KiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
namestring, requiredDisplay name. 1 to 120 characters, with no control characters.
urlstring, requiredAPI base URL, such as https://openrouter.ai/api/v1. Not the completions URL. HTTP or HTTPS, with no user name, password, query, or fragment. At most 2048 bytes.
keystringAPI key. At most 16 KiB. Omit it to keep the saved key. Send an empty string to remove the key.
modelstring, requiredModel ID. The server sends it to the provider unchanged. At most 256 bytes.
output_profilestringEmpty: the server detects whether the provider supports JSON Schema output. json_schema: always request JSON Schema output. One of "", json_schema.
context_tokensintegerContext window in tokens. 0, or 2048 to 16777216. 0 uses the window that the provider reports, or 32768.
concurrencyintegerParallel requests for one AI job. 0 uses VYLK_AI_CONCURRENCY. The server never exceeds VYLK_AI_CONCURRENCY. From 0 to 8.
test_tokenstringtest_token from POST /api/ai/configurations/test. With a valid token, the configuration is saved as checked.

Responses

StatusCodeDescription
200The saved configuration.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400ai_request_failedA field is invalid, the server already holds 32 configurations, or test_token is expired, already used, or for different settings. error names the problem.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Response body

KeyValueDescription
idstringConfiguration ID.
namestringDisplay name.
urlstringAPI base URL.
modelstringModel ID.
has_keybooleanTrue when an API key is saved. The API never returns the key.
checkedbooleanTrue when a test or check succeeded with the current url, model, output_profile, and key. Sessions use only checked configurations.
is_defaultbooleanTrue for the configuration that new sessions use. At most one configuration is the default.
revisionintegerRevision. Each update increases it by 1.
output_profilestringEmpty: detect JSON Schema support. json_schema: always request JSON Schema output. One of "", json_schema.
context_tokensintegerContext window in tokens. 0 uses the provider value or 32768.
concurrencyintegerParallel requests for one job. 0 uses VYLK_AI_CONCURRENCY.

Example request

curl -X POST 'http://localhost:8080/api/ai/configurations' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "name": "OpenRouter",
  "url": "https://openrouter.ai/api/v1",
  "key": "sk-or-v1-example",
  "model": "openai/gpt-4.1-mini",
  "context_tokens": 0,
  "concurrency": 0,
  "test_token": "a2c4bb6b931a8b86bcdc1aed395736bf.1795349269.9e66c902fe9c4dbe7f91364d579838b2b8338d789d2285cd97070ae633f34c51"
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "output_profile": "",
  "id": "93e426f2feca1406629434a9891ce6d7",
  "name": "OpenRouter",
  "url": "https://openrouter.ai/api/v1",
  "model": "openai/gpt-4.1-mini",
  "has_key": true,
  "checked": true,
  "is_default": true,
  "revision": 1,
  "context_tokens": 0,
  "concurrency": 0
}

Test an AI configuration

POST /api/ai/configurations/test

Sends one short request to the provider and reports whether it returned a valid reply. Nothing is saved, but the server records the usage. The request has a limit of 2048 output tokens. If the model supports thinking control, the test turns thinking off. To test a saved configuration with its saved key, send its id and revision and omit key. A successful test returns a test_token. Send it to POST /api/ai/configurations or PUT /api/ai/configurations/{id} to save the configuration as checked. The token is valid for 10 minutes and for one save. The server forgets it on restart and when AI is turned off. It is bound to this session and to url, key, model, output_profile, id, and revision. A change to name, context_tokens, or concurrency does not invalidate it. The provider can take up to 10 minutes to reply. The body limit is 24 KiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
namestringDisplay name. 1 to 120 characters, with no control characters.
urlstring, requiredAPI base URL, such as https://openrouter.ai/api/v1. Not the completions URL. HTTP or HTTPS, with no user name, password, query, or fragment. At most 2048 bytes.
keystringAPI key. At most 16 KiB. Omit it to keep the saved key. Send an empty string to remove the key.
modelstring, requiredModel ID. The server sends it to the provider unchanged. At most 256 bytes.
output_profilestringEmpty: the server detects whether the provider supports JSON Schema output. json_schema: always request JSON Schema output. One of "", json_schema.
context_tokensintegerContext window in tokens. 0, or 2048 to 16777216. 0 uses the window that the provider reports, or 32768.
concurrencyintegerParallel requests for one AI job. 0 uses VYLK_AI_CONCURRENCY. The server never exceeds VYLK_AI_CONCURRENCY. From 0 to 8.
idstringID of a saved configuration. Required to test with its saved key.
revisionintegerCurrent revision of the saved configuration. Required with id.

Responses

StatusCodeDescription
200The provider returned a valid reply.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400ai_request_failedA field is invalid, the saved configuration changed, the provider failed or timed out, or the reply was not valid. error names the problem.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.
500ai_deadline_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Response body

KeyValueDescription
oktrue
thinking_controllablebooleanTrue when requests can set thinking.
test_tokenstringProof of this test. Send it when you save the configuration.
reported_context_tokensintegerContext window that the provider reports. 0 when the provider reports none.
default_context_tokensintegerContext window that the server uses when neither context_tokens nor the provider sets one.

Example request

curl -X POST 'http://localhost:8080/api/ai/configurations/test' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "name": "OpenRouter",
  "url": "https://openrouter.ai/api/v1",
  "key": "sk-or-v1-example",
  "model": "openai/gpt-4.1-mini",
  "context_tokens": 0,
  "concurrency": 0
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "default_context_tokens": 32768,
  "ok": true,
  "reported_context_tokens": 0,
  "test_token": "a2c4bb6b931a8b86bcdc1aed395736bf.1795349269.9e66c902fe9c4dbe7f91364d579838b2b8338d789d2285cd97070ae633f34c51",
  "thinking_controllable": false
}

Update an AI configuration

PUT /api/ai/configurations/{id}

Replaces a configuration. Send every field. A field that you omit takes its zero value, except key, which keeps the saved key. revision must equal the current revision. The saved configuration has a new revision. The configuration stays checked only when url, model, output_profile, and key do not change, or when the request has a valid test_token. The update closes every AI session that uses this configuration. The body limit is 24 KiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Path parameters

KeyValueDescription
idstring, requiredConfiguration ID.

Request body

KeyValueDescription
namestring, requiredDisplay name. 1 to 120 characters, with no control characters.
urlstring, requiredAPI base URL, such as https://openrouter.ai/api/v1. Not the completions URL. HTTP or HTTPS, with no user name, password, query, or fragment. At most 2048 bytes.
keystringAPI key. At most 16 KiB. Omit it to keep the saved key. Send an empty string to remove the key.
modelstring, requiredModel ID. The server sends it to the provider unchanged. At most 256 bytes.
output_profilestringEmpty: the server detects whether the provider supports JSON Schema output. json_schema: always request JSON Schema output. One of "", json_schema.
context_tokensintegerContext window in tokens. 0, or 2048 to 16777216. 0 uses the window that the provider reports, or 32768.
concurrencyintegerParallel requests for one AI job. 0 uses VYLK_AI_CONCURRENCY. The server never exceeds VYLK_AI_CONCURRENCY. From 0 to 8.
revisioninteger, requiredCurrent revision.
test_tokenstringtest_token from POST /api/ai/configurations/test. With a valid token, the configuration is saved as checked.

Responses

StatusCodeDescription
200The saved configuration.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400ai_request_failedThe ID is invalid or unknown, a field is invalid, revision is not current, or test_token is not valid for these settings. error names the problem.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Response body

KeyValueDescription
idstringConfiguration ID.
namestringDisplay name.
urlstringAPI base URL.
modelstringModel ID.
has_keybooleanTrue when an API key is saved. The API never returns the key.
checkedbooleanTrue when a test or check succeeded with the current url, model, output_profile, and key. Sessions use only checked configurations.
is_defaultbooleanTrue for the configuration that new sessions use. At most one configuration is the default.
revisionintegerRevision. Each update increases it by 1.
output_profilestringEmpty: detect JSON Schema support. json_schema: always request JSON Schema output. One of "", json_schema.
context_tokensintegerContext window in tokens. 0 uses the provider value or 32768.
concurrencyintegerParallel requests for one job. 0 uses VYLK_AI_CONCURRENCY.

Example request

curl -X PUT 'http://localhost:8080/api/ai/configurations/5ac56143516b29c821e302682e246296' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "name": "Ollama on desktop",
  "url": "http://192.168.1.20:11434/v1",
  "model": "qwen3:8b",
  "revision": 1,
  "context_tokens": 32768,
  "concurrency": 2
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "output_profile": "",
  "id": "5ac56143516b29c821e302682e246296",
  "name": "Ollama on desktop",
  "url": "http://192.168.1.20:11434/v1",
  "model": "qwen3:8b",
  "has_key": false,
  "checked": true,
  "is_default": true,
  "revision": 2,
  "context_tokens": 32768,
  "concurrency": 2
}

Delete an AI configuration

DELETE /api/ai/configurations/{id}

Deletes a configuration and closes every AI session that uses it. When you delete the default configuration, the server does not choose another default. Usage records stay.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Path parameters

KeyValueDescription
idstring, requiredConfiguration ID.

Responses

StatusCodeDescription
204Deleted. The response has no body.
400ai_request_failedThe ID is invalid, or the server could not delete the configuration.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Example request

curl -X DELETE 'http://localhost:8080/api/ai/configurations/5ac56143516b29c821e302682e246296' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 204 No Content
Cache-Control: no-store

Check or select an AI configuration

POST /api/ai/configurations/{id}/{action}

check sends one short request to the provider, the same as POST /api/ai/configurations/test, and marks the saved configuration as checked when the reply is valid. A failed check marks it unchecked and closes the sessions that use it. The server records the usage. The provider can take up to 10 minutes to reply. default makes a checked configuration the default. New sessions use the default configuration. Neither action has a request body.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Path parameters

KeyValueDescription
idstring, requiredConfiguration ID.
actionstring, requiredAction to run. One of check, default.

Responses

StatusCodeDescription
200check only. The check succeeded.
204default only. The configuration is the default. The response has no body.
400ai_request_failedThe ID is invalid or unknown, the configuration is not checked (default), or the provider failed or timed out (check). error names the problem.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
404Not found. The action is not one of the listed values. The body is plain text.
500ai_unavailableThe server could not complete the request.
500ai_deadline_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.
Cache-Controlno-storeSent with status 204. Responses are not cached.

Response body

KeyValueDescription
oktrue

Example request

curl -X POST 'http://localhost:8080/api/ai/configurations/5ac56143516b29c821e302682e246296/check' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "ok": true
}

Start an AI session

POST /api/ai/sessions

Starts a session with the default configuration. The configuration must be checked. A session holds a draft of the shared text, the conversation, and the suggested changes. The server sends only text to the provider, never the title, the tags, or the rest of the note. In an encrypted vault, the client sends decrypted text, and the server forwards it to the provider. A session belongs to the session cookie that created it. It ends after 30 minutes without requests, when you sign out, when AI is turned off, and when the server restarts. The server holds at most four sessions at a time. The body limit is about 6 MiB.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Request body

KeyValueDescription
note_idstring, requiredNote that the session edits. Pattern: ^[A-Za-z0-9_-]{1,64}$.
scopestring, requiredWhat text contains. none: nothing; the provider receives only the prompts. selection: selected Markdown, or an empty string for an insertion point. note: the whole note text. One of none, selection, note.
textstring, requiredShared Markdown. At most 1 MiB. Must be empty when scope is none.

Responses

StatusCodeDescription
200The new session.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400ai_request_failednote_id or scope is invalid, text is larger than 1 MiB, there is no checked default configuration, or four sessions are open. error names the problem.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Response body

KeyValueDescription
idstringSession ID.
note_idstringNote that the session edits. Pattern: ^[A-Za-z0-9_-]{1,64}$.
configuration_idstringConfiguration that the session uses.
scopestringWhat the shared text contains. One of none, selection, note.
draftstringShared text with the accepted changes.
hunksarray of AI hunkSuggested changes from the last request that suggested any.
answerstringReply from the model to the last request.
versionintegerVersion. Each change to the session increases it. Send it with each action.
can_undobooleanTrue when undo can revert an acceptance.
changedbooleanTrue when draft differs from the shared text.
thinking_controllablebooleanTrue when requests can set thinking. Fixed for the session.
jobAI jobLatest job. Absent before the first job.

Example request

curl -X POST 'http://localhost:8080/api/ai/sessions' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "note_id": "trip-notes",
  "scope": "note",
  "text": "# Trip notes\n\nPack teh charger.\n\nBook the train.\n"
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "configuration_id": "93e426f2feca1406629434a9891ce6d7",
  "thinking_controllable": false,
  "id": "0acde88882e62aaf5229b714b9054f8d",
  "note_id": "trip-notes",
  "scope": "note",
  "draft": "# Trip notes\n\nPack teh charger.\n\nBook the train.\n",
  "hunks": [],
  "answer": "",
  "version": 0,
  "can_undo": false,
  "changed": false
}

Get an AI session

GET /api/ai/sessions/{id}

Returns the session. With job, returns the status of the current job instead. With job and wait=1, the server waits up to 25 seconds for the job to finish, and returns as soon as it does. Repeat the request while status is running. At most two requests can wait on one job.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Path parameters

KeyValueDescription
idstring, requiredSession ID from POST /api/ai/sessions.

Query parameters

KeyValueDescription
jobstringAny value returns the job status instead of the session.
waitstring1 waits for the job to finish. Requires job. One of 1.

Responses

StatusCodeDescription
200The session, or the job status when the request has job.
400ai_request_failedThe session ID is invalid, or the session ended. With job, the session has no job.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Response body

AI session. A temporary AI session. The server keeps it in memory only.

KeyValueDescription
idstringSession ID.
note_idstringNote that the session edits. Pattern: ^[A-Za-z0-9_-]{1,64}$.
configuration_idstringConfiguration that the session uses.
scopestringWhat the shared text contains. One of none, selection, note.
draftstringShared text with the accepted changes.
hunksarray of AI hunkSuggested changes from the last request that suggested any.
answerstringReply from the model to the last request.
versionintegerVersion. Each change to the session increases it. Send it with each action.
can_undobooleanTrue when undo can revert an acceptance.
changedbooleanTrue when draft differs from the shared text.
thinking_controllablebooleanTrue when requests can set thinking. Fixed for the session.
jobAI jobLatest job. Absent before the first job.

AI job. Status of a background job.

KeyValueDescription
idstringJob ID.
snapshot_idstringID of the plan that the job runs.
versionintegerSession version when the job finished, or when it started while it runs.
statusstringJob state. Get the session when it is completed. One of running, completed, failed, cancelled.
completedintegerProvider requests that finished.
totalintegerProvider requests planned so far. It can grow while the job runs.
errorstringReason for a failed job.

Example request

curl 'http://localhost:8080/api/ai/sessions/0acde88882e62aaf5229b714b9054f8d' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "configuration_id": "93e426f2feca1406629434a9891ce6d7",
  "job": {
    "id": "337342d5d47c347e02000d0d88483fc8",
    "snapshot_id": "2cb14c0b6097a1389cd319e5ef17fe5c",
    "version": 1,
    "status": "completed",
    "completed": 1,
    "total": 1
  },
  "thinking_controllable": false,
  "id": "0acde88882e62aaf5229b714b9054f8d",
  "note_id": "trip-notes",
  "scope": "note",
  "draft": "# Trip notes\n\nPack teh charger.\n\nBook the train.\n",
  "hunks": [
    {
      "id": "ba968b79a37b2d3a741cdc7ba71a3314",
      "ref": "@1",
      "start": 14,
      "end": 31,
      "before": "Pack teh charger.",
      "after": "Pack the charger.",
      "decision": ""
    }
  ],
  "answer": "Suggested changes are ready to review.",
  "version": 1,
  "can_undo": false,
  "changed": false
}

Close an AI session

DELETE /api/ai/sessions/{id}

Cancels the running job and deletes the session. The server returns 204 when the session is already closed.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.

Path parameters

KeyValueDescription
idstring, requiredSession ID from POST /api/ai/sessions.

Responses

StatusCodeDescription
204Closed. The response has no body.
400ai_request_failedThe session ID is invalid.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
500ai_unavailableThe server could not complete the request.

Response headers

KeyValueDescription
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.

Example request

curl -X DELETE 'http://localhost:8080/api/ai/sessions/0acde88882e62aaf5229b714b9054f8d' \
	-b cookies.txt -c cookies.txt

Example response

HTTP/1.1 204 No Content
Cache-Control: no-store

Run an AI session action

POST /api/ai/sessions/{id}/{action}

Runs one step of a session. Every action except cancel needs the current version, and each change to the session increases version. plan prepares a request and returns a plan. It does not generate a response. start runs a plan as a background job and returns 202. Starting the same plan again returns the same job. Poll GET /api/ai/sessions/{id}?job=1&wait=1 until the job finishes, then get the session. cancel stops the job and the pending plans, and keeps the session. review accepts or rejects suggested changes in the draft. It does not save the note. accept_all accepts every pending hunk. undo reverts the last acceptance and discards the pending hunks. finalize returns the draft when every hunk has a decision and the draft differs from the original. context replaces the shared text and scope. Resolve every pending hunk first. rebase replaces the shared text after another device edits the note. Hunks that the edit touches become outdated. configuration switches the session to another checked configuration. It does not change the default. turn runs a request synchronously and returns the session. It can take up to 10 minutes. Use plan and start instead. A session allows 20 requests. The body limit is 100 KiB, or about 6 MiB for context and rebase.

Request headers

KeyValueDescription
Cookiestring, requiredThe session cookie from POST /api/login.
Content-Typeapplication/json, requiredMedia type of the body.

Path parameters

KeyValueDescription
idstring, requiredSession ID from POST /api/ai/sessions.
actionstring, requiredAction to run. One of plan, start, cancel, review, context, rebase, configuration, turn.

Request body

KeyValueDescription
versionintegerCurrent version of the session. Used by every action except cancel.
promptstringRequest to the model. At most 16 KiB. Used by plan and turn.
thinkingbooleanTurn model thinking on. True fails when thinking_controllable is false. Used by plan and turn. Default: false.
whole_contextbooleanSend the whole shared text in one request when it fits. Used by plan and turn. Default: false.
plan_idstringid from the plan response. Used by start.
actionstringReview step. Used by review. One of accept, reject, accept_all, undo, finalize.
hunk_idstringid of the hunk. Used by review with accept or reject.
scopestringNew sharing scope. Used by context. One of none, selection, note.
textstringNew shared text. At most 1 MiB. Used by context and rebase.
configuration_idstringChecked configuration to use. Used by configuration.

Responses

StatusCodeDescription
200plan: the plan. Other actions: the session.
202start only. The job is running.
204cancel only. The response has no body.
400invalid_requestThe body is not one JSON object, has an unknown field, or exceeds the size limit.
400ai_request_failedThe session ended, version is not current, a request is already running, a field is invalid, or the provider failed. error names the problem.
401authentication_requiredThe request has no valid session cookie.
403ai_disabledThe aiEnabled preference is false.
404Not found. The action is not one of the listed values. The body is plain text.
500ai_unavailableThe server could not complete the request.
500ai_deadline_failedThe server could not complete the request.

Response headers

KeyValueDescription
Content-Typeapplication/jsonMedia type of the body.
Set-CookiestringThe server renews the session cookie while you use it. Store the new value.
Cache-Controlno-storeResponses are not cached.
Cache-Controlno-storeSent with status 202. Responses are not cached.
Cache-Controlno-storeSent with status 204. Responses are not cached.

Response body

AI plan. A prepared request. A plan does not call the model.

KeyValueDescription
idstringPlan ID. Send it as plan_id to start.
versionintegerSession version that the plan is for.
sectionsintegerParts of the shared text that the job handles separately.
estimated_input_tokensintegerEstimate of the input tokens. Not a tokenizer count.
whole_contextbooleanTrue when the request asked for the whole shared text at once.

AI session. A temporary AI session. The server keeps it in memory only.

KeyValueDescription
idstringSession ID.
note_idstringNote that the session edits. Pattern: ^[A-Za-z0-9_-]{1,64}$.
configuration_idstringConfiguration that the session uses.
scopestringWhat the shared text contains. One of none, selection, note.
draftstringShared text with the accepted changes.
hunksarray of AI hunkSuggested changes from the last request that suggested any.
answerstringReply from the model to the last request.
versionintegerVersion. Each change to the session increases it. Send it with each action.
can_undobooleanTrue when undo can revert an acceptance.
changedbooleanTrue when draft differs from the shared text.
thinking_controllablebooleanTrue when requests can set thinking. Fixed for the session.
jobAI jobLatest job. Absent before the first job.

Example request

curl -X POST 'http://localhost:8080/api/ai/sessions/0acde88882e62aaf5229b714b9054f8d/plan' \
	-b cookies.txt -c cookies.txt \
	-H 'Content-Type: application/json' \
	-d '{
  "prompt": "Fix typos",
  "version": 0
}'

Example response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

{
  "whole_context": false,
  "id": "2cb14c0b6097a1389cd319e5ef17fe5c",
  "version": 0,
  "sections": 1,
  "estimated_input_tokens": 1544
}

Objects

Objects that appear in the request and response tables above.

AI configuration

A saved AI provider configuration.

KeyValueDescription
idstringConfiguration ID.
namestringDisplay name.
urlstringAPI base URL.
modelstringModel ID.
has_keybooleanTrue when an API key is saved. The API never returns the key.
checkedbooleanTrue when a test or check succeeded with the current url, model, output_profile, and key. Sessions use only checked configurations.
is_defaultbooleanTrue for the configuration that new sessions use. At most one configuration is the default.
revisionintegerRevision. Each update increases it by 1.
output_profilestringEmpty: detect JSON Schema support. json_schema: always request JSON Schema output. One of "", json_schema.
context_tokensintegerContext window in tokens. 0 uses the provider value or 32768.
concurrencyintegerParallel requests for one job. 0 uses VYLK_AI_CONCURRENCY.

AI hunk

One suggested change.

KeyValueDescription
idstringHunk ID. Send it as hunk_id.
refstringLabel for people, such as @1 or @2.1. A prompt can name it. The server never reuses a label in a session.
startintegerStart of before in the draft, in UTF-16 code units. 0 when decision is outdated.
endintegerEnd of before in the draft, in UTF-16 code units. 0 when decision is outdated.
beforestringCurrent text.
afterstringSuggested text.
decisionstringEmpty while pending. outdated: another edit changed the text, and the hunk cannot be accepted. Reject it to dismiss it. One of "", accepted, rejected, outdated.

AI job

Status of a background job.

KeyValueDescription
idstringJob ID.
snapshot_idstringID of the plan that the job runs.
versionintegerSession version when the job finished, or when it started while it runs.
statusstringJob state. Get the session when it is completed. One of running, completed, failed, cancelled.
completedintegerProvider requests that finished.
totalintegerProvider requests planned so far. It can grow while the job runs.
errorstringReason for a failed job.

Acknowledgement

KeyValueDescription
client_sequenceintegerclient_sequence of the operation.
op_idstringop_id of the operation.
statusstringapplied: the server applied the operation. conflict: the base revision is old, and nothing changed. compacted: the server applied the operation earlier and no longer keeps its result. One of applied, conflict, compacted.
revisionintegerNew revision. Present when the operation applied.
current_revisionintegerCurrent revision. Present on a conflict.
pin_orderintegerNew pin position. note.pin only.

Change

KeyValueDescription
sequenceintegerPosition in the change feed.
note_idstringChanged note. Pattern: ^[A-Za-z0-9_-]{1,64}$.
revisionintegerRevision after the change.
deletedbooleanTrue when the change deleted the note.
changed_atstring (date-time)Time of the change.

Note with content

A note with its content.

Plaintext vault.

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
titlestringTitle. At most 512 bytes.
filenamestringFile name in the notes folder. Not an API path.
tagsstringComma-separated tags. The server trims them and removes duplicates. Tags are case-sensitive. At most 4096 bytes.
pinnedbooleanTrue when the note is pinned.
pin_orderintegerPosition among pinned notes. Absent when 0.
created_atstring (date-time)Creation time.
updated_atstring (date-time)Time of the last change.
revisionintegerRevision. Each change increases it by 1.
contentstringNote text in Markdown.

Encrypted vault.

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
summaryEnvelopeEncrypted title and tags.
pinnedbooleanTrue when the note is pinned.
pin_orderintegerPosition among pinned notes. 0 when not pinned.
created_atstring (date-time)Creation time.
updated_atstring (date-time)Time of the last change.
revisionintegerRevision. Each change increases it by 1.
epochintegerVault epoch that encrypted the note.
bodyEnvelopeEncrypted note text.

Device

KeyValueDescription
idstringDevice ID. 32 hexadecimal characters.
namestringBrowser and platform, from the User-Agent at sign-in.
last_seen_atstring (date-time)Approximate time of the last request.
currentbooleanTrue for the device that sent this request.

Encrypted operation

A queued edit in an encrypted vault. The server rejects title, tags, content, and base_content.

KeyValueDescription
client_sequenceintegerPosition in the queue. Starts at 1 and has no gaps. At least 1.
op_idstringStable identifier of the operation. Reuse it on retry. Pattern: ^[A-Za-z0-9_-]{1,128}$.
typestringOperation type. note.save, note.delete, and note.pin change a note. prefs.save changes preferences. noop only uses a sequence number. One of note.save, note.delete, note.pin, prefs.save, noop.
note_idstringTarget note. Required for note operations. Pattern: ^[A-Za-z0-9_-]{1,64}$.
base_revisionintegerRevision that the edit is based on. Required for note operations. At least 1 for note.delete.
summaryEnvelopeEncrypted title and tags. note.save only.
bodyEnvelopeEncrypted note text. note.save only.
epochintegerVault epoch that encrypted the envelopes. Required for note operations. At least 1.
pinnedbooleanNew pin state. note.pin only.
prefsPreferencesPreferences. Required for prefs.save.

Envelope

AES-256-GCM ciphertext as a JSON object, not as a string. The client protocol defines the encryption.

KeyValueDescription
v1Format version.
noncestring12-byte nonce in unpadded base64url.
ciphertextstringCiphertext followed by the 16-byte authentication tag, in unpadded base64url.

Note summary

A note without its content.

Note. Note metadata in a plaintext vault.

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
titlestringTitle. At most 512 bytes.
filenamestringFile name in the notes folder. Not an API path.
tagsstringComma-separated tags. The server trims them and removes duplicates. Tags are case-sensitive. At most 4096 bytes.
pinnedbooleanTrue when the note is pinned.
pin_orderintegerPosition among pinned notes. Absent when 0.
created_atstring (date-time)Creation time.
updated_atstring (date-time)Time of the last change.
revisionintegerRevision. Each change increases it by 1.

Encrypted note. Note metadata in an encrypted vault.

KeyValueDescription
idstringNote ID. 1 to 64 letters, digits, hyphens, or underscores.
summaryEnvelopeEncrypted title and tags.
pinnedbooleanTrue when the note is pinned.
pin_orderintegerPosition among pinned notes. 0 when not pinned.
created_atstring (date-time)Creation time.
updated_atstring (date-time)Time of the last change.
revisionintegerRevision. Each change increases it by 1.
epochintegerVault epoch that encrypted the note.

Operation

A queued edit in a plaintext vault. note.save needs the complete title, tags, and content. The server accepts base_content but does not use it to merge text.

KeyValueDescription
client_sequenceintegerPosition in the queue. Starts at 1 and has no gaps. At least 1.
op_idstringStable identifier of the operation. Reuse it on retry. Pattern: ^[A-Za-z0-9_-]{1,128}$.
typestringOperation type. note.save, note.delete, and note.pin change a note. prefs.save changes preferences. noop only uses a sequence number. One of note.save, note.delete, note.pin, prefs.save, noop.
note_idstringTarget note. Required for note operations. Pattern: ^[A-Za-z0-9_-]{1,64}$.
base_revisionintegerRevision that the edit is based on. Required for note operations. At least 1 for note.delete.
titlestringComplete title. note.save only.
tagsstringComplete tags. note.save only.
contentstringComplete Markdown text. note.save only.
base_contentstringText that the edit is based on. Accepted and not used.
pinnedbooleanNew pin state. note.pin only.
prefsPreferencesPreferences. Required for prefs.save.

Shortcut

KeyValueDescription
stepsarray of Shortcut stepOne or two key presses.

Preferences

Preferences that every device shares. They are not encrypted. Defaults apply to a new account. In a prefs.save operation, send the changed fields in _sync_patch and their previous values in _sync_base. A field conflicts when another device changed it to a third value.

KeyValueDescription
aiEnabledbooleanTurn on AI. When false, every /api/ai/ route returns 403, and the server ends every AI session. Default: false.
revisionintegerRevision. Each save increases it by 1.
autoSavebooleanSync changes automatically. Changes are always saved on the device. Default: true.
reduceMotionstringsystem follows the operating system. always turns off animations. never keeps them on. One of system, always, never. Default: system.
startViewstringView of a newly opened note. One of editor, preview, split, zen. Default: editor.
hideToolbarbooleanHide the formatting toolbar above the editor. Default: false.
hideSaveButtonbooleanHide the manual Save button. Default: true.
saveButtonLocationstringpanel puts the Save button in the editor toolbar. header puts it in the app header. One of "", panel, header. Default: panel.
collapseDetailsbooleanCollapse the title and tags fields when a note opens.
hideCursorHighlightbooleanTurn off the preview highlight of the block at the cursor.
interactivePreviewbooleanAllow toggling tasks and moving blocks in Split and Preview views. Default: true.
statusDisplaystringSync status display. The web app uses normal, compact, or off.
contentWidthstringWidth of the text column. One of "", compact, standard, wide, full.
zenPageWidthstringWidth of the page in Zen mode. One of "", compact, standard, wide, full.
themestringBuilt-in theme name, or a palette string that the client defines. The server does not interpret it.
accentColorstringCustom accent color. Empty means the theme color.
fontFamilystringInterface font.
fontFamilyGooglebooleanLoad fontFamily from Google Fonts.
fontSizestringInterface font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
editorFontFamilystringEditor font.
editorFontFamilyGooglebooleanLoad editorFontFamily from Google Fonts.
editorFontSizestringEditor font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
previewFontFamilystringPreview font.
previewFontFamilyGooglebooleanLoad previewFontFamily from Google Fonts.
previewFontSizestringPreview font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem.
zenFontFamilystringZen mode font. Default: Inter.
zenFontFamilyGooglebooleanLoad zenFontFamily from Google Fonts. Default: true.
zenFontSizestringZen mode font size. One of "", 0.8rem, 0.9rem, 1rem, 1.1rem, 1.25rem, 1.5rem. Default: 1.25rem.
zenWordCountbooleanShow the word count in Zen mode. Default: true.
zenShowTitlebooleanShow the title in Zen mode. Default: true.
zenShowControlsbooleanShow the controls in Zen mode. Default: true.
zenInteractivePreviewbooleanStored for clients. The vylk web app does not use it.
shortcutPrefixShortcutKey press that starts a shortcut. Exactly one step. The default is Mod+E.
keyboardShortcutsobjectCustom shortcuts by action name, at most 64. null turns off the default shortcut for that action. Each value is Shortcut or null.
shortcutConfirmationSkipsobjectActions that run without a confirmation, at most 64. Each value is true.
_sync_patchobjectChanged fields. prefs.save operations only.
_sync_baseobjectPrevious values of the changed fields. prefs.save operations only.

Shortcut step

One key press. The first step uses ["Mod"] or ["Mod", "Shift"]. A second step uses no modifiers.

KeyValueDescription
keystringOne letter, digit, /, or ;. Pattern: ^[A-Za-z0-9/;]$.
modifiersarray of stringMod is Ctrl on Windows and Linux and Command on macOS.