Documentation.
From your form to DOCX. Learn how to connect your application to Onlinedisken.
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.
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.
Quick start
- Sign in to WordPress and open Convert to Word Studio to manage your own templates and API key.
- Create or select an active template and note its API slug. The plugin includes an example letter template with fields such as
overskrift,navn,datoandindhold. - 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.
- Call
GET /statusorGET /templatesto test credentials and discover template fields. - Send a JSON body with a
templateslug and matching top-level fields toPOST /create. - Decode the
base64response into a.docxfile, or request direct download.
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.
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.
Check API status
Returns the product version, server component availability and active templates belonging to the API key owner.
/wp-json/convert-to-word-studio/v1/statusResponse fields: status (ok), product, version, generated_at (ISO 8601), ziparchive (boolean), domdocument (boolean), and templates (array of name, slug, version).
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.
/wp-json/convert-to-word-studio/v1/templatesThe 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.
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}}.
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.
/wp-json/convert-to-word-studio/v1/createSuccessful 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.
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.
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.
/wp-json/convert-to-word-studio/v1/mergeSend 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.
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.
Limits and storage
These are plugin-level limits. The monthly limits shown on Onlinedisken pricing plans are not enforced by this plugin version on their own.
Troubleshooting and error codes
ctws_invalid_request — invalid JSON/body, missing template field or invalid template field values. ctws_https_required — insecure transport.ctws_unauthorized — invalid, disabled or missing API key.ctws_forbidden — account lacks the required Studio capability.ctws_template_not_found — template not found or inactive.ctws_request_too_large — request body exceeds the endpoint limit.ctws_rate_limited — too many calls within the rate-limit window.ctws_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.
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.
API reference
/wp-json/convert-to-word-studio/v1/statusStatus and active template summaries/wp-json/convert-to-word-studio/v1/templatesActive template schemas/wp-json/convert-to-word-studio/v1/createGenerate a DOCX from a template/wp-json/convert-to-word-studio/v1/mergeMerge 2–20 DOCX filesSource: 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.
Start with an account and connect your first form.
Create account →