Log inCreate account
DEVELOPER CENTER

Documentation.

From your form to DOCX. Learn how to connect your application to Onlinedisken.

Integration reference

This guide is based on the source code of Convert to Word Studio 1.0.2. It describes this plugin version specifically, not the older Convert to Word plugin. Test your integration against the version deployed on your WordPress installation.

01 / INTRODUCTION

Overview

Onlinedisken turns structured form data into editable DOCX documents. Your application collects data, sends a JSON request, and uses a document template configured in the document engine.

01Your formCollect data
02REST APISend JSON
03DOCXGenerate document
02 / SETUP

Quick start

  1. Sign in to WordPress and open Convert to Word Studio to manage your own templates and API key.
  2. Create or select an active template and note its API slug. The plugin includes an example letter template with fields such as overskrift, navn, dato and indhold.
  3. Generate an API key in Studio and save it in a secure server-side secret store. You will only see the full key at generation time.
  4. Call GET /status or GET /templates to test credentials and discover template fields.
  5. Send a JSON body with a template slug and matching top-level fields to POST /create.
  6. Decode the base64 response into a .docx file, or request direct download.
03 / ACCESS

Authentication

All four API endpoints require HTTPS, an active API key and appropriate WordPress capabilities. Pass the key through one of these supported methods. No API username header is required.

HTTP headers
X-CTWS-API-Key: YOUR_API_KEY
Accept: application/json

Alternatively: Authorization: Bearer YOUR_API_KEY. For JSON POST requests, use Content-Type: application/json. A Studio account has one API key at a time; regenerating it replaces the previous key.

04 / ENDPOINT

Check API status

Returns the product version, server component availability and active templates belonging to the API key owner.

GET/wp-json/convert-to-word-studio/v1/status
cURL
curl 'https://YOUR-DOMAIN/wp-json/convert-to-word-studio/v1/status' \
  -H 'Accept: application/json' \
  -H 'X-CTWS-API-Key: YOUR_API_KEY'

Response fields: status (ok), product, version, generated_at (ISO 8601), ziparchive (boolean), domdocument (boolean), and templates (array of name, slug, version).

05 / DISCOVERY

Templates and fields

Only the authenticated user's active templates are listed. Use this endpoint to discover field names and input requirements instead of guessing.

GET/wp-json/convert-to-word-studio/v1/templates
cURL
curl 'https://YOUR-DOMAIN/wp-json/convert-to-word-studio/v1/templates' \
  -H 'X-CTWS-API-Key: YOUR_API_KEY'

The JSON response contains status: "ok" and a templates array. Each template has name, slug, description, version and fields. Each field exposes key, label, type, required and options.

Supported field types

text, textarea, richtext, date, number, boolean, email, url, select and multiselect. Dates use YYYY-MM-DD. Select values must match the configured options; multiselect accepts an array or comma-separated values.

Within the Studio document editor, insert placeholders such as ${navn}; conditional content supports {{#if navn}}...{{/if}} and {{#unless navn}}...{{/unless}}.

06 / GENERATION

Create a DOCX document

Send the active template slug as template (or template_slug) and its field values at the top level. This example uses the built-in sample letter template's field names; obtain the actual slug from /templates.

POST/wp-json/convert-to-word-studio/v1/create
cURL
curl -X POST 'https://YOUR-DOMAIN/wp-json/convert-to-word-studio/v1/create' \
  -H 'Content-Type: application/json' \
  -H 'X-CTWS-API-Key: YOUR_API_KEY' \
  -d '{
    "template": "YOUR_ACTIVE_TEMPLATE_SLUG",
    "overskrift": "Example letter",
    "navn": "Example ApS",
    "dato": "2026-10-13",
    "indhold": "<p>Document text</p>",
    "filename": "example-letter.docx"
  }'

Successful JSON response: status: "success", filename, template (slug), document_id (may be null when not archived), and base64 containing the document bytes. Invalid input returns a WordPress REST error, not this success schema.

Required fields

Each template defines its own required fields and defaults. Unknown fields are ignored during document data normalization. You may optionally send filename to request a different filename.

07 / DOCUMENTS

Merge DOCX files

Merge between 2 and 20 existing DOCX files. Send each input document as Base64 in an array using content or base64. The result is a new DOCX file.

POST/wp-json/convert-to-word-studio/v1/merge
JSON body
{
  "filename": "combined.docx",
  "files": [
    {"base64": "BASE64_OF_FIRST_DOCX"},
    {"base64": "BASE64_OF_SECOND_DOCX"}
  ]
}

Send this body as JSON with the API key header. The files array may also be the top-level JSON body. The successful JSON response includes status, filename, document_id and base64. Inputs must be valid DOCX files; raw PDF or DOC files are not supported by this endpoint.

08 / OUTPUT

Download formats

By default, /create and /merge return JSON with Base64-encoded DOCX bytes. Decode the base64 value in your server application and write it to a .docx file.

For a direct binary DOCX response, add ?download=1 to the URL or send Accept: application/vnd.openxmlformats-officedocument.wordprocessingml.document. The response then uses the DOCX content type and a file attachment disposition rather than JSON.

09 / OPERATION

Limits and storage

Rate limit120 logged API calls per rolling 60 seconds per user; excess requests return HTTP 429.
Create bodyMaximum 2 MiB.
Merge bodyMaximum 64 MiB; 2–20 documents, with a 16 MiB Base64 string limit per input.
Document archive0–365 days, 30 days by default; files above 10 MiB are not stored in the document history.
API logRetained for 90 days; request bodies and document contents are not recorded.

These are plugin-level limits. The monthly limits shown on Onlinedisken pricing plans are not enforced by this plugin version on their own.

10 / SUPPORT

Troubleshooting and error codes

400ctws_invalid_request — invalid JSON/body, missing template field or invalid template field values. ctws_https_required — insecure transport.
401ctws_unauthorized — invalid, disabled or missing API key.
403ctws_forbidden — account lacks the required Studio capability.
404ctws_template_not_found — template not found or inactive.
413ctws_request_too_large — request body exceeds the endpoint limit.
429ctws_rate_limited — too many calls within the rate-limit window.
500ctws_create_error / ctws_merge_error — server-side document generation/failure.

WordPress REST errors typically include code, message and data.status. Log the HTTP status and safe error code; never log live keys or document contents.

11 / BEST PRACTICES

Security

Keep your API key server-side, never in public JavaScript or a publicly distributed app. Use HTTPS. A key identifies its owner; clients cannot impersonate another user using a user-ID field. Treat generated document contents as confidential. Rotate the key if compromised and store only the new key in your application's secrets.

Requirements: WordPress 6.0+, PHP 8.0+, and the PHP ZipArchive and DOMDocument extensions.

12 / REFERENCE

API reference

GET/wp-json/convert-to-word-studio/v1/statusStatus and active template summaries
GET/wp-json/convert-to-word-studio/v1/templatesActive template schemas
POST/wp-json/convert-to-word-studio/v1/createGenerate a DOCX from a template
POST/wp-json/convert-to-word-studio/v1/mergeMerge 2–20 DOCX files

Source: Convert to Word Studio 1.0.2, includes/class-ctws-api.php, includes/class-ctws-db.php, includes/class-ctws-document-service.php and the bundled README. Documentation is version-specific.

Ready to create documents?

Start with an account and connect your first form.

Create account →