# 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.
