Esta guía todavía no está traducida a tu idioma: se muestra en inglés.
The document endpoints let you list, create, update, publish and version documents. All of them require a token with the documents:read scope (reading) or documents:write (changes). {id} is the document id returned by the API.
Endpoints
| Method | Path | Scope | Description |
|---|---|---|---|
GET | /api/documents | read | List documents |
POST | /api/documents | write | Create a document |
GET | /api/documents/languages | read | Languages available to the organization |
GET | /api/documents/limits | read | Document usage and limit of your plan |
GET | /api/documents/{id} | read | Get a document |
PATCH | /api/documents/{id} | write | Update a document (send only the fields to change) |
DELETE | /api/documents/{id} | write | Delete a document |
POST | /api/documents/{id}/clone | write | Clone a document |
POST | /api/documents/{id}/publish | write | Publish a document |
POST | /api/documents/{id}/unpublish | write | Unpublish a document |
GET | /api/documents/{id}/versions | read | List versions |
GET | /api/documents/{id}/versions/{n} | read | Get one version |
GET | /api/documents/{id}/versions/diff?from=&to= | read | Compare two versions |
POST | /api/documents/{id}/versions/{n}/restore | write | Restore a version |
DELETE | /api/documents/{id}/versions/{n} | write | Delete a version |
The document object
| Field | Type | Description |
|---|---|---|
id | string | Identifier used by the API |
title | string | Internal title (max 200 characters) |
content | string | HTML body (only in detail responses) |
type | string | privacy, cookies, legal, terms, conditions or other |
language | string | Language code, for example en |
site_ids | array | Sites where it is published |
visible | boolean | Whether it is shown |
token_required | boolean | Whether /d/{hash} requires an access token |
allowed_countries | array | ISO country codes allowed (empty = all) |
inherit_styles | boolean | Inherit the style of the embedding site |
h1_color, h2_color, body_color, link_color | string | Optional colors |
has_token | boolean | Whether it has a document token |
public_url | string | Public path, for example /d/abc123 (detail only) |
created_at, updated_at | string | Dates |
List documents
curl -H "Authorization: Bearer YOUR_TOKEN" \
"https://api.legalcloud.info/api/documents?page=1&per_page=20&site_id=SITE_ID"
{
"success": true,
"data": {
"documents": [
{ "id": "514789b931ee4cc1", "title": "Privacy policy", "type": "privacy", "language": "en", "visible": true }
],
"total": 1,
"page": 1,
"per_page": 20
}
}
The list omits the content.
Create a document
curl -X POST https://api.legalcloud.info/api/documents \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Privacy policy",
"type": "privacy",
"language": "en",
"content": "<h1>Privacy policy</h1><p>...</p>",
"site_ids": [1]
}'
site_ids must contain at least one site. Creation is subject to the limits of your plan (documents and languages); when a limit is reached the API answers 403 with PLAN_UPGRADE_REQUIRED, LANGUAGE_LIMIT_REACHED or a similar code.
Get a document
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://api.legalcloud.info/api/documents/{id}
The detail includes content and public_url. The public address of the document is https://dash.legalcloud.info followed by public_url.
Update, publish and unpublish
curl -X PATCH https://api.legalcloud.info/api/documents/{id} \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"content": "<h1>Privacy policy v2</h1><p>...</p>"}'
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
https://api.legalcloud.info/api/documents/{id}/publish
When the content changes, a new version is stored (on plans with versioning).
Versions
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://api.legalcloud.info/api/documents/{id}/versions
curl -H "Authorization: Bearer YOUR_TOKEN" \
"https://api.legalcloud.info/api/documents/{id}/versions/diff?from=1&to=2"
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
https://api.legalcloud.info/api/documents/{id}/versions/1/restore
Public page of a document
GET https://dash.legalcloud.info/d/{hash}?lang=en returns the rendered HTML (no API token needed unless the document requires one). GET /d/{hash}/restrictions?country=ES tells you whether a visitor from that country would be allowed.
Statistics
Statistics are available under /api/statistics/* (see Viewing analytics).