# Overview Prepare a plan, submit it for optimisation and retrieve the result. ## Start building - [Submit a plan](/quickstart/) - [Base URLs](/base-urls/) - [Direct-plan API preview](/reference/) ## Built for humans and AI The quickstart covers the implemented plan submission workflow. The direct-plan preview describes a proposed interface. ## Developer resources - [Documentation index](/llms.txt) - [Complete reference](/llms-full.txt) --- # Submit a plan to Coordigator Submit a plan with crews and jobs, queue its optimisation, and hand the saved plan to a dispatcher. The optimisation runs in the background, so the submitting client can disconnect as soon as the API returns a run ID. The public API base URL is `https://api.coordigator.io`. For local development, set `API_BASE` to `http://127.0.0.1:3001`. Send JSON bodies with `Content-Type: application/json` and credentials with `Authorization: Bearer `. | Step | Method and path | Bearer | Success | |---|---|---|---| | Prepare | `POST /customers/prepare-plan-import` | API key | `200` returns the ready-to-send `plan` and `solve` bodies, plus access details. | | Save | `POST /plans` | API key | `201` creates the plan and returns its ID, revisions and expiry. | | Submit | `POST /plans/{planId}/solves` | Plan edit token | `202` queues the solve and returns its run ID. | | Retrieve | `GET /plans/{planId}/solves/{runId}` | Plan view or edit token | `200` returns the current status and, on completion, the encrypted result. | ## Example submission Run the following in Bash with cURL and jq. Set `COORDIGATOR_API_KEY` to the account’s API key (the full value labelled **Client ID**). The example uses one crew and one service visit in Stockholm. ```bash set -euo pipefail API_BASE=${API_BASE:-https://api.coordigator.io} customer="Authorization: Bearer ${COORDIGATOR_API_KEY:?Set your API key}" json='Content-Type: application/json' prepared=$(curl --fail-with-body -sS "$API_BASE/customers/prepare-plan-import" \ -H "$customer" -H "$json" --data-binary @- <<'JSON' { "expiryHours": 24, "file": { "format": "coordigator-demo-v1", "date": "2026-12-01", "crews": [{ "name": "North", "driver": "Alex", "van": "Van 1", "capacity": 4, "start": "09:00", "end": "17:00", "breaks": [{"earliestStart": "12:00", "latestStart": "13:00", "duration": 30}], "origin": "sto-1259515079", "destination": "sto-1259515079" }], "jobs": [{ "name": "Service visit", "kind": "Service", "site": "sto-3661237304", "open": "09:00", "close": "16:00", "duration": 5 }] } } JSON ) saved=$(jq -c '.plan' <<<"$prepared" | curl --fail-with-body -sS "$API_BASE/plans" \ -H "$customer" -H "$json" --data-binary @-) plan_id=$(jq -er '.planId' <<<"$saved") editor="Authorization: Bearer $(jq -er '.editToken' <<<"$prepared")" run=$(jq -c '.solve' <<<"$prepared" | curl --fail-with-body -sS \ "$API_BASE/plans/$plan_id/solves" -H "$editor" -H "$json" --data-binary @-) run_id=$(jq -er '.runId' <<<"$run") echo "$run" ``` The crew’s 30-minute break can start between 12:00 and 13:00 Stockholm time. Crew capacity and job load in this file format are single quantities. All location fields in this import format use Stockholm catalogue IDs. Times use the planning date and the `Europe/Stockholm` time zone. Visit duration is in minutes. For a shipment, send two job rows with `kind` set to `Pickup` and `Delivery`, the same nonempty `pair` ID and matching `load`. A file accepts 1–500 crews and up to 500 logical jobs. Plan expiry is 1, 24 or 48 hours and defaults to 24. [Location catalogue](https://github.com/niklaslagergren/vrp/blob/bb38a34/packages/api-client/src/stockholmAddresses.json) ## After submission A typical `202 Accepted` response is: ```json { "runId": "7ffb0ac0-249f-4f97-bf00-b3750abc81cd", "problemRevision": 1, "solutionRevision": 1, "status": "queued", "createdAt": "2026-12-01T08:00:00.000Z", "expiresAt": "2026-12-02T08:00:00.000Z" } ``` **Handoff to Dispatcher.** Once saved, the plan can be opened with the `dispatcherUrl` returned by preparation. Give the dispatcher the `planKey` separately. The URL grants edit access. Keep the preparation response private. **Retrieve the result.** Call the status endpoint again while the run is `queued` or `running`. Each poll counts toward the account quota. ```bash viewer="Authorization: Bearer $(jq -er '.viewToken' <<<"$prepared")" curl --fail-with-body -sS "$API_BASE/plans/$plan_id/solves/$run_id" -H "$viewer" ``` A `completed` response adds `result`. The shared client decrypts it with `decryptSolveResult(planKey, { planId, runId, problemRevision }, result)`. Applying the result to the saved plan is a separate action. A `failed` response adds `"error":"solve_failed"`. The completed result expires with the plan. [Result decryption](https://github.com/niklaslagergren/vrp/blob/bb38a34/packages/api-client/src/solveCrypto.ts) **Retry a submission.** Keep the prepared bodies and tokens before saving. If the save response is lost, check `GET /plans/{planId}` with the original edit token. A successful read confirms creation. Retry a lost solve submission with the original `solve` body. Its `idempotencyKey` is the run ID. Changing the body while reusing the key returns `409 idempotency_conflict`. An invalid import returns `400`, an oversized payload `413`, an account run-size violation `422`, and an exhausted quota `429`. [Implementation and integration contract · bb38a34](https://github.com/niklaslagergren/vrp/blob/bb38a34/services/portal-api/saved-plans.md#background-solves-for-saved-plans) --- # Base URLs Choose the API base URL for your environment. ## Environments | Environment | Base URL | | --- | --- | | Public API | `https://api.coordigator.io` | | Local development | `http://127.0.0.1:3001` | Append the endpoint path to the base URL. For example, prepare a plan import with `POST https://api.coordigator.io/customers/prepare-plan-import`. ## Example configuration ```bash export API_BASE="https://api.coordigator.io" ``` --- # Integrate with AI Give your coding agent the implemented workflow for submitting plans. ## Integration prompt ```text Use the Coordigator plan submission guide at https://docs.coordigator.io/plan-submission.md. Prepare the import, save the plan, queue optimisation and retrieve the result using the credentials specified for each operation. ``` ## Documentation resources - [Download the implemented workflow](/plan-submission.md) - [Download the full reference with the direct-plan preview](/llms-full.txt) --- # Markdown & AI resources Download the plan submission guide and the direct-plan preview. ## Documentation exports - [Implemented plan submission guide](/plan-submission.md) - [Documentation index](/llms.txt) - [Full reference, including preview pages](/llms-full.txt) --- # Direct-plan API preview --- # Endpoint overview Three operations for the external plan submission workflow. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Operations | Method and path | Success (proposed) | Purpose | | --- | --- | --- | | POST /plans | 201 Created | Submit a plan directly | | POST /plans/{planId}/solves | 202 Accepted | Queue optimisation | | GET /plans/{planId}/solves/{runId} | 200 OK | Retrieve status and result | - [Create plan](./create.md) - [Start optimisation](./submit.md) - [Retrieve results](./retrieve.md) ## Scope This is a proposed replacement for the existing integration contract, not live API documentation. Public beta access remains on the marketing homepage. --- # Direct-plan quickstart (preview) Submit a plan, queue optimisation and retrieve the result. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Before you begin Use your solver portal Client ID as your API key. The direct-plan contract shown here is a design proposal; it is not the existing wire format. ## 1. Create a plan Save the example request from Create plan as plan.json. Coordinates are supplied directly, with no dependency on Dispatcher exports or location catalogues. ```bash export API_BASE="https://api.coordigator.io" # Set COORDIGATOR_API_KEY to the Client ID you use in the solver portal. saved=$(curl --fail-with-body -sS "$API_BASE/plans" \ -H "Authorization: Bearer $COORDIGATOR_API_KEY" \ -H "Content-Type: application/json" \ --data-binary @plan.json) PLAN_ID=$(jq -er '.planId' <<<"$saved") ``` - [Full request and response](./create.md) ## 2. Queue optimisation A background run is associated with the saved plan. The proposed call uses the API key. Final authorisation must be verified. ```bash run=$(curl --fail-with-body -sS -X POST "$API_BASE/plans/$PLAN_ID/solves" \ -H "Authorization: Bearer $COORDIGATOR_API_KEY" \ -H "Content-Type: application/json" \ -d '{}') RUN_ID=$(jq -er '.runId' <<<"$run") ``` ## 3. Retrieve the result Poll with a reasonable interval while queued or running; do not poll continuously. Stop at a terminal state. ```bash curl --fail-with-body -sS "$API_BASE/plans/$PLAN_ID/solves/$RUN_ID" \ -H "Authorization: Bearer $COORDIGATOR_API_KEY" ``` - [Result examples](./retrieve.md) ## Dispatcher handoff The design must support opening the saved plan in Dispatcher without exposing plan secrets in logs. The exact handoff response and key exchange are not agreed yet. --- # Authentication Authenticate customer-scoped requests with your API key. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## API key Use your solver portal **Client ID** as your API key. Copy it exactly as issued into `COORDIGATOR_API_KEY` and send it in the `Authorization` header using the `Bearer` scheme. ```text Authorization: Bearer Content-Type: application/json ``` The proposed direct-plan examples use the API key for all three operations. In the implemented API, preparing and creating a plan use the API key. Submitting a solve requires the plan edit token. Retrieving the result accepts a plan view or edit token. ## Keep credentials private Store credentials on the server. Never include them in browser code, logs or source control. The current operator can rotate or revoke credentials. --- # Create plan Create a saved routing plan using vehicles, jobs and geographic coordinates. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Request Send all timestamps in UTC and end each one with an uppercase `Z`. The `Z` means UTC. Responses use the same format. | Field | Type | Description | | --- | --- | --- | | name | string | Plan label | | expiryHours | integer | 1, 24 or 48; default 24 in current implementation | | vehicles | array of objects | Vehicle definitions | | jobs | array of objects | Service visits or shipments with linked pickup and delivery stops | The van can carry four pallets and 800 kg. Each job specifies its load as `[pallets, kilograms]`. The van also has a 30-minute break that can start between 11:00 and 12:00 UTC (12:00 to 13:00 in Stockholm on December 1). - [Nested field definitions](./model.md) ```json { "name": "Stockholm service visits", "expiryHours": 24, "vehicles": [ { "id": "van-1", "startLocation": { "latitude": 59.3326, "longitude": 18.0649 }, "endLocation": { "latitude": 59.347, "longitude": 18.038 }, "capacity": [4, 800], "breaks": [ { "durationMinutes": 30, "timeWindow": { "start": "2026-12-01T11:00:00Z", "end": "2026-12-01T12:00:00Z" } } ], "timeWindow": { "start": "2026-12-01T07:00:00Z", "end": "2026-12-01T16:00:00Z" } } ], "jobs": [ { "id": "job-1", "location": { "latitude": 59.34, "longitude": 18.05 }, "serviceDuration": 5, "load": [1, 250], "timeWindow": { "start": "2026-12-01T08:00:00Z", "end": "2026-12-01T15:00:00Z" } }, { "id": "job-2", "location": { "latitude": 59.345, "longitude": 18.045 }, "serviceDuration": 10, "load": [2, 300] } ] } ``` ## Example locations The example uses four points in central Stockholm, Sweden. The vehicle defines where the route starts and ends. Each job defines a place to visit. Array indexes start at zero, so `jobs[0]` is the first job listed in the request. The optimiser determines the visit order. | Location | JSON field | Area | Map pin (latitude, longitude) | | --- | --- | --- | --- | | Van start | `vehicles[0].startLocation` | Near Sergels torg | [59.3326, 18.0649](https://www.openstreetmap.org/?mlat=59.3326&mlon=18.0649#map=17/59.3326/18.0649) | | Van end | `vehicles[0].endLocation` | Northwest of Odenplan | [59.3470, 18.0380](https://www.openstreetmap.org/?mlat=59.3470&mlon=18.0380#map=17/59.3470/18.0380) | | Job `job-1` | `jobs[0].location` | South of Odenplan | [59.3400, 18.0500](https://www.openstreetmap.org/?mlat=59.3400&mlon=18.0500#map=17/59.3400/18.0500) | | Job `job-2` | `jobs[1].location` | Northwest of Odenplan | [59.3450, 18.0450](https://www.openstreetmap.org/?mlat=59.3450&mlon=18.0450#map=17/59.3450/18.0450) | [See all four locations in Google Maps](https://www.google.com/maps/dir/?api=1&origin=59.3326,18.0649&destination=59.3470,18.0380&waypoints=59.3400,18.0500%7C59.3450,18.0450&travelmode=driving). The map shows the jobs in request order. ## Pickup and delivery example To collect one pallet weighing 250 kg at the first Stockholm location and deliver it to the second, replace the two service visits in the request above with this `jobs` array. The same vehicle visits both stops, with pickup first. Specify the shipment’s `load` once. Each stop has its own `serviceDuration` in minutes. For a shipment, omit `jobs[0].location`. Put the two sets of coordinates in `jobs[0].pickup.location` and `jobs[0].delivery.location`. ```json { "jobs": [ { "id": "shipment-1", "load": [1, 250], "pickup": { "location": { "latitude": 59.34, "longitude": 18.05 }, "serviceDuration": 5 }, "delivery": { "location": { "latitude": 59.345, "longitude": 18.045 }, "serviceDuration": 10 } } ] } ``` Allow 5 minutes to load the pallet and 10 minutes to unload it. Travel time between the stops is calculated separately. ## Example call ```bash API_BASE=https://api.coordigator.io curl --fail-with-body -sS "$API_BASE/plans" \ -H "Authorization: Bearer $COORDIGATOR_API_KEY" \ -H "Content-Type: application/json" \ --data-binary @plan.json ``` ## 201 Created ```json { "planId": "11111111-1111-4111-8111-111111111111", "expiresAt": "2026-12-02T08:00:00Z" } ``` The plan ID identifies the saved plan. `expiresAt` is the UTC time when the plan expires. Access material and Dispatcher handoff fields must be designed and verified before release. --- # Start optimisation Queue a background solve for a saved plan. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Request Path parameter planId is the UUID returned by plan creation. The proposal uses an empty JSON object to optimise the saved plan snapshot. The current implementation requires a prepared solve body and edit token instead; the proposed simplified request requires backend changes. ```bash API_BASE=https://api.coordigator.io curl --fail-with-body -sS -X POST "$API_BASE/plans/$PLAN_ID/solves" \ -H "Authorization: Bearer $COORDIGATOR_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` ## 202 Accepted ```json { "runId": "22222222-2222-4222-8222-222222222222", "status": "queued", "createdAt": "2026-12-01T08:00:00Z", "expiresAt": "2026-12-02T08:00:00Z" } ``` Save the runId for later retrieval. The client can disconnect once the background run has been accepted. ## Retries The current implementation supports a solve idempotency key. The direct submission contract must define how callers provide that key and recover after an ambiguous response. Do not automatically retry unsafe writes. --- # Retrieve results Retrieve an optimisation run and its result. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Request Use planId and runId from the previous responses. ```bash API_BASE=https://api.coordigator.io curl --fail-with-body -sS "$API_BASE/plans/$PLAN_ID/solves/$RUN_ID" \ -H "Authorization: Bearer $COORDIGATOR_API_KEY" ``` ## Run status | Status | Meaning | | --- | --- | | queued | Waiting to execute | | running | Optimisation in progress | | completed | Result available | | failed | Optimisation failed | These states are documented in the supplied implementation reference. The proposed result representation below is illustrative, not the current encrypted result envelope. ## 200 OK — completed ```json { "runId": "22222222-2222-4222-8222-222222222222", "status": "completed", "createdAt": "2026-12-01T08:00:00Z", "expiresAt": "2026-12-02T08:00:00Z", "result": { "routes": [ { "vehicleId": "van-1", "jobIds": [ "job-1", "job-2" ] } ], "unassignedJobIds": [] } } ``` jobIds are shown in visit order in this proposed minimal response. No solver was executed to produce this example. The exact result schema, geometry, timings, loads and secure result delivery remain to be defined. ## Failure The current implementation returns error solve_failed when a run fails. Applying a completed result to a saved solution is a separate operation today; automatic application behaviour for the proposed interface must be agreed. --- # Plan data model Understand the proposed direct-plan payload. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Vehicles | Field | Type | Description | | --- | --- | --- | | id | string | Unique vehicle identifier within the plan | | startLocation | object | Starting coordinates | | endLocation | object | Finishing coordinates; may differ from start | | capacity | integer array | Maximum load in each dimension, in the same order as each job’s load | | breaks | array of objects | Optional break rules for this vehicle. Omit or send an empty array for no rules. | | timeWindow | object | Vehicle availability interval | Different vehicles may have different depots. The proposed minimal contract requires both start and end coordinates; open-route support must be verified separately. ## Jobs For a single service visit, put the location and service duration directly on the job. | Field | Type | Description | | --- | --- | --- | | id | string | Unique job identifier within the plan | | location | object | Visit coordinates | | serviceDuration | number | Time spent servicing this job, in minutes. For example, 5 means five minutes. | | load | integer array | Amount consumed in each capacity dimension | | timeWindow | object | Optional window for starting service. Both endpoints are inclusive. | ## Shipment jobs Represent a shipment as one entry in `jobs` with an `id`, a shared `load`, and two stops. Omit the job-level `location` field. The vehicle collects the load at `pickup.location` and drops it off at `delivery.location`. | Field | Type | Description | | --- | --- | --- | | `pickup.location` | object | Coordinates where the vehicle collects the shipment, using `latitude` and `longitude` | | `pickup.serviceDuration` | number | Minutes spent at the pickup stop | | `delivery.location` | object | Coordinates where the vehicle delivers the shipment, using `latitude` and `longitude` | | `delivery.serviceDuration` | number | Minutes spent at the delivery stop | See the [pickup and delivery example](/create/#pickup-and-delivery-example) for a shipment with a 5-minute pickup and a 10-minute delivery. ## Load dimensions Choose a unit for each array position and keep the order and length consistent across vehicles and jobs. Use nonnegative whole numbers. In the example, `[4, 800]` means room for four pallets and 800 kg. A job with `load: [1, 250]` uses one pallet space and 250 kg. A load of `[1, 900]` exceeds this van’s weight limit even with pallet spaces available. Use a one-element array for a single dimension, and use zero for an unused dimension. In the implemented routing problem the fields are `vehicles[].capacity` and `jobs[].demand`, both integer arrays. The current Dispatcher plan-file import accepts scalar crew `capacity` and job `load` and converts each to one routing dimension. ## Vehicle breaks In the proposed format, put each rule in `vehicles[].breaks`. A windowed break has a positive integer `durationMinutes` and a `timeWindow` with the earliest and latest permitted **start** timestamps. For the example van, a 30-minute break starting at 12:00 UTC finishes at 12:30 UTC. The implemented routing format uses `duration` in seconds and `time_window` for the start window. It also supports a work-time trigger (`trigger_after`, in seconds), optionally combined with the window. The [implemented import example](/plan-submission.md) shows the crew-file format. ## Coordinates | Field | Type | Description | | --- | --- | --- | | latitude | number | Decimal degrees, −90 to 90 | | longitude | number | Decimal degrees, −180 to 180 | Use named coordinate properties to avoid ordering ambiguity. The coordinate system is proposed as WGS 84. ## Time windows Use UTC timestamps ending in an uppercase `Z` for all vehicle, job and break windows. The `Z` means UTC. Convert local times to UTC before submitting the plan. For example, send 09:00 in Stockholm on December 1, 2026 as `2026-12-01T08:00:00Z`. Response timestamps such as `createdAt` and `expiresAt` use the same format. Each window’s `start` must be at or before its `end`. For a job, service may start at any time from `start` through `end`, inclusive. Service may finish after `end`. For example, a 10-minute visit with a window ending at 15:00 UTC may start at 15:00 UTC and finish at 15:10 UTC. If the stop must finish within the window, subtract `serviceDuration` (in minutes) from the required finish time and use the result as `timeWindow.end`. For a 10-minute stop that must finish by 15:00 UTC, set `timeWindow.end` to `2026-12-01T14:50:00Z` for a December 1, 2026 visit. ## Example ```json { "name": "Stockholm service visits", "expiryHours": 24, "vehicles": [ { "id": "van-1", "startLocation": { "latitude": 59.3326, "longitude": 18.0649 }, "endLocation": { "latitude": 59.347, "longitude": 18.038 }, "capacity": [4, 800], "breaks": [ { "durationMinutes": 30, "timeWindow": { "start": "2026-12-01T11:00:00Z", "end": "2026-12-01T12:00:00Z" } } ], "timeWindow": { "start": "2026-12-01T07:00:00Z", "end": "2026-12-01T16:00:00Z" } } ], "jobs": [ { "id": "job-1", "location": { "latitude": 59.34, "longitude": 18.05 }, "serviceDuration": 5, "load": [1, 250], "timeWindow": { "start": "2026-12-01T08:00:00Z", "end": "2026-12-01T15:00:00Z" } }, { "id": "job-2", "location": { "latitude": 59.345, "longitude": 18.045 }, "serviceDuration": 10, "load": [2, 300] } ] } ``` --- # Privacy & retention Keep routing data only as long as needed. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Retention | Current expiry option | Duration | | --- | --- | | 1 | 1 hour | | 24 | 24 hours (default) | | 48 | 48 hours | The supplied implementation reference confirms these options for the current import workflow. The proposed direct plan request retains expiryHours. Completed results expire with the plan. ## Encryption and hosting Hosted in Europe is the stated platform positioning. The current saved-plan workflow encrypts plan records and results using a separate plan key and plan-specific access tokens. The direct API must preserve those privacy properties; plaintext processing, key custody, encrypted transport/storage and secure result delivery must be reviewed before implementation. ## Dispatcher handoff The current workflow shares an edit URL and a plan key separately. The public contract must make handoff secure and straightforward without requiring callers to understand internal encryption envelopes. --- # Limits & quotas Understand current limits before integrating. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Current implementation | Limit | Current behaviour | | --- | --- | | Request body | 8 MiB for routing and plans | | Account quotas | Operator-configured dailyRequests, monthlyJobs, activeJobs and vehicles | | Background polls | Count toward daily quota | The supplied import format limits crews and logical jobs to 500. That limit is specific to the current import and is not asserted for the proposed coordinate-based contract. Final field limits and validation need verification. --- # Errors & retries Handle failures and retries safely. > **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative. ## Current error format ```json { "error": "invalid_request", "issues": [ { "path": [ "body" ], "code": "invalid_json" } ] } ``` ## Current error reference | HTTP | Error | Meaning | | --- | --- | --- | | 400 | invalid_request | Invalid payload | | 401 | customer_credentials_required | Invalid credential | | 403 | customer_inactive | Disabled account | | 413 | payload_too_large | Body exceeds limit | | 422 | run_limit_exceeded | Run-size limit | | 429 | quota_exceeded | Account quota exceeded | | 500 | internal_server_error | Unexpected failure | These codes are from the supplied current implementation; verify mapping for the new contract. ## Retries Do not blindly retry creation or solve submission after a lost response. Define an explicit idempotency and recovery contract before publication.