RESOURCE | Dielines

POST '/dieline-templates/{id}/dielines'

Create a custom dieline with the given request parameters.

Request Parameters

id string Unique identifier for the template. required
For example: "becf-10319"
Dieline template ids start with "becf".
Available dieline templates are listed on https://www.diecuttemplates.com/dielines
format string File format. required
Valid values are: "dxf", "pdf", "svg"
pdf_header boolean Only applicable when the 'format' is 'pdf'.
When set to 'true', it adds a header to the pdf document. This header includes dieline template variables.
Valid values are: true, false
Default value: true
area boolean When set to 'true', the area of the dieline is calculated and the result is included in the response.
Please note that area calculation is only supported for templates in "Cartons" and "Corrugated cardboards" groups.
Valid values are: true, false
Default value: false
variables object Key-value pairs including values for "dieline template variables" that define the dimensions for creating the custom dieline.
unit enum Unit required
Possible values are:
"mm"
"in"
material decimal Material thickness. For example 1.23
{dieline_template_variable_name} string

Dieline template specific dieline template variable names.
For example a, b, top_tuck_flap
value for the {dieline_template_variable_name}
For example 100.00

Response Object

Returns a "dieline" object.

Objects | dieline

type string "dieline"
id string Unique identifier for custom dieline
"di_fwe4iu3vngty"
dieline_template_id string Unique identifier for the dieline template.
Example: "becf-10301"
variables object Key-value pairs including values for "dieline template variables" that define the dimensions when the custom dieline was generated.
unit enum Unit required
Possible values are:
"mm"
"in"
material decimal Material thickness. For example 1.23
{dieline_template_variable_name} string

Dieline template specific dieline template variable names.
For example a, b, top_tuck_flap
value for the {dieline_template_variable_name}
For example 100.00
format string File format. "dxf", "pdf" or "svg"
url URL URL for the dieline. The custom dieline can be downloaded directly from this link.
artwork_dimensions width and height This is the dimensions for uploading artwork to create a 3D Mockup. The image file doesn't need to be in this exact dimensions but it should have the same aspect ratio.
area The area of the dieline.
This information is only included in the result if area_calculation is set to true.
For example:
{
  "value": 200000,
  "unit": "mm2"
} 

Possible "unit" values are: "mm2" for "square millimeters".
links [dieline_link]
created_at DateTime For example: 2024-11-25T10:00:00Z


Code Examples


curl -i -X POST \
https://api.diecuttemplates.com/dieline-templates/becf-10301/dielines\
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <YOUR_DIELINES_API_KEY_HERE>" \
  -d '{
  "format": "pdf",
  "variables": {
    "unit": "in",
    "material": 0.11,
    "length": 4.25,
    "width": 3.0,
    "height": 5.0,
    "top_tuck_flap": 0.53
  }
}'

require 'uri'
require 'net/http'
require 'openssl'

url = URI('https://api.diecuttemplates.com/dieline-templates/becf-10301/dielines')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request['Content-Type'] = 'application/json'
request['Dielines-Api-Version'] = '1.0'
request['Authorization'] = 'Bearer <YOUR_DIELINES_API_KEY_HERE>'
params = {
  "format": "pdf",
  "variables": {
    "unit": "in",
    "material": 0.11,
    "length": 4.25,
    "width": 3.00,
    "height": 5.00,
    "top_tuck_flap": 0.53
  }
}

request.body = params.to_json

response = http.request(request)
puts response.read_body


$url = 'https://api.diecuttemplates.com/dieline-templates/becf-10301/dielines';
$data = [
    "format" => "pdf",
    "variables" => [
      "unit" => "in",
      "material" => "0.11",
      "length" => "4.25",
      "width" => "3.0",
      "height" => "5.0",
      "top_tuck_flap" => "0.53"
    ]
];

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer <YOUR_DIELINES_API_KEY_HERE>'
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    echo 'Response: ' . $response;
}

curl_close($ch);

Example Response, Status = 200

application/json
{
  "dieline": {
    "type": "dieline",
    "id": "ueipnpyp0rlw",
    "dieline_template_id": "becf-10301",
    "variables": {
      "unit": "mm",
      "length": 251.13,
      "width": 102,
      "height": 253,
      "material": 2.22
    },
    "format": "pdf",
    "url": "https://d2atdwxjx7uc4i.cloudfront.net/campaigns/0e9d742f-bdcd-4b41-8122-88e0426d263f20241218-14172-y29ocn.pdf",
    "artwork_dimensions": {
      "unit": "mm",
      "width": "723.06",
      "height": "502.44"
    },
    "area": {
      "unit": "mm2",
      "value": "11723.06"
    },
    "created_at": "2024-12-18T19:27:22Z"
  }
}

Error Response Object

message string High level error message.
Example: "Validation failed for one or more variables"
More detailed error messages can be included in the "errors" object.
errors object
message string Low level error message. (error message detail)
Example: "top tuck flap should be minimum 0.355in."
suggestion object Errors can include a suggession object.
type string Suggestion type.
Possible values are "change_value", "swap_values"
name string Name of the variable for "change_value" .
Only provided if suggestion type is "change_value"
Example: top_tuck_flap
value numeric Value of the variable for "change_value" .
Only provided if suggestion type is "change_value"
Example: 13.50
names array Names for "swap_values" .
Only provided if suggestion type is "swap_values"
Example: ["a", "b"]

Example Response, Status = 400, Bad Request

application/json
{
  "message": "Validation failed for one or more variables.",
  "errors": [
    {
      "message": "Invalid 'unit'. Valid 'unit' values are 'mm' and 'in'."
    }
  ]
}

Example Response, Status = 400, Bad Request

application/json
{
  "message": "Validation failed for one or more variables.",
  "errors": [
    {
      "message": "Based on the variables you provided, top tuck flap should be minimum 0.355in.",
      "suggestion": {
        "type": "change_value",
        "name": "top_tuck_flap",
        "value": 0.355
      }
    }
  ]
}

Example Response, Status = 400, Bad Request

application/json
{
  "message": "Validation failed for one or more variables.",
  "errors": [
    {
      "message": "The application expects the dimensions to be given in order of Length, Width and Height. A and B should swap places.",
      "suggestion": {
        "suggestion": {
          "type": "swap_values",
          "names": [
            "a",
            "b"
          ]
        }
      }
    }
  ]
}