RESOURCE | Nestings

POST '/dielines/{dieline_id}/nestings/{nesting_template_id}'

Create a custom nesting (also known as imposition or layout) for a dieline with the given request parameters. A nesting arranges one or more dielines on a sheet according to the specified nesting template and sheet dimensions.

Request Parameters

dieline_id string The unique identifier of the dieline for which to create a nesting. This is the ID returned when creating a dieline.
Example: "di_ueipnpyp0rlw"
nesting_template_id string The unique identifier of the nesting template to use. required
This ID can be obtained from the nesting templates list endpoint.
Example: "lt_xyz123abc"
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 nesting information such as sheet dimensions and quantities.
Valid values are: true, false
Default value: true
variables object Key-value pairs including values for nesting template variables that define the sheet dimensions and arrangement for creating the custom nesting.
unit enum Unit required
Possible values are:
"mm"
"in"
sheet_width length Width of the sheet required
Example: 1000.00
sheet_height length Height of the sheet required
Example: 700.00
sheet_margin_top length Margin from the top edge of the sheet optional
Example: 15.00
Default is 0.00
sheet_margin_bottom length Margin from the bottom edge of the sheet optional
Example: 20.00
Default is 0.00
sheet_margin_side length Margin from both left and right edges of the sheet optional
Example: 10.00
Default is 0.00
num_x integer Number of dielines to arrange along the x-axis (width) optional
If not provided, the system will automatically calculate the optimal number.
Example: 3 If num_x is provided, num_y must also be provided.
num_y integer Number of dielines to arrange along the y-axis (height). optional
If not provided, the system will automatically calculate the optimal number.
Example: 2 If num_x is provided, num_y must also be provided.
{nesting_template_variable_name} varies Additional template-specific variables. Each nesting template may have its own set of optional variables such as rotation or other layout options. For example "margin_x", "margin_y" etc
These variables are listed in the nesting template object returned from the nesting templates list endpoint.

Response Object

Returns a "nesting" object.

Objects | nesting

This object represents a custom nesting (also known as imposition or layout), which is an arrangement of one or more dielines on a sheet according to specified dimensions and a nesting template.

type string "nesting"
id string Unique identifier for the nesting. For example : "ne_wpxjk9m2nlrw"
dieline_id string The unique identifier of the dieline that was nested. For example : "di_ueipnpyp0rlw"
dieline_template_id string The catalog identifier of the dieline template. For example : "becf-10301"
nesting_template_id string The unique identifier of the nesting template used to create this nesting. For example : "lt_xyz123abc"
variables object The variables used to create this nesting, including sheet dimensions, dieline variables and number of dielines used.
For example:
{
  "unit": "mm",
  "sheet_width": 1000.00,
  "sheet_height": 700.00,
  "sheet_margin_top": 15.00,
  "sheet_margin_bottom": 20.00,
  "sheet_margin_side": 10.00,
  "dieline_variables": {
    "unit": "mm",
    "width": 100,
    "height": 150,
    "length": 50,
    "material": "0.8"
  },
  "num_x": 3,
  "num_y": 2,
  "margin_x": 10,
  "margin_y": 20,
}
        
format string The file format of the nesting. Valid values: "pdf", "svg", "dxf"
width length The width of the nesting.
For example:
{
  "value": 990.00,
  "unit": "mm"
} 

Possible "unit" values are: "mm" or "in".
height length The height of the nesting.
For example:
{
  "value": 880.00,
  "unit": "mm"
} 

Possible "unit" values are: "mm" or "in".
nesting_overflow boolean Is set to "true" if the nesting does not fit the sheet.
sum_of_line_lengths array Sum of line lengths.
[
  {
    "name": "Cut",
    "unit": "mm",
    "value": 3000.00
  },
  {
    "name": "Crease",
    "unit": "mm",
    "value": 5000.00
  },
  {
    "name": "Total",
    "unit": "mm",
    "value": 8000.00
  }
] 
url string A URL to download the nesting file.
Example: "https://d2atdwxjx7uc4i.cloudfront.net/nestings/abc123.pdf"
created_at string ISO 8601 timestamp of when the nesting was created.
Example: "2024-12-18T19:27:22Z"


Code Examples


curl -i -X POST \
https://api.diecuttemplates.com/dielines/di_ueipnpyp0rlw/nestings/lt_xyz123abc\
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <YOUR_DIELINES_API_KEY_HERE>" \
  -H "Dielines-Api-Version: 1.0" \
  -d '{
  "format": "pdf",
  "variables": {
    "unit": "mm",
    "sheet_width": 1000.0,
    "sheet_height": 700.0,
    "sheet_margin_top": 15.0,
    "sheet_margin_bottom": 20.0,
    "sheet_margin_side": 10.0,
    "num_x": 3,
    "num_y": 2
  }
}'

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

url = URI('https://api.diecuttemplates.com/dielines/di_ueipnpyp0rlw/nestings/lt_xyz123abc')

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>'
# Note: margin_x and margin_y are optional - include only if your template requires them
params = {
  "format": "pdf",
  "variables": {
    "unit": "mm",
    "sheet_width": 1000.00,
    "sheet_height": 700.00,
    "sheet_margin_top": 15.00,
    "sheet_margin_bottom": 20.00,
    "sheet_margin_side": 10.00,
    "num_x": 3,
    "num_y": 2
  }
}

request.body = params.to_json

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


$url = 'https://api.diecuttemplates.com/dielines/di_ueipnpyp0rlw/nestings/lt_xyz123abc';
$data = [
    "format" => "pdf",
    "variables" => [
        "unit" => "mm",
        "sheet_width" => 1000.00,
        "sheet_height" => 700.00,
        "sheet_margin_top" => 15.00,
        "sheet_margin_bottom" => 20.00,
        "sheet_margin_side" => 10.00,
        "num_x" => 3,
        "num_y" => 2
    ]
];

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Dielines-Api-Version: 1.0',
    '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
{
  "nesting": {
    "type": "nesting",
    "id": "ne_wpxjk9m2nlrw",
    "dieline_id": "di_ueipnpyp0rlw",
    "dieline_template_id": "becf-10301",
    "nesting_template_id": "lt_xyz123abc",
    "variables": {
      "unit": "mm",
      "sheet_width": 1000.0,
      "sheet_height": 700.0,
      "sheet_margin_top": 15.0,
      "sheet_margin_bottom": 20.0,
      "sheet_margin_side": 10.0,
      "dieline_variables": {
        "unit": "mm",
        "width": 100,
        "height": 150,
        "length": 50,
        "material": 0.5
      },
      "num_x": 3,
      "num_y": 2,
      "margin_x": 10,
      "margin_y": 20
    },
    "format": "pdf",
    "width": {
      "value": 990.0,
      "unit": "mm"
    },
    "height": {
      "value": 880.0,
      "unit": "mm"
    },
    "nesting_overflow": false,
    "sum_of_line_lengths": [
      {
        "name": "Cut",
        "unit": "mm",
        "value": 3000.0
      },
      {
        "name": "Crease",
        "unit": "mm",
        "value": 5000.0
      },
      {
        "name": "Total",
        "unit": "mm",
        "value": 8000.0
      }
    ],
    "url": "https://d2atdwxjx7uc4i.cloudfront.net/nestings/abc123.pdf",
    "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: "Sheet width must be greater than zero"

Example Response, Status = 400, Bad Request

application/json
{
  "message": "Validation failed for one or more variables",
  "errors": [
    {
      "message": "Sheet width must be greater than zero."
    }
  ]
}