Skip to content

CDN

Contentrain Studio includes a built-in Content Delivery Network for serving your published content through a fast, public API. The CDN builds optimized content from your Git repository and serves it through edge infrastructure.

Managed service / Enterprise Edition

The CDN is an Enterprise Edition feature, gated by the cdn.delivery plan feature and backed by Cloudflare R2 storage. It is available on Contentrain's managed service (Starter plans and above) and on self-hosted Enterprise Edition deployments. It is not available in the self-hosted Community Edition, which has no CDN storage backend.

How the CDN Works

Git Repository → Build Pipeline → CDN Storage → Public API
  1. Content is committed to your repository through Studio
  2. A build is triggered (manually or automatically after a merge)
  3. The build pipeline reads content, filters by status (published only), and serializes to optimized JSON
  4. Content is uploaded to CDN storage
  5. Consumers fetch content through the public delivery endpoint

Enabling CDN

CDN is available on Starter plans and above. To enable it for a project:

  1. Open the project sidebar
  2. Click CDN to open the CDN panel
  3. Toggle Enable CDN in the settings
  4. Create an API key for authentication

The CDN Delivery panel: enable toggle, API keys with scopes, key permissions, and build history

API Key Management

CDN access requires an API key. Keys are used in the Authorization header of requests to the delivery endpoint.

Creating a Key

  1. In the CDN panel, navigate to the Keys section
  2. Click Create key
  3. Enter a descriptive name for the key
  4. The key is generated and shown once — copy it immediately

WARNING

API keys are shown only once at creation time. Studio stores only the SHA-256 hash of the key. If you lose the key, you must create a new one.

Key Format

CDN API keys follow the format:

crn_live_{random-base62-string}

Example: crn_live_7K2mX9pQ4rT6vW3nY8sB1hJ5

Deleting a Key

To revoke access, delete the key from the CDN panel. This takes effect immediately — any requests using the deleted key will receive a 401 Unauthorized response.

Public Delivery Endpoint

Content is served through a REST-style endpoint:

GET /api/cdn/v1/{projectId}/{path}
Authorization: Bearer crn_live_...

Path Structure

Objects are keyed by model ID (the domain is not part of the CDN path — it is written flat by the build pipeline):

PathReturns
content/{modelId}/{locale}.jsonPublished entries for an i18n collection/singleton/dictionary, by locale
content/{modelId}/data.jsonPublished entries for a non-i18n model
documents/{modelId}/{slug}/{locale}.jsonA single document entry
models/{modelId}.jsonA model definition
models/_index.jsonSummary index of all models
_manifest.jsonBuild manifest (commit SHA, locales, domains, model list)

For example, the English entries of a blog-post collection are served at content/blog-post/en.json.

Response Format

The endpoint returns the raw published-content JSON file straight from CDN storage, with Content-Type: application/json and an ETag header (conditional If-None-Match requests return 304). Collection and singleton files are an object map keyed by entry ID, containing only entries with published status:

json
{
  "a1b2c3d4e5f6": {
    "title": "Hello World",
    "slug": "hello-world",
    "body": "..."
  },
  "g7h8i9j0k1l2": {
    "title": "Second Post",
    "slug": "second-post",
    "body": "..."
  }
}

Authentication

All CDN requests require a valid API key in the Authorization header:

bash
curl -H "Authorization: Bearer crn_live_..." \
  https://your-studio.com/api/cdn/v1/{projectId}/content/blog-post/en.json

Build Pipeline

Triggering a Build

Builds can be triggered in two ways:

  1. Manual trigger — Click Trigger Build in the CDN panel
  2. Automatic — After a branch merge completes (when configured)

Build Process

Each build:

  1. Reads the latest content from your Git repository
  2. Loads all model definitions
  3. Filters content entries to include only published status
  4. Serializes Markdown content to HTML (for document models)
  5. Uploads optimized JSON to CDN storage
  6. Cleans up stale files from previous builds

Build Results

After a build completes, you can see:

FieldDescription
buildIdUnique build identifier
commitShaThe Git commit the build was created from
filesUploadedNumber of content files processed
filesDeletedNumber of stale files removed
totalSizeBytesTotal size of the uploaded content
changedModelsWhich models had content changes
durationMsBuild duration in milliseconds

Build History

The CDN panel shows a history of recent builds with their status, timing, and output details.

TIP

If content looks stale on the CDN, trigger a manual build to ensure the latest published content is served.

CDN Security

  • API key authentication — Every request must include a valid key
  • Rate limiting — Requests are rate-limited per key (configurable per plan)
  • Allowed origins — Configure CORS origins per API key for browser-based access
  • Published only — The CDN only serves entries with published status; draft, archived, and rejected content is never exposed

Plan Limits

FeatureFreeStarterProEnterprise
CDN deliveryNoYesYesYes
API keys0310Unlimited
Bandwidth02GB/mo20GB/moUnlimited
Preview branchesNoNoYesYes
Custom domainNoNoNoYes

Next Steps

Released under the AGPL-3.0 License.