DS DS Templates

Partner Documentation

Enter your credentials to access the integration guide.

Confidential — for integration partners only

DS DS Templates
Docs Integration Guide
v1.0
Integration Guide

Template Editor API Integration

Integrate the DS Templates platform into your CMS — provide your users with a complete template library, editor, and template management, fully white-labeled under your own domain.

REST API JWT Auth PostMessage Iframe White-label
Confidential - Reference integration

This document is confidential and intended for DS Templates integration partners only. It describes a reference integration and serves as a practical example of how the DS Templates platform can be embedded into a CMS. Every CMS provider has a unique architecture — we work closely with each partner to determine the optimal integration approach. The endpoints, data flows, and authentication methods can be adapted to your platform's needs.

Contact us to discuss how we can tailor the integration to your platform.

Core Components

The integration consists of three main components that together provide a complete template experience for your users.

ComponentTypeDescription
Template LibraryAPIRetrieve all available templates with previews, thumbnails, and categories to present to your users
Template EditorIframeEmbedded editor where users customise templates with their own content
User TemplatesAPIRetrieve saved templates per user — the "My Templates" overview

User Flow

The typical end-user journey follows four steps. Your CMS controls the UI; DS Templates provides the data and editor.

1 Browse Template Library
GET /templates
2 Select & Preview Template
editor iframe
3 Edit Template in Editor
save-complete event
4 Saved to "My Templates"
GET /user/templates
Display in CMS playout / scheduling

White-label & Custom Domain

All DS Templates URLs can be served from your own domain. Your end-users will never see or find the DS Templates brand.

Default URLYour domain
https://content.ds-templates.com/...https://templates.yourcms.com/...
https://api.dstemplates.nl/v1/...https://api.yourcms.com/templates/...
Setup

White-label is configured by pointing a CNAME record to our servers. We handle SSL certificates automatically. Contact us to set up your custom domain.

Authentication

Authentication is handled via JWT tokens. Your CMS backend requests a token for a specific user, and that token is used for all subsequent API calls and to load the editor iframe.

Roles

RolePermissions
viewerBrowse templates, view previews
editorBrowse, edit, save, and manage own templates
adminFull access including user management

Generate JWT Token

Your CMS backend requests a JWT token for a specific user. This token is then used for all authenticated operations.

POST/auth/token
Request body
AuthTokenRequest
json
{
    "external_user_id": "cms-user-456",
    "account_id": "company-123",
    "role": "editor"
}
FieldTypeRequiredDescription
external_user_idstringYesThe user's ID in your CMS
account_idstringYesThe account/company ID in DS Templates
rolestringYesOne of: admin, editor, viewer
Response
200 OK
json
{
    "jwt_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "expires_in": 3600
}
Note

Tokens are valid for 3600 seconds (1 hour). Implement token caching and refresh logic server-side. The JWT token is used both as a Bearer token for API calls and as a query parameter to load the editor iframe.

Manage Sub-users

Provision sub-users with specific roles for an account. Existing users (matched by external_user_id) are skipped.

POST/accounts/{account_id}/subusers
Path parameters
ParameterTypeDescription
account_idstringThe account/company ID
Request body
Subusers Request
json
{
    "subusers": [
        {
            "external_user_id": "cms-user-456",
            "email": "user@company.com",
            "role": "editor"
        },
        {
            "external_user_id": "cms-user-789",
            "email": "admin@company.com",
            "role": "admin"
        }
    ]
}
Response
200 OK
json
{
    "success": true,
    "created": 2,
    "skipped": 0
}

Template Library

Retrieve all available templates to display in your CMS. This powers the template browser/library where users choose a template to edit.

GET/templates
Query parameters
ParameterTypeRequiredDescription
categorystringNoFilter by category
responsivebooleanNoFilter by responsive support
Response
200 OK
json
[
    {
        "template_id": "abc123",
        "preview_url": "https://content.ds-templates.com/template/abc123/preview",
        "editor_url": "https://content.ds-templates.com/editor/abc123",
        "thumbnail_url": "https://content.ds-templates.com/template/abc123/thumbnail.jpg",
        "category": "Information",
        "responsive": true,
        "is_active": true
    },
    {
        "template_id": "def456",
        "preview_url": "https://content.ds-templates.com/template/def456/preview",
        "editor_url": "https://content.ds-templates.com/editor/def456",
        "thumbnail_url": "https://content.ds-templates.com/template/def456/thumbnail.jpg",
        "category": "Promotion",
        "responsive": false,
        "is_active": true
    }
]

Use the thumbnail_url and preview_url to build your template library UI. The editor_url is used to load the editor iframe for the selected template.

User Templates

Retrieve all saved templates for the authenticated user. This powers the "My Templates" view in your CMS.

GET/user/templates
Authentication

Requires a valid JWT token as Bearer token in the Authorization header.

Response
200 OK
json
[
    {
        "template_id": "xyz789",
        "template_url": "https://content.ds-templates.com/template/xyz789",
        "preview_url": "https://content.ds-templates.com/template/xyz789/preview",
        "duration": 15,
        "thumbnail_url": "https://content.ds-templates.com/template/xyz789/thumbnail.jpg",
        "creator": "Jan Jansen",
        "last_edit": "2025-11-01T12:00:00Z",
        "ratio": "16:9",
        "language": "nl"
    }
]

The template_url points to the live renderable version of the saved template. Use this URL in your CMS playout or scheduling system. The preview_url provides a static preview.

Editor Iframe

The template editor is loaded in an iframe. The editor_url from the template library response is used as the iframe source, with the JWT token appended as a query parameter.

URL format
Editor URL
url
{editor_url}?token={jwt_token}
Note

The editor_url is returned by the GET /templates endpoint for each template. Append the user's JWT token as a query parameter. The editor handles all template editing, auto-saving, and preview generation within the iframe.

Embedding example

HTML
html
<div class="editor-container" style="width:100%;height:100vh">
    <iframe
        id="template-editor"
        src="https://content.ds-templates.com/editor/abc123?token={jwt_token}"
        style="width:100%;height:100%;border:none"
        allow="clipboard-write"
    ></iframe>
</div>

PostMessage Communication

The editor communicates bidirectionally with the parent window using the PostMessage API. Always validate event.origin before processing messages.

Editor → Parent Events

EventDescriptionPayload
readyEditor loaded and readyEditor metadata
form-changedUser made unsaved changes
preview-data-updatedPreview refreshed{ previewUrl }
save-startedSave operation initiated
save-completeTemplate saved successfully{ templateId, previewKey }
save-errorSave operation failed{ error }
aspect-ratio-changedTemplate dimensions changed{ aspectRatio }

Example: save-complete

Event payload
json
{
    "type": "save-complete",
    "data": {
        "templateId": "xyz789",
        "message": "Template saved successfully",
        "previewKey": "bb2534b15e5cca2de323c60aa44201f9"
    }
}

Parent → Editor Commands

CommandDescription
saveTrigger save operation programmatically

Event listener example

PostMessage handler
javascript
const ORIGIN = 'https://content.ds-templates.com';
const editor = document.getElementById('template-editor');

window.addEventListener('message', (event) => {
    if (event.origin !== ORIGIN) return;

    const { type, data } = event.data;

    switch (type) {
        case 'ready':
            console.log('Editor ready');
            break;

        case 'save-complete':
            console.log('Template saved:', data.templateId);
            // Refresh your "My Templates" list
            refreshUserTemplates();
            break;

        case 'save-error':
            console.error('Save failed:', data.error);
            break;
    }
});

// Trigger save from your CMS UI
function triggerSave() {
    editor.contentWindow.postMessage(
        { type: 'save' }, ORIGIN
    );
}

Additional Endpoints

Beyond the core endpoints documented above, DS Templates can provide additional API endpoints tailored to your platform. These capabilities are available on request and determined in collaboration with each CMS provider based on your specific requirements.

CapabilityDescriptionDirection
WebhooksReal-time HTTP callbacks for template events (saved, published, deleted)DS Templates → CMS
Content syncPush or pull content data between platforms for seamless updatesBidirectional
Asset managementUpload and manage media assets (images, videos, fonts) per customerBidirectional
Template categoriesManage and customise template categories for your platformCMS → DS Templates
AnalyticsUsage statistics per template, user, and accountDS Templates → CMS
Bulk operationsCreate, update, or delete multiple user templates in a single requestCMS → DS Templates
Tailored integration

We analyse your platform's architecture and user workflows to design an integration that feels native to your product. The endpoints, data models, and communication patterns are fully customisable. Contact our integration team to get started.

Data Models

Reference for all data objects returned by the API.

Template (library item)

FieldTypeDescription
template_idstringUnique template identifier
preview_urlstring (URI)URL to preview the template
editor_urlstring (URI)URL to load the editor for this template
thumbnail_urlstring (URI)Thumbnail image URL
categorystringTemplate category
responsivebooleanWhether the template is responsive
is_activebooleanWhether the template is currently active

MyTemplate (saved user template)

FieldTypeDescription
template_idstringUnique saved template identifier
template_urlstring (URI)URL to the live renderable template
preview_urlstring (URI)URL to preview the saved template
durationintegerLoop duration in seconds
thumbnail_urlstring (URI)Thumbnail image URL
creatorstringName of the template creator
last_editdatetimeLast edit timestamp (ISO 8601)
ratiostringAspect ratio: 16:9, 9:16, 4:3, 1:1
languagestringLanguage code: nl, en-US, de, fr, etc.

Error Handling

All API endpoints return standard HTTP status codes with a consistent JSON error format.

CodeMeaningCommon cause
200SuccessRequest processed successfully
201CreatedResource created successfully
400Bad RequestMissing or invalid parameters
401UnauthorizedMissing or invalid JWT token
403ForbiddenInsufficient role/permissions or inactive licence
404Not FoundTemplate or resource does not exist
429Too Many RequestsRate limit exceeded
500Server ErrorInternal error — contact support

Error response format

Error response
json
{
    "code": 401,
    "message": "JWT token missing or invalid"
}
Recommendation

Implement retry logic with exponential backoff for 429 and 5xx responses. For 401 errors, request a new JWT token and retry the original request.

Rate Limiting

API requests are rate-limited per account to ensure fair usage and platform stability. Exact limits are configured per partner and may differ from the defaults shown below.

EndpointLimitWindow
/auth/token60 requestsPer minute
/accounts/{id}/subusers30 requestsPer minute
All other endpoints120 requestsPer minute
Rate limit headers
http
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 115
X-RateLimit-Reset: 1708300800

Security Best Practices

Follow these recommendations to ensure a secure integration.

  • Server-side token generation — always request JWT tokens from your backend. Never expose your API credentials in client-side code.
  • Token handling — pass the JWT token to the client only via the iframe URL query parameter. Do not store tokens in localStorage or cookies.
  • Validate PostMessage origin — always verify event.origin before processing any message from the editor iframe.
  • HTTPS only — all communication must use HTTPS. HTTP requests are rejected.
  • Principle of least privilege — assign users the minimum required role (viewer, editor, admin).
  • Credential rotation — contact DS Templates to issue new credentials if you suspect a compromise.