> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trusset.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Terms Template

> Edit a terms library template, or archive and restore it

Changes one template of this instance's terms library. Send only the fields to change: a field you leave out keeps its value. This is a database write: nothing is signed and nothing goes on chain.

A change to the title or the text writes a new template version and answers `changed: true`. Markets bound to the template keep the version they published until they are bound again with [Save Terms](https://docs.trusset.org/endpoints/lending/save-terms.md) and the same `templateId`. Until then they read `TEMPLATE_OUTDATED`, as [Get Terms Template](https://docs.trusset.org/endpoints/lending/get-terms-template.md) and [Get Terms](https://docs.trusset.org/endpoints/lending/get-terms.md) report. A [standing policy](https://docs.trusset.org/endpoints/operators/list-standing-policies.md) publishes the version that is current when a market is adopted.

`archived: true` archives the template, as [Archive Terms Template](https://docs.trusset.org/endpoints/lending/archive-terms-template.md) does, and `archived: false` restores it. Archiving alone writes no version and answers `changed: false`. A request that changes nothing writes nothing and answers `changed: false` as well.

Only an account Trusset approved as a lender of record can author templates. Any other account is refused with `403 CURATOR_NOT_APPROVED` before the body is read.

## Path Parameters

**templateId** `string` *required*

Template ID from [List Terms Templates](https://docs.trusset.org/endpoints/lending/list-terms-templates.md), 1 to 100 characters.

## Body Parameters

**title** `string`

New title, 1 to 200 characters, under the rules of [Create Terms Template](https://docs.trusset.org/endpoints/lending/create-terms-template.md#body-parameters).

**content** `string`

New text as markdown, under the rules of [Create Terms Template](https://docs.trusset.org/endpoints/lending/create-terms-template.md#body-parameters): at most 262,144 bytes of UTF-8, not blank, no control characters other than tab, newline and carriage return.

**archived** `boolean`

`true` to archive the template, `false` to restore it. Archiving is refused with `409 TEMPLATE_IN_USE` while the template is still bound to a published, non-customised market or to any standing policy, switched off or not. See [Archive Terms Template](https://docs.trusset.org/endpoints/lending/archive-terms-template.md#when-archiving-is-refused).

## Response Fields

**data** `object`

**template** `object`

The template after the change, with the fields of [Get Terms Template](https://docs.trusset.org/endpoints/lending/get-terms-template.md#response-fields) except `versions` and `markets`. `content` and `usage` are included.

**changed** `boolean`

`true` when the title or the text changed and a new version was written. `false` when only `archived` changed, or nothing did.

```bash cURL theme={null}
curl -X PUT "https://api.trusset.org/lending-external-securities-v2/api/markets/terms-library/cmwh2t9e10002l80d7s3k5m8c" \
  -H "X-API-Key: trusset_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "# Terms of Use\n\n## 1. Lender of record\n\nACME Bank AG acts as lender of record for this market.\n\n## 2. Collateral\n\nPledged tokens stay frozen in the wallet of the borrower.\n"
  }'
```

```typescript TypeScript theme={null}
import { readFile } from 'node:fs/promises';

const content = await readFile('./house-terms.md', 'utf8');

const res = await fetch(
  `https://api.trusset.org/lending-external-securities-v2/api/markets/terms-library/${templateId}`,
  {
    method: 'PUT',
    headers: {
      'X-API-Key': 'trusset_your_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ content })
  }
);
const { success, data, error } = await res.json();
if (!success) throw new Error(`${error.code}: ${error.message}`);
console.log(data.changed, data.template.version);
```

```json Response theme={null}
{
  "success": true,
  "data": {
    "template": {
      "id": "cmwh2t9e10002l80d7s3k5m8c",
      "instanceId": "cmrz4d1v20000cghx8k6p3m7t",
      "title": "Secured credit line, house terms",
      "version": 3,
      "contentHash": "0x6c1f0b2e9a47d385c2e0f81b97a4d6c3e5f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8",
      "archived": false,
      "archivedAt": null,
      "createdBy": "cmrz3a8q10000cghxf5w2n9k4",
      "updatedBy": "cmrz3a8q10000cghxf5w2n9k4",
      "createdAt": "2026-11-10T08:15:00.000Z",
      "updatedAt": "2026-11-16T13:58:22.000Z",
      "contentBytes": 172,
      "content": "# Terms of Use\n\n## 1. Lender of record\n\nACME Bank AG acts as lender of record for this market.\n\n## 2. Collateral\n\nPledged tokens stay frozen in the wallet of the borrower.\n",
      "usage": {
        "markets": 2,
        "current": 0,
        "outdated": 2,
        "customised": 0,
        "unpublished": 0
      }
    },
    "changed": true
  },
  "error": null,
  "metadata": {
    "timestamp": "2026-11-16T13:58:22.000Z",
    "requestId": "550e8400-e29b-41d4-a716-446655440000",
    "instanceId": "cmrz4d1v20000cghx8k6p3m7t"
  }
}
```

## Error Codes

| Code | HTTP | Cause |
| - | - | - |
| `VALIDATION_ERROR` | `400` | `templateId` or a field breaks its type or length rule |
| `INVALID_TERMS_TITLE` | `400` | The title is blank after trimming, or contains control characters |
| `INVALID_TERMS_CONTENT` | `400` | The document is blank, or contains control characters other than tab, newline and carriage return |
| `TEMPLATE_SAVE_FAILED` | `400` | The template could not be saved for a reason that carries no code of its own |
| `CURATOR_NOT_APPROVED` | `403` | Trusset has not approved this account to act as a lender of record |
| `TEMPLATE_NOT_FOUND` | `404` | No template with this ID exists on this instance |
| `TEMPLATE_IN_USE` | `409` | `archived: true`, and the template is still bound to a published, non-customised market or to a standing policy. `error.details` names them, see [Archive Terms Template](https://docs.trusset.org/endpoints/lending/archive-terms-template.md#when-archiving-is-refused) |
| `TERMS_TOO_LARGE` | `413` | The document exceeds 262,144 bytes of UTF-8, or the request body is over 1 MB |
| `RATE_LIMIT_EXCEEDED` | `429` | More than 10 writes in the minute |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.