Dielines API: how to create 3D mockups

The Dielines API lets you generate dielines and create interactive 3D mockups programmatically. This post walks through the full flow, from your first sandbox request to a hosted, rotatable mockup page.

If you prefer to watch first, here is a recent screencast that demonstrates the entire process end to end:

A note on tooling

The examples below use curl, which is a command you run in a terminal (Terminal on macOS or Linux, Command Prompt or PowerShell on Windows). curl is built into all modern versions of these operating systems.

If you would rather use a graphical client, paste the same URL, headers, and body into Postman or Insomnia. Both are free and friendlier for first-time API testing.

Use the Sandbox to test for free

The Sandbox environment uses the same API key as production, but requests do not consume credits. The free demo template (becf-11f08) accepts custom dimensions and is the right way to try the API end to end. Other templates on the Sandbox return dielines in their default options — to generate custom dielines from any other template, you will need API credits and the production endpoint.

  • Sandbox base URL: https://sandbox.api.diecuttemplates.com
  • Production base URL: https://api.diecuttemplates.com

The following request uses our free demo template (becf-11f08) to generate a dieline PDF:

curl -X POST \
  https://sandbox.api.diecuttemplates.com/dieline-templates/becf-11f08/dielines \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Dielines-Api-Version: 1.0" \
  -d '{
    "format": "pdf",
    "variables": {
      "unit": "mm",
      "material": 0.5,
      "length": 100.0,
      "width": 50.0,
      "height": 150.0,
      "dimension_texts": false
    }
  }'

The response contains a dieline id (for example di_ueipnpyp0rlw) and a download URL for the PDF. You will need this id in the next step.

Full documentation, the list of available templates, and every variable you can set live here: Dielines API — Getting Started.

Two steps to a 3D mockup

Creating a mockup is a two-step flow:

  1. Generate a dieline and keep the returned id.
  2. Upload your print-ready artwork to that dieline.

Step 1 — Generate the dieline

Use the request shown above. Save the dieline id from the response.

Step 2 — Upload the artwork

Post your artwork file to the dieline you just created:

curl -X POST \
  https://sandbox.api.diecuttemplates.com/dielines/di_ueipnpyp0rlw/3d-mockups \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Dielines-Api-Version: 1.0" \
  -F "file=@/path/to/your/artwork.pdf" \
  -F "name=My Design" \
  -F "outside_design=true"

Accepted artwork formats: PDF, PNG, JPEG, SVG. The response returns the 3D mockup id and a hosted URL such as https://www.diecuttemplates.com/3d/llnmb1oh8r — open it to see what a live mockup page looks like.

Listing mockups for a dieline

You can list all mockups attached to a dieline:

curl -X GET \
  https://sandbox.api.diecuttemplates.com/dielines/di_ueipnpyp0rlw/3d-mockups \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Dielines-Api-Version: 1.0"

Premium subscription vs. API credits

These are two separate products:

  • The Premium website subscription gives unlimited access on diecuttemplates.com — dieline downloads, nesting, the manufacturing cost calculator, 3D previews, and so on. It does not include API access or API credits.
  • The Dielines API is billed separately, in credits. You can either buy a one-time credit pack or subscribe monthly. Pricing details are here: API pricing.

Sandbox testing is always free, regardless of which product you have — so you can build and verify your entire integration before purchasing any credits.

Putting it all together

The API portion of a 3D mockup pipeline is just two requests:

  1. POST /dieline-templates/{id}/dielines — returns a dieline id.
  2. POST /dielines/{id}/3d-mockups — returns a mockup id and a hosted URL.

If you hit anything specific while testing in the Sandbox, send us the request you are making and the response you are getting and we will take a look.