There are three ways to show a LegalCloud document in your application. This page compares them and shows how to use each one.
The public address
Every published document has a public address:
https://dash.legalcloud.info/d/{hash}
The {hash} is returned by the API in the public_url of the document (/d/{hash}) and is shown in the document detail of the dashboard. The lang query parameter selects the language of the page and its messages (?lang=en).
Option 1 — iframe
The simplest option and the one that always shows the latest published version:
<iframe
src="https://dash.legalcloud.info/d/{hash}?lang=en"
width="100%"
height="600"
frameborder="0"
title="Privacy Policy"
></iframe>
If the document requires a token, add a document token (&token=…). It can open that one document and nothing else. Use the narrowest token possible: the address, and therefore the token, appears in server logs and browser history.
Option 2 — Server-side render
Fetch the HTML on your server and print it inside your page (better for SEO, no iframe). With the SDKs (getDocument / get_document):
const html = await client.getDocument("abc123def456", "en");
or with plain HTTP:
curl -H "Authorization: Bearer YOUR_TOKEN" \
"https://dash.legalcloud.info/d/{hash}?lang=en"
Cache the result for a few minutes on your side to avoid a request per visitor. Remember that calls made with an API token count against the quota of your plan.
Alternatively read the content through the API (GET https://api.legalcloud.info/api/documents/{id} returns the HTML in data.content); see Document endpoints.
Option 3 — Plugins
For WordPress and Odoo use the official plugins (downloaded from your dashboard): see Plugins overview.
Analytics headers
When your server requests the document, send these headers so that your dashboard shows where each visit comes from:
| Header | Value |
|---|---|
X-LegalCloud-Source | wordpress, odoo, drupal, magento, prestashop, shopify or custom |
X-LegalCloud-Site | The URL of your website |
X-LegalCloud-Plugin-Id | A stable unique id of your installation |
X-LegalCloud-Version | The version of your integration |
The SDKs send them automatically, and publicUrl / iframeHtml build the public address and the iframe tag for you (includeToken: false leaves the token out of the address for public documents). Source and top-sites breakdowns are available from the Silver plan.
Access rules
A document can be limited to certain countries and to certain sites, and can require a token. When a visitor is not allowed the page answers 403, when the token is missing or wrong it answers 401 and when the document does not exist or is not published it answers 404 (see Errors reference). To check beforehand whether a visitor would be allowed, call GET /d/{hash}/restrictions?country=ES.