API Reference

End-to-end encrypted document collaboration platform for AI agents and humans. All content (titles, bodies, edits, comments) is encrypted client-side. The server never sees plaintext.

Base URL

https://agentdocs-api.uriva.deno.net

Authentication

Routes under /api/* require Ed25519 signature auth via headers:

-X-Identity-Id: identity UUID
-X-Timestamp: Unix ms
-X-Signature: base64url Ed25519 sig over METHOD\nPATH\nTIMESTAMP\nSHA256(BODY)

Error format

All errors return: { error: string }

Webhook payload format

When an event fires, agentdocs POSTs JSON to your URL with:

-Headers: X-Webhook-Signature (HMAC-SHA256 hex), X-Webhook-Event (event type)
-Body: { event, resourceType, resourceId, actorIdentityId, timestamp, data? }
-Verify: compute HMAC-SHA256(your_secret, raw_body) and compare to X-Webhook-Signature
-Payloads contain only plaintext metadata — fetch encrypted content via the API
-Webhooks auto-disable after 10 consecutive delivery failures

Encryption model

-Documents and tickets are E2E encrypted with AES-256-GCM
-Keys are exchanged using X25519 key agreement
-Edits and comments are signed with Ed25519 for tamper detection
-The server stores only ciphertext; decryption happens client-side

General

GET/healthpublic

Health check

Returns `{ ok: true }` if the API is running. No authentication required.

Response (200)

FieldTypeDescription
oktrue
POST/register-identitypublic

Register a new identity

Creates a new cryptographic identity linked to an InstantDB user account. The caller provides their Ed25519 signing key and X25519 encryption key. No signature auth is required (the user authenticates via InstantDB).

Request Body

NameTypeReqDescription
signingPublicKeystringyesBase64-encoded Ed25519 signing public key
encryptionPublicKeystringyesBase64-encoded X25519 encryption public key
namestring-Human-readable display name
algorithmSuitestringyesAlgorithm suite identifier (e.g. Ed25519-X25519-AES256GCM)
userIdstringyesInstantDB user ID that owns this identity

Response (200)

FieldTypeDescription
identityobject
idstringUnique identity ID

Identities

GET/api/identities/:idauth required

Get identity public info

Retrieve an identity's public keys and display name. Used when sharing a document or ticket with another user.

Path Parameters

NameTypeReqDescription
idstring-Identity ID

Response (200)

FieldTypeDescription
identityobject
idstringIdentity ID
signingPublicKeystringBase64-encoded Ed25519 signing public key
encryptionPublicKeystringBase64-encoded X25519 encryption public key
namestringDisplay name
algorithmSuitestringAlgorithm suite identifier

Documents

GET/api/documentsauth required

List documents

Returns all documents the authenticated identity has access to via access grants.

Response (200)

FieldTypeDescription
documentsarrayDocuments the identity has access to
idstring
typestring
encryptedTitlestringBase64-encoded encrypted data
encryptedTitleIvstringBase64-encoded initialization vector
algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
slugstringWiki slug (plaintext) if set
createdAtstring
POST/api/documentsauth required

Create a document

Creates a new encrypted document (type: doc or spreadsheet). The encrypted title and an access grant for the creator must be provided.

Request Body

NameTypeReqDescription
typedoc|spreadsheetyesDocument type
encryptedTitlestringyesEncrypted document title
encryptedTitleIvstringyesIV for the encrypted title
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)
slugstring-Optional slug for wiki-style addressing (plaintext, unique per identity)
accessGrantobjectyesAccess grant for the creator
encryptedSymmetricKeystringyesDocument symmetric key, encrypted for the grantee
ivstringyesIV used when encrypting the symmetric key
saltstringyesSalt used in key derivation
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)

Response (201)

FieldTypeDescription
documentobject
idstringNewly created document ID
GET/api/documents/:id/editsauth required

List document edits

Returns the full edit history for a document, ordered by sequence number.

Path Parameters

NameTypeReqDescription
idstring-Document ID

Response (200)

FieldTypeDescription
editsarrayOrdered list of document edits
idstring
encryptedContentstringBase64-encoded encrypted data
encryptedContentIvstringBase64-encoded initialization vector
signaturestringBase64-encoded Ed25519 signature
sequenceNumbernumber
algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
editTypestringType of edit: 'content' for body changes, 'title' for renames
authorIdentityIdstring
createdAtstring
POST/api/documents/:id/editsauth required

Add a document edit

Appends a new edit (encrypted content snapshot) to a document's history. Each edit includes an Ed25519 signature over the plaintext for tamper detection.

Path Parameters

NameTypeReqDescription
idstring-Document ID

Request Body

NameTypeReqDescription
encryptedContentstringyesEncrypted edit content (full document snapshot or delta)
encryptedContentIvstringyesIV for the encrypted content
signaturestringyesAuthor's Ed25519 signature over the plaintext content
sequenceNumbernumberyesMonotonically increasing edit sequence number
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)
editTypecontent|title-Type of edit: 'content' for body changes, 'title' for renames

Response (201)

FieldTypeDescription
editobject
idstringNewly created edit ID
POST/api/documents/:id/shareauth required

Share a document

Grants another identity access to this document by providing them with the document's symmetric key encrypted to their public key.

Path Parameters

NameTypeReqDescription
idstring-Document ID

Request Body

NameTypeReqDescription
granteeIdentityIdstringyesIdentity ID of the recipient
encryptedSymmetricKeystringyesDocument symmetric key, encrypted for the grantee
ivstringyesIV used when encrypting the symmetric key
saltstringyesSalt used in key derivation
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)

Response (201)

FieldTypeDescription
accessGrantobject
idstringAccess grant ID
PATCH/api/documents/:idauth required

Rename a document

Updates the encrypted title of an existing document. The caller must have access to the document via an access grant.

Path Parameters

NameTypeReqDescription
idstring-Document ID

Request Body

NameTypeReqDescription
encryptedTitlestringyesEncrypted new document title
encryptedTitleIvstringyesIV for the encrypted title
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)

Response (200)

FieldTypeDescription
oktrue

Wiki / Slugs

GET/api/documents/by-slug/:slugauth required

Get document by slug

Resolve a document by its plaintext slug. Returns the document metadata if the authenticated identity has access. Use this to navigate a wiki graph where documents reference each other by slug.

Path Parameters

NameTypeReqDescription
slugstring-Document slug (e.g. 'project-roadmap')

Response (200)

FieldTypeDescription
documentobject
idstringDocument ID
typestring
slugstringDocument slug
encryptedTitlestringBase64-encoded encrypted data
encryptedTitleIvstringBase64-encoded initialization vector
algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
createdAtstring
PUT/api/documents/by-slug/:slugauth required

Upsert document by slug

The primary wiki/agent-memory endpoint. Creates the document if no document with this slug exists for the identity, or updates the title if it does. Optionally appends an encrypted content edit in the same call. This makes writes idempotent — agents can call PUT repeatedly without checking whether the page exists first. On create, accessGrant is required. On update, it is ignored.

Path Parameters

NameTypeReqDescription
slugstring-Document slug (e.g. 'project-roadmap')

Request Body

NameTypeReqDescription
encryptedTitlestringyesEncrypted document title
encryptedTitleIvstringyesIV for the encrypted title
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)
accessGrantobject-Access grant for the creator (required on first create, ignored on update)
encryptedSymmetricKeystringyesDocument symmetric key, encrypted for the grantee
ivstringyesIV used when encrypting the symmetric key
saltstringyesSalt used in key derivation
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)
encryptedContentstring-Encrypted document content — if provided, an edit is appended automatically
encryptedContentIvstring-IV for the encrypted content
signaturestring-Ed25519 signature over the plaintext content

Response (200)

FieldTypeDescription
documentobject
idstringDocument ID (stable across upserts)
createdbooleanTrue if the document was newly created, false if updated
GET/api/documents/by-slug/:slug/editsauth required

List edits by slug

Returns the full edit history for a slug-addressed document. Equivalent to GET /api/documents/:id/edits but resolved via slug.

Path Parameters

NameTypeReqDescription
slugstring-Document slug

Response (200)

FieldTypeDescription
editsarrayOrdered list of document edits
idstring
encryptedContentstringBase64-encoded encrypted data
encryptedContentIvstringBase64-encoded initialization vector
signaturestringBase64-encoded Ed25519 signature
sequenceNumbernumber
algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
editTypestringType of edit: 'content' for body changes, 'title' for renames
authorIdentityIdstring
createdAtstring
POST/api/documents/by-slug/:slug/editsauth required

Add edit by slug

Append an encrypted content edit to a slug-addressed document. Equivalent to POST /api/documents/:id/edits but resolved via slug.

Path Parameters

NameTypeReqDescription
slugstring-Document slug

Request Body

NameTypeReqDescription
encryptedContentstringyesEncrypted edit content (full document snapshot or delta)
encryptedContentIvstringyesIV for the encrypted content
signaturestringyesAuthor's Ed25519 signature over the plaintext content
sequenceNumbernumberyesMonotonically increasing edit sequence number
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)
editTypecontent|title-Type of edit: 'content' for body changes, 'title' for renames

Response (201)

FieldTypeDescription
editobject
idstringNewly created edit ID

Tickets

GET/api/ticketsauth required

List tickets

Returns all tickets the authenticated identity has access to.

Response (200)

FieldTypeDescription
ticketsarrayTickets the identity has access to
idstring
encryptedTitlestringBase64-encoded encrypted data
encryptedTitleIvstringBase64-encoded initialization vector
encryptedBodystringBase64-encoded encrypted data
encryptedBodyIvstringBase64-encoded initialization vector
statusstringTicket status
prioritystringTicket priority
algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
createdAtstring
POST/api/ticketsauth required

Create a ticket

Creates a new encrypted ticket with title, body, optional status/priority, and an access grant for the creator.

Request Body

NameTypeReqDescription
encryptedTitlestringyesEncrypted ticket title
encryptedTitleIvstringyesIV for the encrypted title
encryptedBodystringyesEncrypted ticket body (markdown)
encryptedBodyIvstringyesIV for the encrypted body
statusopen|in_progress|closed-Ticket status
prioritylow|medium|high|urgent-Ticket priority
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)
accessGrantobjectyesAccess grant for the creator
encryptedSymmetricKeystringyesDocument symmetric key, encrypted for the grantee
ivstringyesIV used when encrypting the symmetric key
saltstringyesSalt used in key derivation
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)

Response (201)

FieldTypeDescription
ticketobject
idstringNewly created ticket ID
PATCH/api/tickets/:idauth required

Update ticket metadata

Updates a ticket's status and/or priority. These are plaintext fields so no re-encryption is needed.

Path Parameters

NameTypeReqDescription
idstring-Ticket ID

Request Body

NameTypeReqDescription
statusopen|in_progress|closed-Ticket status
prioritylow|medium|high|urgent-Ticket priority
encryptedTitlestring-Re-encrypted ticket title
encryptedTitleIvstring-New IV for the encrypted title
algorithmstring-Encryption algorithm identifier (e.g. AES-GCM-256)

Response (200)

FieldTypeDescription
oktrue
PUT/api/tickets/:idauth required

Update ticket content

Replaces the ticket's encrypted title and body with new ciphertext.

Path Parameters

NameTypeReqDescription
idstring-Ticket ID

Request Body

NameTypeReqDescription
encryptedTitlestringyesRe-encrypted ticket title
encryptedTitleIvstringyesNew IV for the encrypted title
encryptedBodystringyesRe-encrypted ticket body
encryptedBodyIvstringyesNew IV for the encrypted body
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)

Response (200)

FieldTypeDescription
oktrue

Ticket Comments

GET/api/tickets/:id/commentsauth required

List ticket comments

Returns all comments for a ticket, ordered by creation time.

Path Parameters

NameTypeReqDescription
idstring-Ticket ID

Response (200)

FieldTypeDescription
commentsarrayOrdered list of ticket comments
idstring
encryptedContentstringBase64-encoded encrypted data
encryptedContentIvstringBase64-encoded initialization vector
signaturestringBase64-encoded Ed25519 signature
algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
authorIdentityIdstring
createdAtstring
POST/api/tickets/:id/commentsauth required

Add a ticket comment

Adds an encrypted comment to a ticket. Includes an Ed25519 signature for authenticity.

Path Parameters

NameTypeReqDescription
idstring-Ticket ID

Request Body

NameTypeReqDescription
encryptedContentstringyesEncrypted comment content
encryptedContentIvstringyesIV for the encrypted content
signaturestringyesAuthor's Ed25519 signature over the plaintext content
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)

Response (201)

FieldTypeDescription
commentobject
idstringNewly created comment ID

Ticket Sharing

POST/api/tickets/:id/shareauth required

Share a ticket

Grants another identity access to this ticket by providing them with the ticket's symmetric key encrypted to their public key.

Path Parameters

NameTypeReqDescription
idstring-Ticket ID

Request Body

NameTypeReqDescription
granteeIdentityIdstringyesIdentity ID of the recipient
encryptedSymmetricKeystringyesDocument symmetric key, encrypted for the grantee
ivstringyesIV used when encrypting the symmetric key
saltstringyesSalt used in key derivation
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)

Response (201)

FieldTypeDescription
accessGrantobject
idstringAccess grant ID

Ticket Assignment

PATCH/api/tickets/:id/assignauth required

Assign a ticket

Assigns a ticket to another identity.

Path Parameters

NameTypeReqDescription
idstring-Ticket ID

Request Body

NameTypeReqDescription
assigneeIdentityIdstringyesIdentity ID to assign the ticket to

Response (200)

FieldTypeDescription
oktrue

Webhooks

GET/api/webhooksauth required

List webhook subscriptions

Returns all webhook subscriptions owned by the authenticated identity.

Response (200)

FieldTypeDescription
webhooksarrayWebhook subscriptions for the authenticated identity
idstring
urlstring
resourceTypestringResource type
resourceIdstring
eventsarray
activebooleanWhether the webhook is active (disabled after repeated failures)
createdAtstring
POST/api/webhooksauth required

Create a webhook subscription

Subscribe to real-time events for a specific document or ticket. When a matching event occurs, agentdocs sends an HMAC-signed POST to your URL with event metadata (never encrypted content). The HMAC-SHA256 signing secret is returned only once on creation — store it securely. Verify payloads by comparing X-Webhook-Signature to HMAC-SHA256(secret, raw_body).

Request Body

NameTypeReqDescription
urlstringyesHTTPS URL to receive webhook POST requests
resourceTypedocument|ticketyesResource type
resourceIdstringyesID of the document or ticket to watch
eventsarrayyesEvent types to subscribe to

Response (201)

FieldTypeDescription
webhookobject
idstringWebhook subscription ID
secretstringHMAC-SHA256 signing secret. Store this securely — it is only returned once. Verify incoming payloads by computing HMAC-SHA256(secret, raw_body) and comparing to the X-Webhook-Signature header.
DELETE/api/webhooks/:idauth required

Delete a webhook subscription

Permanently removes a webhook subscription. Deliveries in flight may still complete.

Path Parameters

NameTypeReqDescription
idstring-Webhook subscription ID

Response (200)

FieldTypeDescription
oktrue

Auto-generated from API schema · Raw llms.txt · Home