Skip to content
Documentation menu
docs / api / post-v1-jobs-optimise
Optimisation and jobs

POST/v1/jobs/optimise

Access and price

AuthAn API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Needs a full key; a browser (maps) key is refused.
PriceAs the synchronous twin, doubled when relax_if_unassigned reserves a second solve; the unused half is refunded when the job finishes. Class: standard, or premium for truck and ADR work. Published as unit_rules.async_jobs in /pricing.json.
PremiumWhen the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true

What it does

Submit an optimisation problem to the asynchronous lane.

An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Price: As the synchronous twin, doubled when relax_if_unassigned reserves a second solve; the unused half is refunded when the job finishes.

Call it

bash
curl -fsS -X POST "https://api.mapmap.ai/v1/jobs/optimise" \
  -H "Authorization: Bearer $MAPMAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"costing":"auto","jobs":[{"id":10,"location":{"lat":52.4862,"lon":-1.8904}},{"id":11,"location":{"lat":53.4808,"lon":-2.2426}}],"vehicles":[{"id":1,"start":{"lat":51.5074,"lon":-0.1278}}]}'

Request body

application/json

Exactly the POST /optimise body: vehicles, jobs, optional shipments, costing, costing_options, adr, eu_drivers_hours, plus an optional webhook_url. The unique-location cap here is SN_OPTIMISE_MAX_LOCATIONS_ASYNC (2,000 by default), ten times the synchronous 200: the synchronous cap is bound by the request deadline, and there is no request to hold open here

Example: From website/public/docs/api-reference.md:3081

json
{
  "costing": "auto",
  "jobs": [
    {
      "id": 10,
      "location": {
        "lat": 52.4862,
        "lon": -1.8904
      }
    },
    {
      "id": 11,
      "location": {
        "lat": 53.4808,
        "lon": -2.2426
      }
    }
  ],
  "vehicles": [
    {
      "id": 1,
      "start": {
        "lat": 51.5074,
        "lon": -0.1278
      }
    }
  ]
}

Responses

202Accepted and queued. Poll result_url, or wait for the signed webhook
FieldTypeRequiredDescription
idstringyesThe job id to poll.
kindstringyesoptimise, replan, matrix or coverage.
result_urlstringyesWhere to fetch it. The same URL the webhook will carry.
statusstringyesAlways queued, the worker has not looked at it yet.
units_chargedintegeryesQuota units this submission drew. Charged now, refunded in full if the job fails.

Example: A response assembled from this schema's own field examples, enums, defaults and types; not a recorded call

json
{
  "id": "string",
  "kind": "string",
  "result_url": "string",
  "status": "string",
  "units_charged": 0
}
400Invalid problem, or an unusable webhook_url (must be https and publicly resolvable)

application/problem+json · Problem

401Missing or invalid API key. Also: No key, or a missing, malformed, unknown, revoked or expired one (unauthorized); the body carries signup, docs and a one-call hint for a free key

application/problem+json · Problem

402Beyond the included volume with no way to pay this call: an x402 body naming how to pay (provisional key past its allowance, prepaid balance below the price, or a rejected X-PAYMENT). Not problem+json

application/json · X402PaymentRequired

403The key may not call this: a browser key outside its scope (scope-insufficient), a request from an origin the key does not allow (origin-not-allowed), or an account restriction (forbidden)

application/problem+json · Problem

409A webhook_url was given but the key has no webhook signing secret

application/problem+json · Problem

413The request declares a body larger than 1048576 bytes (plain text, not problem+json)

text/plain

422More than SN_OPTIMISE_MAX_LOCATIONS_ASYNC unique locations. (A problem too large for the solver's cost arithmetic is accepted here and fails as a job, refunded like any failed job.)

application/problem+json · Problem

429Quota, rate limit, or too many jobs already queued or running. Also: Per-key rate limit (rate-limited, with Retry-After), or monthly quota exhausted with no payment path (quota-exceeded)

application/problem+json · Problem

503Optimisation is not enabled on this deployment (SN_VROOM_URL unset)

application/problem+json · Problem

504The request did not finish within the gateway's request deadline (request-timeout)

application/problem+json · Problem

Error bodies follow the shared problem model documented on API conventions.

Also under Optimisation and jobs

Generated from https://api.mapmap.ai/openapi.json on 2026-11-12 · operationId post_optimise_job