---
title: "Take Dispatch Plan Optimization"
method: POST
path: "/v1/plans/{planId}/optimizations/{activityId}:take"
tags: ["Dispatch plans"]
---

# Take Dispatch Plan Optimization

`POST /v1/plans/{planId}/optimizations/{activityId}:take`

## Request

- Base URL: `https://api.sandbox.usenash.com`
- URL: `https://api.sandbox.usenash.com/v1/plans/{planId}/optimizations/{activityId}:take`
- Auth: none declared

Take a `succeeded` run into the plan's draft. Fails with 409 `PLAN_OPTIMIZATION_UNAVAILABLE` and `reason` `not_finished` while the run is `queued` or `running` (poll again), or `not_takeable` for a run that failed or whose result does not fit the plan; and with 409 `PLAN_OPTIMIZATION_STALE` when the draft changed after the run started. `not_takeable` and `PLAN_OPTIMIZATION_STALE` are final for that run: start a new one. Fails with 409 `PLAN_LEASE_HELD` (naming `heldBy`) while anyone has the plan open in the Planner, and with 409 `PLAN_REVISION_STALE` (naming `currentRevision`) when the plan changed since `expectedRevision`.

## Path parameters

- `planId` string, required
- `activityId` string, required: The optimization run id from its start.

## Request body

- DispatchPlanWrite
  - `expectedRevision` integer, required: The `revision` of the plan you last read.

## Response `200`

OK

- DispatchPlanOptimizationTaken
  - `revision` integer, required: The plan's revision with the result taken in.

## Other responses

- `422`: Unprocessable Content

---

[API](https://skmtc.dev/nash/apis/nash-api.md) - [All operations](https://skmtc.dev/nash/apis/nash-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nash/apis/nash-api/revisions/e3713837c5c9?raw)
