POST /api/spaces/{space}/documents
Spaces API - Create Document 📄
This endpoint lets authenticated users add a new document (page) to a specific Space.
Authentication 🔒
Requests must include a valid token. Unauthorized access returns 403 Forbidden.
Endpoint
POST /api/spaces/{space}/documents
Request
Path Parameter
| Name | Type | Required | Description |
|---|---|---|---|
| space | integer | yes | ID of the Space |
Headers
- Authorization:
Bearer(required)
Body Parameters
| Field | Type | Required | Validation | Description |
|---|---|---|---|---|
| title | string | yes | max:255 | Document title |
| content | string | yes | — | Raw Markdown or blank content |
| type | string | no | in: blank, markdown |
How to store content; markdown triggers Editor.js conversion |
| parent_id | integer | no | exists: spacemenuitems,id |
ID of parent folder |
| path | string | no | max:500 | Slash-delimited folder path (e.g. "docs/api") |
Example Request
{
"title": "API Overview",
"content": "# API Overview\nThis document explains the endpoints.",
"type": "markdown",
"parent_id": null,
"path": "docs/api"
}
Response
Success (201 Created)
{
"success": true,
"data": {
"id": 10,
"name": "API Overview",
"type": "blank",
"parent_id": null,
"url": "https://app.docuwriter.ai/space/1/item/10",
"created_at": "2025-09-17T12:00:00Z"
},
"message": "Document created successfully"
}
- 201 status code
- data.url links to the new page in the app
Error Responses ❌
| Status | Condition | Response Body |
|---|---|---|
| 403 | Unauthorized | { "success": false, "message": "Access denied. You do not have permission to create documents in this space." } |
| 422 | Validation failed | { "success": false, "message": "Validation failed", "errors": { "title": ["The title field is required."] } } |
| 500 | Server error | { "success": false, "message": "Failed to create document: " } |
{
"title": "Create Space Document",
"description": "Create a new document in a Space",
"method": "POST",
"baseUrl": "https://app.docuwriter.ai",
"endpoint": "/api/spaces/{space}/documents",
"headers": [
{
"key": "Authorization",
"value": "Bearer <token>",
"required": true
}
],
"queryParams": [],
"pathParams": [
{
"key": "space",
"value": "Space ID",
"required": true
}
],
"bodyType": "json",
"requestBody": "{\n \"title\": \"API Overview\",\n \"content\": \"# API Overview\\nDetails...\",\n \"type\": \"markdown\",\n \"parent_id\": null,\n \"path\": \"docs/api\"\n}",
"formData": [],
"rawBody": "",
"responses": {
"201": {
"description": "Document created successfully",
"body": "{\n \"success\": true,\n \"data\": {\n \"id\": 10,\n \"name\": \"API Overview\",\n \"type\": \"blank\",\n \"parent_id\": null,\n \"url\": \"https://app.docuwriter.ai/space/1/item/10\",\n \"created_at\": \"2025-09-17T12:00:00Z\"\n },\n \"message\": \"Document created successfully\"\n}"
},
"403": {
"description": "Unauthorized",
"body": "{\n \"success\": false,\n \"message\": \"Access denied. You do not have permission to create documents in this space.\"\n}"
},
"422": {
"description": "Validation error",
"body": "{\n \"success\": false,\n \"message\": \"Validation failed\",\n \"errors\": { \"title\": [\"The title field is required.\"] }\n}"
},
"500": {
"description": "Server error",
"body": "{\n \"success\": false,\n \"message\": \"Failed to create document: Internal error\"\n}"
}
}
}
Updated