Sawvant
Optimization

Submit a cutting optimization job

Validates the request synchronously, then enqueues the job for async processing. Returns 202 with a job ID and URLs for polling/streaming.

POST
/v1/optimize
X-API-Key<token>

API key with sk_ prefix

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.sawvant.com/v1/optimize" \  -H "Content-Type: application/json" \  -d '{    "parts": [      {        "id": "shelf",        "length": 600,        "width": 400,        "quantity": 8,        "grain": "none"      },      {        "id": "bracket",        "length": 300,        "width": 200,        "quantity": 4,        "grain": "none"      }    ],    "sheets": [      {        "id": "mdf-18",        "length": 2440,        "width": 1220,        "quantity": 0,        "grain": "none"      }    ],    "machine": {      "blade_thickness": 3.2,      "max_levels": 3,      "cut_direction": "default"    }  }'
{
  "job_id": "453bd7d7-5355-4d6d-a38e-d9e7eb218c3f",
  "status": "pending",
  "poll_url": "/v1/jobs/550e8400-e29b-41d4-a716-446655440000",
  "stream_url": "/v1/jobs/550e8400-e29b-41d4-a716-446655440000/stream"
}

{
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "parts[0].length: must be greater than zero",
    "details": [
      {
        "field": "parts[0].length",
        "reason": "must be greater than zero"
      }
    ]
  }
}

{
  "error": "string"
}
{
  "error": "string"
}
{
  "error": {
    "code": "INFEASIBLE",
    "message": "1 part does not fit on any sheet: P1",
    "details": [
      {
        "field": "parts",
        "reason": "part \"P1\" does not fit on any sheet, even rotated (edge banding and trim margins included)"
      }
    ]
  }
}
{
  "error": "rate limit exceeded",
  "limit": 0,
  "remaining": 0,
  "strategy": "fast"
}
{
  "error": {
    "code": "INVALID_BODY",
    "message": "string",
    "details": [
      {
        "field": "parts[2].width",
        "reason": "must be greater than zero"
      }
    ]
  }
}
{
  "error": {
    "code": "INVALID_BODY",
    "message": "string",
    "details": [
      {
        "field": "parts[2].width",
        "reason": "must be greater than zero"
      }
    ]
  }
}