# Create documents

URL: https://docs.hanzo.ai/docs/openapi/legal/post-legal-documents

> Renders a document from a template and the caller's own merge data, seals it in the org's store, and returns it with its rendered body.

`POST /v1/legal/documents`

> [Legal →](https://docs.hanzo.ai/docs/openapi/legal) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                           |
| ------------- | ----------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/legal/documents` |
| **Method**    | `POST`                                    |
| **Operation** | `post_legal_documents`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`    |

Renders a document from a template and the caller's own
merge data, seals it in the org's store, and returns it with its rendered body.

The render is PURE and deterministic — no clock, no I/O — so the same template
version and the same data always produce identical bytes, which is what makes a
generated contract reproducible. It fails CLOSED on a missing merge field: there
is no blank-filled contract, only a 400 naming the fields that were absent. When
the template is counsel-review the rendered body opens with the counsel notice,
which no caller can suppress.

The document is a DRAFT. Hanzo Legal manages documents; it does not give legal
advice and does not determine that a document is valid or sufficient.

## Request

3 fields, body `application/json` (required).

| Field        | In   | Type   | Required | Description                                                                |
| ------------ | ---- | ------ | -------- | -------------------------------------------------------------------------- |
| `data`       | body | object | —        | Data supplies every merge field the template declares, keyed by field key. |
| `data.*`     | body | string | —        |                                                                            |
| `templateId` | body | string | —        | TemplateID is the template to render.                                      |

## Response

| Status    | Body                | Meaning |
| --------- | ------------------- | ------- |
| `201`     | legal.documentReply | created |
| `default` | problem-details     | refused |

`201` body — 14 fields.

| Field                      | In   | Type               | Always | Description                                                    |
| -------------------------- | ---- | ------------------ | ------ | -------------------------------------------------------------- |
| `disclaimer`               | body | string             | —      | Disclaimer is the boundary made visible on the wire.           |
| `document`                 | body | legal.documentView | —      |                                                                |
| `document.body`            | body | string             | —      | Body is the rendered document.                                 |
| `document.category`        | body | string             | —      |                                                                |
| `document.contentType`     | body | string             | —      | ContentType is the rendered body's media type — text/markdown. |
| `document.createdAt`       | body | integer (int64)    | —      |                                                                |
| `document.esignProvider`   | body | string             | —      |                                                                |
| `document.id`              | body | string             | —      |                                                                |
| `document.signedAt`        | body | integer (int64)    | —      |                                                                |
| `document.status`          | body | string             | —      |                                                                |
| `document.templateId`      | body | string             | —      |                                                                |
| `document.templateVersion` | body | integer (int64)    | —      |                                                                |
| `document.title`           | body | string             | —      |                                                                |
| `document.updatedAt`       | body | integer (int64)    | —      |                                                                |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo legal documents create
```

**SDK**

**.ts**

```ts
import { Configuration, LegalApi } from 'hanzoai';

const api = new LegalApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postLegalDocuments({ data: {}, templateId: "<templateId>" });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import LegalApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = LegalApi(client).post_legal_documents(data={}, template_id="<templateId>")
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.LegalAPI.PostLegalDocuments(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, legal_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = legal_api::post_legal_documents(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.LegalApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new LegalApi(client).postLegalDocuments();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/legal/documents \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "data": {},
       "templateId": "<templateId>"
     }'
```

**MCP**

MCP reaches **legal** through the `legal` tool, which names its 10 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_legal_documents"
         }
       }
     }'
```

---

[Legal API](https://docs.hanzo.ai/docs/openapi/legal) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
