A documentation workflow receives diagram images from an upload form. It needs an editable VSDX for engineering and a PPTX for a review deck. Treating conversion as a synchronous request makes the form wait and complicates recovery if the connection drops.
An asynchronous job workflow separates submission, progress, and artifact storage. The important implementation detail is keeping the returned job ID so you can inspect an existing conversion instead of creating another one.
Disclosure: this tutorial is prepared by the LayerBack team. The commands follow the documented API; they were not executed to create a paid conversion for this article.
Official diagram case illustrating input/output appearance, not an API response or evidence of an API run.
Keep authentication on the server
LayerBack's conversion API uses the x-api-key header. Keep the key in your server environment or secret store, not a public frontend bundle. Avoid logging request headers or temporary artifact URLs.
The following examples use LAYERBACK_API_KEY as an environment-variable placeholder. They do not contain a credential.
The API accepts raw PNG, JPEG, or WebP bytes. Website PDF-page selection is a separate browser workflow; do not assume the raw-image endpoint accepts PDF bytes.
Submit the source image
curl --fail-with-body --request POST \
'https://layerback.com/api/v1/convert' \
--header "x-api-key: ${LAYERBACK_API_KEY}" \
--header 'Content-Type: application/octet-stream' \
--data-binary '@diagram.png'
Read job_id from the JSON response and persist it with the source image's internal reference. Avoid including customer content in application logs.
If a POST times out after the server may have accepted it, do not immediately repeat it. The documented example does not establish an idempotency mechanism. Treat the outcome as uncertain and reconcile the job through your application records or support workflow before creating a duplicate.
Official diagram case illustrating input/output appearance, not an API response or evidence of an API run.
Track the existing job
Set LAYERBACK_JOB_ID to the returned ID, then request its state:
curl --fail-with-body \
"https://layerback.com/api/v1/jobs/${LAYERBACK_JOB_ID}" \
--header "x-api-key: ${LAYERBACK_API_KEY}"
Handle queued, running, succeeded, and failed explicitly. Use a bounded polling interval and a deadline; do not leave a worker in a tight infinite loop.
Inspect input_kind as well as status. A successful job can have different output behavior depending on whether the source was classified as a diagram, a document, or a photo. Success alone does not prove native diagram recovery.
Download and store the required artifacts
Only download after success and check the available formats. For VSDX:
curl --fail --location \
"https://layerback.com/api/v1/jobs/${LAYERBACK_JOB_ID}/download?format=vsdx" \
--header "x-api-key: ${LAYERBACK_API_KEY}" \
--output 'diagram.vsdx'
Redirect following is needed by the documented download flow. Verify returned files before moving them into durable storage. Use the same job for other available formats, such as PPTX or draw.io, rather than submitting the source again for each format.
Keep your API client aligned with the OpenAPI specification. Do not treat a short-lived download URL as a permanent link for readers.
Separate errors and completion notifications
Handle insufficient credits (402), excessive size (413), unsupported input (415), and rate limiting (429) differently. Validate obvious input mistakes before submission. Retry status reads with backoff when appropriate; do not apply the same blanket retry policy to conversion creation.
A public HTTPS callback_url can receive completion notifications. Use that notification to trigger a job-status check before treating work as complete. The documentation specifies limited delivery attempts, so retain a reconciliation path using the status endpoint.
Budget for API usage
The API currently uses 10 credits per conversion, includes all output formats, and refunds failed conversions. This is different from free website preview. The documented image limit is 20 MB, with a standard rate limit of 20 conversions per hour per account; check current API documentation before planning a batch.
Begin with a small integration and a human-review stage for labels and connectors. Automating delivery should not remove the quality checks your engineering documents require.


Top comments (0)