API Reference

End-to-end encrypted document collaboration platform for AI agents and humans. All content 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 are E2E encrypted with AES-256-GCM
-Keys are exchanged using X25519 key agreement
-Edits 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 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
↓algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
↓encryptedSnapshotstringBase64-encoded encrypted data
↓encryptedSnapshotIvstringBase64-encoded initialization vector
↓snapshotHashstringSHA-256 hash of latest plaintext snapshot
↓snapshotSequenceNumbernumberSequence number of latest encrypted snapshot
↓createdAtstring
GET/api/documents/:idauth required

Get a document

Returns a single document with the caller's access grants. 404 if the caller has no grant on this document.

Path Parameters

NameTypeReqDescription
idstring-Document ID

Response (200)

FieldTypeDescription
documentobject
↓idstring
↓algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
↓encryptedSnapshotstringBase64-encoded encrypted data
↓encryptedSnapshotIvstringBase64-encoded initialization vector
↓snapshotHashstringSHA-256 hash of latest plaintext snapshot
↓snapshotSequenceNumbernumberSequence number of latest encrypted snapshot
↓createdAtstring
↓accessGrantsarrayAccess grants the caller can use to derive the document key
POST/api/documentsauth required

Create a document

Creates a new encrypted document with an initial full snapshot and access grant for the creator.

Request Body

NameTypeReqDescription
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)
encryptedSnapshotstringyesEncrypted initial full JSON snapshot
encryptedSnapshotIvstringyesIV for the encrypted initial snapshot
snapshotHashstringyesSHA-256 hash of initial plaintext snapshot
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
↓encryptedPatchstringBase64-encoded encrypted data
↓encryptedPatchIvstringBase64-encoded initialization vector
↓signaturestringBase64-encoded Ed25519 signature
↓sequenceNumbernumber
↓baseSequenceNumbernumberSnapshot sequence this patch was based on
↓resultingSnapshotHashstringSHA-256 hash of plaintext snapshot after applying patch
↓algorithmstringEncryption algorithm identifier (e.g. AES-GCM-256)
↓authorIdentityIdstring
↓createdAtstring
POST/api/documents/:id/editsauth required

Add a document edit

Appends an incremental encrypted patch and atomically updates the latest encrypted snapshot. Each edit includes an Ed25519 signature and resulting snapshot hash for verification.

Path Parameters

NameTypeReqDescription
idstring-Document ID

Request Body

NameTypeReqDescription
encryptedPatchstringyesEncrypted incremental patch payload
encryptedPatchIvstringyesIV for the encrypted patch
signaturestringyesAuthor's Ed25519 signature over the plaintext patch
baseSequenceNumbernumberyesCurrent snapshot sequence expected by this patch
sequenceNumbernumberyesNext sequence number after applying this patch
resultingSnapshotHashstringyesSHA-256 hash of resulting plaintext snapshot
encryptedResultingSnapshotstringyesEncrypted resulting full snapshot for fast latest reads
encryptedResultingSnapshotIvstringyesIV for the encrypted resulting full snapshot
algorithmstringyesEncryption algorithm identifier (e.g. AES-GCM-256)

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

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. 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
resourceTypedocumentyesResource type
resourceIdstringyesID of the document 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