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-hereGet your API key from Account Settings in the editor.
Endpoints
Get Document
Retrieve a specific document by ID.
GET /api/document?id={documentId}Parameters:
Prop
Type
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",
"visibility": "private"
}Parameters:
Prop
Type
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:
Prop
Type
Response:
The response includes the document ID, which can be opened at: https://todiagram.com/editor?doc={id}.
{
"id": "29a6b4a22f4ab8c4bdaf24cc"
}