ToDiagram

Documents API

Manage your saved documents programmatically

The Documents API allows you to create, retrieve, update, and list your saved documents.

Authentication

All endpoints require an API key in the Authorization header:

Authorization: your-api-key-here

Get your API key from Account Settings in the editor.

Endpoints

Get Document

Retrieve a specific document by ID.

GET /api/document?id={documentId}

Parameters:

FieldTypeRequiredDescription
idstringYesDocument ID (query parameter)

Response:

{
  "id": "abc123",
  "name": "My Diagram",
  "content": "{ \"user\": \"John\" }",
  "format": "json",
  "owner_id": "user-uuid",
  "visibility": "private",
  "created_at": "2025-01-15T10:30:00Z",
  "updated_at": "2025-01-15T14:20:00Z"
}

Create Document

Create a new document.

POST /api/document
Content-Type: application/json

{
  "name": "My New Diagram",
  "content": "{ \"user\": \"John\" }",
  "format": "json",
  "private": true
}

Parameters:

FieldTypeRequiredDescription
namestringYesDocument name
contentstringYesDocument content
formatstringNoFormat: json, yaml, xml, csv, custom, mermaid (default: json)
privatebooleanNoDeprecated. Use visibility instead
visibilitystringNoprivate, public, or team (default: private)

Response:

{
  "id": "abc123"
}

Update Document

Update an existing document.

PUT /api/document
Content-Type: application/json

{
  "id": "abc123",
  "name": "Updated Name",
  "content": "{ \"user\": \"Jane\" }",
  "format": "json"
}

Parameters:

FieldTypeRequiredDescription
idstringYesDocument ID
namestringNoNew document name
contentstringNoNew document content
formatstringNoNew format: json, yaml, xml, csv, custom, mermaid
visibilitystringNoprivate, public, or team

Response:

{
  "id": "abc123"
}