Skip to main content

Create Document

POST /v1/documents
Create a new document with blocks. Requires the documents:write role.

Request

Headers

HeaderRequiredDescription
X-API-KeyYesYour API key
Content-TypeYesapplication/json

Body

FieldTypeRequiredDescription
titlestringYesDocument title (max 500 characters)
blocksarrayYesArray of content blocks
blocks[].typestringYesBlock type: heading, paragraph, code, list, quote, table, image, divider
blocks[].contentstringYesBlock content
blocks[].metadataobjectNoBlock metadata (e.g., level for headings)
folder_idstringNoTarget folder ID. Uses root folder if omitted.
content_typestringNoDefault: "markdown"
visibilitystringNo"private" (default) or "public"
metadataobjectNoDocument-level metadata

Example

curl -X POST https://api.surfacedocs.dev/v1/documents \
  -H "X-API-Key: sd_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "title": "API Guide",
    "blocks": [
      {"type": "heading", "content": "Overview", "metadata": {"level": 1}},
      {"type": "paragraph", "content": "Welcome to the API."}
    ]
  }'

Response

Status: 201 Created
{
  "id": "doc_abc123",
  "url": "https://app.surfacedocs.dev/d/doc_abc123",
  "folder_id": "fld_xyz",
  "title": "API Guide",
  "content_type": "markdown",
  "block_count": 2,
  "metadata": null,
  "visibility": "private",
  "created_at": "2025-01-15T10:30:00Z"
}

Quota Headers

Responses include document quota information:
HeaderDescription
X-Quota-UsedDocuments created this month
X-Quota-LimitMonthly document limit
X-Quota-ResetDate when quota resets (YYYY-MM-DD)