# Replace templates

URL: https://docs.hanzo.ai/docs/openapi/legal/put-legal-templates-by-id

> Saves the org's own version of a template — a custom NDA, a house MSA — and returns it with its new version number.

`PUT /v1/legal/templates/{id}`

> [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/templates/{id}` |
| **Method**    | `PUT`                                          |
| **Operation** | `put_legal_templates_by_id`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`         |

Saves the org's own version of a template — a custom
NDA, a house MSA — and returns it with its new version number. It takes effect
for that org only; other orgs keep the built-in.

Two boundaries cannot be crossed here. Overriding a built-in INHERITS its
category and its counsel-review posture, which can be raised but never dropped;
and a formation or equity template is counsel-review whatever the caller sends,
so no org can generate a securities-class document without the notice.

The body is validated on save, not at generation: a template that references an
UNDECLARED merge field is refused with 400 rather than stored and rendered blank
into a contract months later.

## Request

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

| Field            | In   | Type           | Required | Description                                                                                           |
| ---------------- | ---- | -------------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `id`             | path | string         | yes      | ID is the template to override, from the path.                                                        |
| `body`           | body | string         | —        | Body is the text/template source.                                                                     |
| `category`       | body | string         | —        | Category groups the template: formation, equity, ops or sales.                                        |
| `counselReview`  | body | boolean        | —        | CounselReview marks a template whose documents must carry the counsel notice.                         |
| `fields`         | body | legal.Field\[] | —        | Fields declares the merge fields the body consumes.                                                   |
| `fields[].key`   | body | string         | —        | Key is the identifier the body substitutes ({{.key}}) and the key a generation's data map must carry. |
| `fields[].label` | body | string         | —        | Label is the human prompt for whoever fills the value in — "Governing law (state)".                   |
| `id`             | body | string         | —        | ID is the template to override, from the path.                                                        |
| `title`          | body | string         | —        | Title is the template's display name.                                                                 |

## Response

| Status    | Body                | Meaning |
| --------- | ------------------- | ------- |
| `200`     | legal.templateReply | ok      |
| `default` | problem-details     | refused |

`200` body — 12 fields.

| Field                     | In   | Type                | Always | Description                                                                                           |
| ------------------------- | ---- | ------------------- | ------ | ----------------------------------------------------------------------------------------------------- |
| `disclaimer`              | body | string              | —      | Disclaimer is the boundary made visible on the wire.                                                  |
| `template`                | body | legal.legalTemplate | —      |                                                                                                       |
| `template.body`           | body | string              | —      |                                                                                                       |
| `template.category`       | body | string              | —      |                                                                                                       |
| `template.counselReview`  | body | boolean             | —      |                                                                                                       |
| `template.fields`         | body | legal.Field\[]      | —      |                                                                                                       |
| `template.fields[].key`   | body | string              | —      | Key is the identifier the body substitutes ({{.key}}) and the key a generation's data map must carry. |
| `template.fields[].label` | body | string              | —      | Label is the human prompt for whoever fills the value in — "Governing law (state)".                   |
| `template.id`             | body | string              | —      |                                                                                                       |
| `template.origin`         | body | string              | —      |                                                                                                       |
| `template.title`          | body | string              | —      |                                                                                                       |
| `template.version`        | body | integer (int64)     | —      |                                                                                                       |

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

## Examples

**CLI**

```bash
hanzo legal templates set <id>
```

**SDK**

**.ts**

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

const api = new LegalApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.putLegalTemplatesById({ id: 'id', body: "<body>", category: "<category>" });
```

**.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).put_legal_templates_by_id(id='id', body="<body>", category="<category>")
```

**.go**

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

resp, _, err := client.LegalAPI.PutLegalTemplatesById(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::put_legal_templates_by_id(&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).putLegalTemplatesById();
```

**HTTP**

```bash
curl -X PUT https://api.hanzo.ai/v1/legal/templates/<id> \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "body": "<body>",
       "category": "<category>"
     }'
```

**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)
