REST API v1.0

API Documentation

Integrate professional 2D cutting optimization into your applications. Fast, reliable, and easy to implement with comprehensive error handling.

~50ms response time
API key authentication
JSON request/response
POST/api/optimize

Submit pieces and stock sheets to receive optimized cutting layouts with placement coordinates, efficiency metrics, and waste calculations.

Authentication

All API requests require an API key passed in the x-api-key header. Generate your API key from the User Portal → API Keys section.

Get Your API Key

Sign in and go to Dashboard → API Keys to create and manage your API keys. Each key includes 100 requests/month with automatic usage tracking.

Keep your API key secure

Never expose your API key in client-side code. Use environment variables and server-side requests.

Header
x-api-key: sk_opt_2d_your_secret_key_here

Request Body

Send a JSON object containing pieces,stockSheets, andsettings.

pieces[] - Cut Pieces (max 1000)

FieldTypeRequiredDescription
idstring YesUnique identifier for the piece
labelstring YesDisplay name for the piece
widthnumber YesWidth in your unit (mm recommended). Max: 100,000
heightnumber YesHeight in your unit. Max: 100,000
quantityinteger YesNumber of pieces needed. Min: 1
canRotateboolean YesWhether this piece can be rotated 90°
materialstringNoOptional material identifier
priorityintegerNoOptional priority (lower = higher priority)

stockSheets[] - Stock Sheets (max 100)

FieldTypeRequiredDescription
idstring YesUnique identifier for the stock sheet
namestring YesDisplay name for the sheet
widthnumber YesSheet width. Max: 100,000
heightnumber YesSheet height. Max: 100,000
quantityinteger YesAvailable quantity. Min: 1
grainDirectionstringNoOne of: horizontal, vertical, none
materialstringNoOptional material identifier
costnumberNoCost per sheet (for calculations)

settings - Optimization Settings

FieldTypeRequiredDescription
bladeKerfnumber YesBlade thickness in your unit. Range: 0-100
allowRotationboolean YesGlobal rotation setting
paddingnumber YesEdge padding/margin. Range: 0-1000

Example Request Body

JSON
{
  "pieces": [
    {
      "id": "p1",
      "label": "Side Panel",
      "width": 600,
      "height": 400,
      "quantity": 4,
      "canRotate": true
    },
    {
      "id": "p2",
      "label": "Top Panel",
      "width": 800,
      "height": 300,
      "quantity": 2,
      "canRotate": false
    }
  ],
  "stockSheets": [
    {
      "id": "s1",
      "name": "Plywood 4x8",
      "width": 2440,
      "height": 1220,
      "quantity": 10
    }
  ],
  "settings": {
    "bladeKerf": 3,
    "allowRotation": true,
    "padding": 5
  }
}

Response

Successful requests return a JSON object with success: true and the optimization results in data.

Response Fields

  • layouts[] - Array of cutting layouts, one per used sheet
  • placements[] - Placed pieces with x, y coordinates
  • efficiency - Sheet utilization percentage
  • unplacedPieces[] - Pieces that couldn't fit
  • totalSheetsUsed - Number of stock sheets needed
  • overallEfficiency - Total material efficiency %
  • computeTimeMs - Algorithm execution time

Example Response

JSON
{
  "success": true,
  "data": {
    "layouts": [
      {
        "sheetIndex": 0,
        "stockSheet": { "id": "s1", "name": "Plywood 4x8", ... },
        "placements": [
          {
            "pieceId": "p1",
            "label": "Side Panel",
            "x": 5,
            "y": 5,
            "width": 600,
            "height": 400,
            "rotated": false,
            "sheetIndex": 0
          },
          ...
        ],
        "usedArea": 1680000,
        "wasteArea": 297680,
        "efficiency": 84.9
      }
    ],
    "unplacedPieces": [],
    "totalSheetsUsed": 1,
    "totalWaste": 297680,
    "overallEfficiency": 84.9,
    "computeTimeMs": 12
  }
}

Code Examples

cURL

bash
curl -X POST https://your-domain.com/api/optimize \
  -H "Content-Type: application/json" \
  -H "x-api-key: your_api_key_here" \
  -d '{
    "pieces": [...],
    "stockSheets": [...],
    "settings": {...}
  }'

JavaScript / TypeScript

javascript
const response = await fetch('/api/optimize', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.OPTIMIZER_API_KEY
  },
  body: JSON.stringify({
    pieces: [...],
    stockSheets: [...],
    settings: { bladeKerf: 3, allowRotation: true, padding: 5 }
  })
});

const result = await response.json();
console.log(result.data.layouts);

Python

python
import requests

response = requests.post(
    'https://your-domain.com/api/optimize',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': 'your_api_key_here'
    },
    json={
        'pieces': [...],
        'stockSheets': [...],
        'settings': {'bladeKerf': 3, 'allowRotation': True, 'padding': 5}
    }
)

result = response.json()
print(result['data']['layouts'])

Error Handling

Error responses include an error message,code, and optionaldetails array.

StatusCodeDescriptionFix
401MISSING_API_KEYNo x-api-key header providedAdd x-api-key header to your request
401INVALID_API_KEYAPI key does not matchCheck your API key is correct
401INACTIVE_API_KEYAPI key has been deactivatedRe-enable the key in the user portal
429RATE_LIMIT_EXCEEDEDMonthly credit limit exceeded (200 credits/month, 2 per call)Wait for monthly credit reset on the 1st of each month
400INVALID_JSONRequest body is not valid JSONValidate your JSON syntax
400VALIDATION_ERROROne or more fields failed validationCheck the details array for specific field errors
405METHOD_NOT_ALLOWEDWrong HTTP method usedUse POST method
500OPTIMIZATION_ERRORAlgorithm execution failedCheck input data for edge cases
500SERVER_CONFIG_ERRORServer misconfigurationContact support

Example Error Response

JSON
{
  "error": "Validation failed",
  "code": "VALIDATION_ERROR",
  "details": [
    "pieces[0].width: must be a positive number (max 100000)",
    "settings.bladeKerf: must be a number between 0 and 100"
  ]
}

Ready to Integrate?

Start using the API today. Need help or have questions? Contact our support team.