Terms Library
Create Terms Template
Add a template to this instance’s terms library
POST
/
lending-external-securities-v2
/
api
/
markets
/
terms-library
curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/markets/terms-library" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"title": "Secured credit line, house terms",
"content": "# Terms of Use\n\n## 1. Lender of record\n\nACME Bank AG acts as lender of record for this market.\n"
}'
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',
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ title: 'Secured credit line, house terms', content })
}
);
const { success, data, error } = await res.json();
if (!success) throw new Error(`${error.code}: ${error.message}`);
const templateId = data.template.id;
{
"success": true,
"data": {
"template": {
"id": "cmwh2t9e10002l80d7s3k5m8c",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t",
"title": "Secured credit line, house terms",
"version": 1,
"contentHash": "0x9a8b7c6d5e4f30210fedcba98765432100112233445566778899aabbccddeeff",
"archived": false,
"archivedAt": null,
"createdBy": "cmrz3a8q10000cghxf5w2n9k4",
"updatedBy": "cmrz3a8q10000cghxf5w2n9k4",
"createdAt": "2026-11-10T08:15:00.000Z",
"updatedAt": "2026-11-10T08:15:00.000Z",
"contentBytes": 95,
"content": "# Terms of Use\n\n## 1. Lender of record\n\nACME Bank AG acts as lender of record for this market.\n",
"usage": {
"markets": 0,
"current": 0,
"outdated": 0,
"customised": 0,
"unpublished": 0
}
}
},
"error": null,
"metadata": {
"timestamp": "2026-11-10T08:15:00.000Z",
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t"
}
}
{
"success": false,
"data": null,
"error": {
"code": "TERMS_TOO_LARGE",
"message": "The terms document exceeds the 256 KB limit"
},
"metadata": {
"timestamp": "2026-11-10T08:16:12.000Z",
"requestId": "550e8400-e29b-41d4-a716-446655440001",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t"
}
}
Adds a terms of use template to this instance’s library and answers
201. The template starts at version 1 and is bound to nothing. Bind it to a market with Save Terms and templateId, or to a standing policy with termsTemplateId. This is a database write: nothing is signed and nothing goes on chain.
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. canAuthor on List Terms Templates says whether this account is one.
Body Parameters
Template title, 1 to 200 characters. Trimmed, must not be blank, and must not contain control characters, tab and newline included.
The document as markdown. Stored verbatim apart from Windows line endings, which become
\n. The stored text must fit in 262,144 bytes of UTF-8, must not be blank, and must not contain control characters other than tab, newline and carriage return.Response Fields
Show child attributes
Show child attributes
The new template with the fields of Get Terms Template except
versions and markets: content is included, and every usage count is 0.curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/markets/terms-library" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"title": "Secured credit line, house terms",
"content": "# Terms of Use\n\n## 1. Lender of record\n\nACME Bank AG acts as lender of record for this market.\n"
}'
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',
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ title: 'Secured credit line, house terms', content })
}
);
const { success, data, error } = await res.json();
if (!success) throw new Error(`${error.code}: ${error.message}`);
const templateId = data.template.id;
{
"success": true,
"data": {
"template": {
"id": "cmwh2t9e10002l80d7s3k5m8c",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t",
"title": "Secured credit line, house terms",
"version": 1,
"contentHash": "0x9a8b7c6d5e4f30210fedcba98765432100112233445566778899aabbccddeeff",
"archived": false,
"archivedAt": null,
"createdBy": "cmrz3a8q10000cghxf5w2n9k4",
"updatedBy": "cmrz3a8q10000cghxf5w2n9k4",
"createdAt": "2026-11-10T08:15:00.000Z",
"updatedAt": "2026-11-10T08:15:00.000Z",
"contentBytes": 95,
"content": "# Terms of Use\n\n## 1. Lender of record\n\nACME Bank AG acts as lender of record for this market.\n",
"usage": {
"markets": 0,
"current": 0,
"outdated": 0,
"customised": 0,
"unpublished": 0
}
}
},
"error": null,
"metadata": {
"timestamp": "2026-11-10T08:15:00.000Z",
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t"
}
}
{
"success": false,
"data": null,
"error": {
"code": "TERMS_TOO_LARGE",
"message": "The terms document exceeds the 256 KB limit"
},
"metadata": {
"timestamp": "2026-11-10T08:16:12.000Z",
"requestId": "550e8400-e29b-41d4-a716-446655440001",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t"
}
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
VALIDATION_ERROR | 400 | title or content is missing, empty or not a string, title is over 200 characters, or content is over 524,288 characters as sent. The document limit itself is measured after Windows line endings become \n, and answers TERMS_TOO_LARGE |
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 |
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 |
⌘I
curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/markets/terms-library" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"title": "Secured credit line, house terms",
"content": "# Terms of Use\n\n## 1. Lender of record\n\nACME Bank AG acts as lender of record for this market.\n"
}'
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',
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ title: 'Secured credit line, house terms', content })
}
);
const { success, data, error } = await res.json();
if (!success) throw new Error(`${error.code}: ${error.message}`);
const templateId = data.template.id;
{
"success": true,
"data": {
"template": {
"id": "cmwh2t9e10002l80d7s3k5m8c",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t",
"title": "Secured credit line, house terms",
"version": 1,
"contentHash": "0x9a8b7c6d5e4f30210fedcba98765432100112233445566778899aabbccddeeff",
"archived": false,
"archivedAt": null,
"createdBy": "cmrz3a8q10000cghxf5w2n9k4",
"updatedBy": "cmrz3a8q10000cghxf5w2n9k4",
"createdAt": "2026-11-10T08:15:00.000Z",
"updatedAt": "2026-11-10T08:15:00.000Z",
"contentBytes": 95,
"content": "# Terms of Use\n\n## 1. Lender of record\n\nACME Bank AG acts as lender of record for this market.\n",
"usage": {
"markets": 0,
"current": 0,
"outdated": 0,
"customised": 0,
"unpublished": 0
}
}
},
"error": null,
"metadata": {
"timestamp": "2026-11-10T08:15:00.000Z",
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t"
}
}
{
"success": false,
"data": null,
"error": {
"code": "TERMS_TOO_LARGE",
"message": "The terms document exceeds the 256 KB limit"
},
"metadata": {
"timestamp": "2026-11-10T08:16:12.000Z",
"requestId": "550e8400-e29b-41d4-a716-446655440001",
"instanceId": "cmrz4d1v20000cghx8k6p3m7t"
}
}
