> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.sofer.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sofer.ai/_mcp/server.

# Create Document

POST https://api.sofer.ai/v1/documents/
Content-Type: application/json

Create a durable document from plain text, Markdown, or a Word `.docx` file.

Provide exactly one of `content` or `file`. Files must be base64 encoded. Text,
Markdown, and Word ingestion completes synchronously. The returned `id` is the
document ID used by every document, translation, and folder endpoint.

Reference: https://docs.sofer.ai/api-reference/documents/create-document

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a DocumentCreateRequest.

- `title` (string, optional) — Display title. Defaults to the file name without its extension or Untitled Document.
- `folder_id` (UUID, optional) — Optional owned folder. Null or omitted creates the document at root.
- `format` (enum, optional) — Source format. Defaults to text for content and is inferred from file_name for files.
  - Allowed values: `text`, `markdown`, `docx`
- `content` (string, optional) — UTF-8 plain-text or Markdown content. Provide this or file, but not both.
- `file` (string, optional) — Base64-encoded `.txt`, `.md`, or `.docx` file. Provide this or content, but not both.
- `file_name` (string, optional) — Original file name. Used to infer format and title when those values are omitted.

## Response

### 200

- `id` (UUID, required) — Stable document ID.
- `type` (string, required) — Document source type.
- `title` (string, required) — Display title.
- `status` (string, required) — Current document or processing status.
- `archived` (boolean, required) — Whether the document is archived.
- `created_at` (datetime, required) — Creation time.
- `folder_id` (UUID, optional) — Containing folder, or null for root.
- `updated_at` (datetime, optional) — Last update time, when available.
- `text` (string, optional) — Visible plain text for completed text and transcript documents when available.
- `html` (string, optional) — Editor-compatible HTML for completed documents when available.

## Errors

### 401 Authentication Error

Authentication error

### 413 Document Too Large

Document exceeds the ingestion limit.

### 400 Invalid Document

Invalid document content, format, state, or update.

### 404 Folder Not Found

Folder not found or not owned by the authenticated API user.

### 429 Rate Limit Error

Rate limit exceeded, or you have used up your quota

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  "type": "type",
  "title": "title",
  "status": "status",
  "archived": true,
  "created_at": "2024-01-15T09:30:00Z",
  "folder_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  "updated_at": "2024-01-15T09:30:00Z",
  "text": "text",
  "html": "html"
}
```

**SDK Code**

```python
import requests

url = "https://api.sofer.ai/v1/documents/"

payload = {}
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.sofer.ai/v1/documents/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sofer.ai/v1/documents/"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.sofer.ai/v1/documents/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.sofer.ai/v1/documents/")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.sofer.ai/v1/documents/', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.sofer.ai/v1/documents/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sofer.ai/v1/documents/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```