Create 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

Addresshttps://api.hanzo.ai/v1/legal/documents
MethodPOST
Operationpost_legal_documents
AuthAuthorization: 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).

FieldInTypeRequiredDescription
databodyobject—Data supplies every merge field the template declares, keyed by field key.
data.*bodystring—
templateIdbodystring—TemplateID is the template to render.

Response

StatusBodyMeaning
201legal.documentReplycreated
defaultproblem-detailsrefused

201 body — 14 fields.

FieldInTypeAlwaysDescription
disclaimerbodystring—Disclaimer is the boundary made visible on the wire.
documentbodylegal.documentView—
document.bodybodystring—Body is the rendered document.
document.categorybodystring—
document.contentTypebodystring—ContentType is the rendered body's media type — text/markdown.
document.createdAtbodyinteger (int64)—
document.esignProviderbodystring—
document.idbodystring—
document.signedAtbodyinteger (int64)—
document.statusbodystring—
document.templateIdbodystring—
document.templateVersionbodyinteger (int64)—
document.titlebodystring—
document.updatedAtbodyinteger (int64)—

Failure carries the platform error shape — see Errors.

Examples

hanzo legal documents create
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>" });
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>")
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
}
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?;
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();
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 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:

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 · All Hanzo APIs · Interactive reference

Was this page useful?