> ## 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.

# Archive Terms Template

> Archive a terms library template that nothing is bound to any more

Archives one template of this instance's terms library. Nothing is deleted: the template, its text and every version stay readable through [Get Terms Template](https://docs.trusset.org/endpoints/lending/get-terms-template.md), and [List Terms Templates](https://docs.trusset.org/endpoints/lending/list-terms-templates.md) lists it with `includeArchived=true`. An archived template can no longer be bound to a market or a standing policy. Restore it with `archived: false` on [Update Terms Template](https://docs.trusset.org/endpoints/lending/update-terms-template.md).

The call is the same as Update Terms Template with `archived: true`. It writes no new version, so `changed` is `false`. Archiving a template that is already archived changes nothing.

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

## When archiving is refused

A template that is still in use cannot be archived, because the markets and policies bound to it would point at terms the library no longer lists, and a market adopted under such a policy would go live without terms of use. Archiving is refused with `409 TEMPLATE_IN_USE` while the template is bound to either of these:

* a market whose terms are published and not customised
* any standing policy, switched off or not

`error.details` names every one of them:

| Field | Content |
| - | - |
| `markets` | `[{ generation, marketAddress, templateVersion, customised, published }]`, one entry per bound market |
| `policies` | `[{ id, kind, address, label, enabled }]`, one entry per bound standing policy |

Release them first, then archive again:

* Bind each market to another template with [Save Terms](https://docs.trusset.org/endpoints/lending/save-terms.md) and `templateId`, or customise its terms with a save that changes the text.
* Bind each policy to another template, or to none with `termsTemplateId: null`, on [Update Standing Policy](https://docs.trusset.org/endpoints/operators/update-standing-policy.md).

## 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.

## Response Fields

**data** `object`

**template** `object`

The archived template, with the fields of [Get Terms Template](https://docs.trusset.org/endpoints/lending/get-terms-template.md#response-fields) except `versions` and `markets`. `archived` reads `true` and `archivedAt` is set.

**changed** `boolean`

`false`: archiving writes no new version.

```bash cURL theme={null}
curl -X DELETE "https://api.trusset.org/lending-external-securities-v2/api/markets/terms-library/cmwh2t9e10002l80d7s3k5m8c" \
  -H "X-API-Key: trusset_your_key_here"
```

```typescript TypeScript theme={null}
const res = await fetch(
  `https://api.trusset.org/lending-external-securities-v2/api/markets/terms-library/${templateId}`,
  { method: 'DELETE', headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { success, data, error } = await res.json();
if (!success && error.code === 'TEMPLATE_IN_USE') {
  const { markets, policies } = error.details;
  console.log(markets.map((m) => m.marketAddress), policies.map((p) => p.id));
}
```

```json Archived theme={null}
{
  "success": true,
  "data": {
    "template": {
      "id": "cmwh2t9e10002l80d7s3k5m8c",
      "instanceId": "cmrz4d1v20000cghx8k6p3m7t",
      "title": "Secured credit line, house terms",
      "version": 3,
      "contentHash": "0x6c1f0b2e9a47d385c2e0f81b97a4d6c3e5f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8",
      "archived": true,
      "archivedAt": "2026-11-17T09:12:40.000Z",
      "createdBy": "cmrz3a8q10000cghxf5w2n9k4",
      "updatedBy": "cmrz3a8q10000cghxf5w2n9k4",
      "createdAt": "2026-11-10T08:15:00.000Z",
      "updatedAt": "2026-11-17T09:12:40.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": 0,
        "current": 0,
        "outdated": 0,
        "customised": 0,
        "unpublished": 0
      }
    },
    "changed": false
  },
  "error": null,
  "metadata": {
    "timestamp": "2026-11-17T09:12:40.000Z",
    "requestId": "550e8400-e29b-41d4-a716-446655440000",
    "instanceId": "cmrz4d1v20000cghx8k6p3m7t"
  }
}
```

```json Error - In Use theme={null}
{
  "success": false,
  "data": null,
  "error": {
    "code": "TEMPLATE_IN_USE",
    "message": "The template \"Secured credit line, house terms\" is bound to 1 market (v2 0x1c74f9a2b0e63d581a47c02f9b8de3517a604c2b) and 1 standing policy (\"ACME Industrial AG\", switched off). Archiving it would leave them pointing at house terms the library no longer lists, and a market adopted under such a policy would go live without terms of use. To archive it, bind each market to another template or customise its terms, and bind each policy to another template or to none first.",
    "details": {
      "markets": [
        {
          "generation": "v2",
          "marketAddress": "0x1c74f9a2b0e63d581a47c02f9b8de3517a604c2b",
          "templateVersion": 3,
          "customised": false,
          "published": true
        }
      ],
      "policies": [
        {
          "id": "cmwh3p7k20004l80dq2x9v1ab",
          "kind": "DEPLOYER",
          "address": "0x1234f9a07c6b53d81e2a4f70c9b385d6014a7e52",
          "label": "ACME Industrial AG",
          "enabled": false
        }
      ]
    }
  },
  "metadata": {
    "timestamp": "2026-11-17T09:10:05.000Z",
    "requestId": "550e8400-e29b-41d4-a716-446655440001",
    "instanceId": "cmrz4d1v20000cghx8k6p3m7t"
  }
}
```

## Error Codes

| Code | HTTP | Cause |
| - | - | - |
| `VALIDATION_ERROR` | `400` | `templateId` is longer than 100 characters |
| `TEMPLATE_ARCHIVE_FAILED` | `400` | The template could not be archived 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` | The template is still bound to a published, non-customised market or to a standing policy. `error.details` names them |
| `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.