# Spoke Dispatch

> Plan delivery routes, add stops and drivers, and follow deliveries in Spoke Dispatch (formerly Circuit for Teams).

App · 28 actions. Web page: https://docs.lodol.com/docs/integrations/spoke-dispatch

## Actions

### Add a driver

Add a driver to the team. Spoke invites them by email or text.

**Inputs**

- Name (`name`, text): The driver's full name.
- Email (`email`, text): The driver's email address. Give an email, a phone number or both.
- Phone (`phone`, text): The driver's phone number.
- Display name (`display_name`, text): The name shown for the driver in Spoke.
- Depots (`depot_ids`, list): The depots the driver works from.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "active": true,
    "depots": [
      "example"
    ],
    "displayName": "example",
    "email": "example",
    "id": "example",
    "name": "example",
    "phone": "example"
  }
}
```

### Add a stop to a plan

Add a stop to a plan that hasn't been optimized yet.

**Inputs**

- Plan (`plan_id`, text, required): The plan.
- Address (`address_line_one`, text): The street address, such as 350 5th Ave. Spoke finds it on the map.
- Address line 2 (`address_line_two`, text): The apartment, suite or unit.
- City (`city`, text): The city.
- State (`state`, text): The state or region.
- Zip (`zip`, text): The ZIP or postal code.
- Country (`country`, text): The country.
- Place name (`address_name`, text): A name shown for the place, such as a business name. Spoke doesn't use it to find the address.
- Latitude (`latitude`, number): The latitude in decimal degrees. With a longitude, it places the stop exactly. From -90 to 90.
- Longitude (`longitude`, number): The longitude in decimal degrees. From -180 to 180.
- Recipient name (`recipient_name`, text): The recipient's name.
- Recipient email (`recipient_email`, text): The recipient's email address, for delivery updates.
- Recipient phone (`recipient_phone`, text): The recipient's phone number, for delivery updates.
- External ID (`external_id`, text): Your own ID for the recipient or order, which list steps can filter by.
- Notes (`notes`, text): Notes for the driver.
- Activity (`activity`, text): Whether the driver delivers or picks up here. One of: `delivery`, `pickup`.
- Package count (`package_count`, number): How many packages. At least 0.
- Position in route (`optimization_order`, text): Where the stop goes in the optimized route. One of: `default`, `first`, `last`.
- Arrive after (`earliest_time`, time): The earliest time of day the driver should arrive.
- Arrive before (`latest_time`, time): The latest time of day the driver should arrive.
- Minutes at stop (`time_at_stop_minutes`, number): How many minutes the driver spends here, when not the team's usual. From 0 to 1440.
- Products (`products`, list): The products in this stop.
- Seller order ID (`seller_order_id`, text): The seller's order ID.
- Barcodes (`barcodes`, list): Barcodes on the packages.
- Custom properties (`custom_properties`, object): Custom stop properties, by their IDs from List custom stop properties.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "activity": "delivery",
    "address": {
      "address": "example",
      "addressLineOne": "example",
      "addressLineTwo": "example",
      "latitude": 1,
      "longitude": 1,
      "placeId": "example"
    },
    "allowedDrivers": [
      "example"
    ],
    "barcodes": [
      "example"
    ],
    "clientId": "example",
    "customProperties": {},
    "deliveryInfo": {
      "attempted": true,
      "attemptedAt": 1,
      "driverProvidedRecipientNotes": "example",
      "photoUrls": [
        "example"
      ],
      "recipientProvidedNotes": "example",
      "signatureUrl": "example",
      "signeeName": "example",
      "state": "example",
      "succeeded": true
    },
    "id": "example",
    "notes": "example",
    "orderInfo": {
      "invoiceNumber": "example",
      "products": [
        "example"
      ],
      "sellerName": "example",
      "sellerOrderId": "example",
      "sellerWebsite": "example"
    },
    "packageCount": 1,
    "plan": "example",
    "recipient": {
      "email": "example",
      "externalId": "example",
      "name": "example",
      "phone": "example"
    },
    "route": {
      "driver": "example",
      "id": "example",
      "plan": "example",
      "state": {
        "completed": true,
        "completedAt": 1,
        "distributed": true,
        "distributedAt": 1,
        "notifiedRecipients": true,
        "started": true,
        "startedAt": 1
      },
      "stopCount": 1,
      "title": "example"
    },
    "stopPosition": 1,
    "timing": {
      "earliestAttemptTime": {
        "hour": 1,
        "minute": 1
      },
      "estimatedAttemptDuration": 1,
      "latestAttemptTime": {
        "hour": 1,
        "minute": 1
      }
    },
    "trackingLink": "example",
    "type": "stop",
    "webAppLink": "example"
  }
}
```

### Add a team member

Invite a dispatcher, admin, depot manager or read-only member to the team.

**Inputs**

- Email (`email`, text, required): The member's email address.
- Role (`role`, text, required): What the member can do in Spoke. One of: `dispatcher`, `admin`, `depot-manager`, `read-only`.
- Name (`name`, text): The member's full name.
- Depots (`depot_ids`, list): The depots the member works with.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "active": true,
    "depots": [
      "example"
    ],
    "displayName": "example",
    "email": "example",
    "id": "example",
    "name": "example",
    "roles": [
      "example"
    ]
  }
}
```

### Create a plan

Create a plan for a day, with the drivers who will run it.

**Inputs**

- Title (`title`, text, required): The plan's title.
- Date (`starts`, date, required): The day the plan runs.
- Drivers (`driver_ids`, list): The drivers on the plan.
- Depot (`depot_id`, text): The depot the routes start from. Left empty, the team's main depot.
- Start time (`start_time`, time): When the drivers' day starts, for every route in the plan.
- End time (`end_time`, time): When the drivers' day ends, for every route in the plan.
- Vehicle type (`vehicle_type`, text): The vehicle used on the plan's routes. One of: `car`, `bike`, `scooter`, `small_truck` (Small truck), `truck`, `electric_cargo_bike` (Electric cargo bike).

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "depot": "example",
    "distributed": true,
    "drivers": [
      "example"
    ],
    "id": "example",
    "optimization": "creating",
    "routes": [
      "example"
    ],
    "starts": {
      "day": 1,
      "month": 1,
      "year": 1
    },
    "title": "example",
    "writable": true
  }
}
```

### Create an unassigned stop

Create a stop that waits to be added to a plan.

**Inputs**

- Address (`address_line_one`, text): The street address, such as 350 5th Ave. Spoke finds it on the map.
- Address line 2 (`address_line_two`, text): The apartment, suite or unit.
- City (`city`, text): The city.
- State (`state`, text): The state or region.
- Zip (`zip`, text): The ZIP or postal code.
- Country (`country`, text): The country.
- Place name (`address_name`, text): A name shown for the place, such as a business name. Spoke doesn't use it to find the address.
- Latitude (`latitude`, number): The latitude in decimal degrees. With a longitude, it places the stop exactly. From -90 to 90.
- Longitude (`longitude`, number): The longitude in decimal degrees. From -180 to 180.
- Depot (`depot_id`, text): The depot the stop leaves from. Left empty, the team's main depot.
- Recipient name (`recipient_name`, text): The recipient's name.
- Recipient email (`recipient_email`, text): The recipient's email address, for delivery updates.
- Recipient phone (`recipient_phone`, text): The recipient's phone number, for delivery updates.
- External ID (`external_id`, text): Your own ID for the recipient or order, which list steps can filter by.
- Notes (`notes`, text): Notes for the driver.
- Activity (`activity`, text): Whether the driver delivers or picks up here. One of: `delivery`, `pickup`.
- Package count (`package_count`, number): How many packages. At least 0.
- Position in route (`optimization_order`, text): Where the stop goes in the optimized route. One of: `default`, `first`, `last`.
- Arrive after (`earliest_time`, time): The earliest time of day the driver should arrive.
- Arrive before (`latest_time`, time): The latest time of day the driver should arrive.
- Minutes at stop (`time_at_stop_minutes`, number): How many minutes the driver spends here, when not the team's usual. From 0 to 1440.
- Products (`products`, list): The products in this stop.
- Seller order ID (`seller_order_id`, text): The seller's order ID.
- Barcodes (`barcodes`, list): Barcodes on the packages.
- Custom properties (`custom_properties`, object): Custom stop properties, by their IDs from List custom stop properties.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "activity": "delivery",
    "address": {
      "address": "example",
      "addressLineOne": "example",
      "addressLineTwo": "example",
      "latitude": 1,
      "longitude": 1,
      "placeId": "example"
    },
    "barcodes": [
      "example"
    ],
    "clientId": "example",
    "customProperties": {},
    "depot": "example",
    "id": "example",
    "notes": "example",
    "orderInfo": {
      "invoiceNumber": "example",
      "products": [
        "example"
      ],
      "sellerName": "example",
      "sellerOrderId": "example",
      "sellerWebsite": "example"
    },
    "packageCount": 1,
    "recipient": {
      "email": "example",
      "externalId": "example",
      "name": "example",
      "phone": "example"
    },
    "trackingLink": "example"
  }
}
```

### Delete a plan

Delete a plan and its routes.

**Inputs**

- Plan (`plan_id`, text, required): The plan to delete.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {}
}
```

### Delete a stop

Delete a stop from a plan that hasn't been optimized yet.

**Inputs**

- Plan (`plan_id`, text, required): The plan.
- Stop (`stop_id`, text, required): The stop's ID, as Spoke gives it (plans/.../stops/...) or its last part.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {}
}
```

### Delete an unassigned stop

Delete a stop waiting to be added to a plan.

**Inputs**

- Unassigned stop (`unassigned_stop_id`, text, required): The unassigned stop's ID, as Spoke gives it (unassignedStops/...) or its last part.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {}
}
```

### Distribute a plan

Send an optimized plan's routes to its drivers.

**Inputs**

- Plan (`plan_id`, text, required): The optimized plan to send to its drivers.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "depot": "example",
    "distributed": true,
    "drivers": [
      "example"
    ],
    "id": "example",
    "optimization": "creating",
    "routes": [
      "example"
    ],
    "starts": {
      "day": 1,
      "month": 1,
      "year": 1
    },
    "title": "example",
    "writable": true
  }
}
```

### Get a plan

Get a plan, with its drivers, routes and optimization state.

**Inputs**

- Plan (`plan_id`, text, required): The plan.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "depot": "example",
    "distributed": true,
    "drivers": [
      "example"
    ],
    "id": "example",
    "optimization": "creating",
    "routes": [
      "example"
    ],
    "starts": {
      "day": 1,
      "month": 1,
      "year": 1
    },
    "title": "example",
    "writable": true
  }
}
```

### Get a route

Get a route, with its driver and whether it has been sent, started or completed.

**Inputs**

- Route (`route_id`, text, required): The route's ID, as Spoke gives it (routes/...) or its last part.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "driver": "example",
    "id": "example",
    "plan": "example",
    "state": {
      "completed": true,
      "completedAt": 1,
      "distributed": true,
      "distributedAt": 1,
      "notifiedRecipients": true,
      "started": true,
      "startedAt": 1
    },
    "stopCount": 1,
    "title": "example"
  }
}
```

### Get a stop

Get a stop on a plan, with its route, ETA and delivery details.

**Inputs**

- Plan (`plan_id`, text, required): The plan.
- Stop (`stop_id`, text, required): The stop's ID, as Spoke gives it (plans/.../stops/...) or its last part.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "activity": "delivery",
    "address": {
      "address": "example",
      "addressLineOne": "example",
      "addressLineTwo": "example",
      "latitude": 1,
      "longitude": 1,
      "placeId": "example"
    },
    "allowedDrivers": [
      "example"
    ],
    "barcodes": [
      "example"
    ],
    "clientId": "example",
    "customProperties": {},
    "deliveryInfo": {
      "attempted": true,
      "attemptedAt": 1,
      "driverProvidedRecipientNotes": "example",
      "photoUrls": [
        "example"
      ],
      "recipientProvidedNotes": "example",
      "signatureUrl": "example",
      "signeeName": "example",
      "state": "example",
      "succeeded": true
    },
    "id": "example",
    "notes": "example",
    "orderInfo": {
      "invoiceNumber": "example",
      "products": [
        "example"
      ],
      "sellerName": "example",
      "sellerOrderId": "example",
      "sellerWebsite": "example"
    },
    "packageCount": 1,
    "plan": "example",
    "recipient": {
      "email": "example",
      "externalId": "example",
      "name": "example",
      "phone": "example"
    },
    "route": {
      "driver": "example",
      "id": "example",
      "plan": "example",
      "state": {
        "completed": true,
        "completedAt": 1,
        "distributed": true,
        "distributedAt": 1,
        "notifiedRecipients": true,
        "started": true,
        "startedAt": 1
      },
      "stopCount": 1,
      "title": "example"
    },
    "stopPosition": 1,
    "timing": {
      "earliestAttemptTime": {
        "hour": 1,
        "minute": 1
      },
      "estimatedAttemptDuration": 1,
      "latestAttemptTime": {
        "hour": 1,
        "minute": 1
      }
    },
    "trackingLink": "example",
    "type": "stop",
    "webAppLink": "example"
  }
}
```

### Get an optimization

Get a plan optimization: whether it is done, and its result.

**Inputs**

- Operation (`operation_id`, text, required): The operation's ID, as Optimize a plan returns it (operations/...) or its last part.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "done": true,
    "id": "example",
    "metadata": {
      "canceled": true,
      "finishedAt": 1,
      "startedAt": 1,
      "startedBy": "example",
      "targetPlanId": "example"
    },
    "result": {
      "code": "example",
      "message": "example",
      "numOptimizedStops": 1
    },
    "type": "plan_optimization"
  }
}
```

### List a plan's stops

List the stops on a plan.

**Inputs**

- Plan (`plan_id`, text, required): The plan.
- External ID (`external_id`, text): Only stops with this external ID.
- Page size (`max_page_size`, number): How many to return, at most 10. Spoke returns 10 when left empty. From 1 to 10.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "nextPageToken": "example",
    "stops": [
      {
        "activity": "delivery",
        "address": {
          "address": "example",
          "addressLineOne": "example",
          "addressLineTwo": "example",
          "latitude": 1,
          "longitude": 1,
          "placeId": "example"
        },
        "allowedDrivers": [
          "example"
        ],
        "barcodes": [
          "example"
        ],
        "clientId": "example",
        "customProperties": {},
        "deliveryInfo": {
          "attempted": true,
          "attemptedAt": 1,
          "driverProvidedRecipientNotes": "example",
          "photoUrls": [
            "example"
          ],
          "recipientProvidedNotes": "example",
          "signatureUrl": "example",
          "signeeName": "example",
          "state": "example",
          "succeeded": true
        },
        "id": "example",
        "notes": "example",
        "orderInfo": {
          "invoiceNumber": "example",
          "products": [
            "example"
          ],
          "sellerName": "example",
          "sellerOrderId": "example",
          "sellerWebsite": "example"
        },
        "packageCount": 1,
        "plan": "example",
        "recipient": {
          "email": "example",
          "externalId": "example",
          "name": "example",
          "phone": "example"
        },
        "route": {
          "driver": "example",
          "id": "example",
          "plan": "example",
          "state": {
            "completed": true,
            "completedAt": 1,
            "distributed": true,
            "distributedAt": 1,
            "notifiedRecipients": true,
            "started": true,
            "startedAt": 1
          },
          "stopCount": 1,
          "title": "example"
        },
        "stopPosition": 1,
        "timing": {
          "earliestAttemptTime": {
            "hour": 1,
            "minute": 1
          },
          "estimatedAttemptDuration": 1,
          "latestAttemptTime": {
            "hour": 1,
            "minute": 1
          }
        },
        "trackingLink": "example",
        "type": "stop",
        "webAppLink": "example"
      }
    ]
  }
}
```

### List a route's stops

List the stops on a route in order, with their delivery details.

**Inputs**

- Route (`route_id`, text, required): The route's ID, as Spoke gives it (routes/...) or its last part.
- Page size (`max_page_size`, number): How many to return, at most 10. Spoke returns 10 when left empty. From 1 to 10.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "nextPageToken": "example",
    "stops": [
      {
        "activity": "delivery",
        "address": {
          "address": "example",
          "addressLineOne": "example",
          "addressLineTwo": "example",
          "latitude": 1,
          "longitude": 1,
          "placeId": "example"
        },
        "allowedDrivers": [
          "example"
        ],
        "barcodes": [
          "example"
        ],
        "clientId": "example",
        "customProperties": {},
        "deliveryInfo": {
          "attempted": true,
          "attemptedAt": 1,
          "driverProvidedRecipientNotes": "example",
          "photoUrls": [
            "example"
          ],
          "recipientProvidedNotes": "example",
          "signatureUrl": "example",
          "signeeName": "example",
          "state": "example",
          "succeeded": true
        },
        "id": "example",
        "notes": "example",
        "orderInfo": {
          "invoiceNumber": "example",
          "products": [
            "example"
          ],
          "sellerName": "example",
          "sellerOrderId": "example",
          "sellerWebsite": "example"
        },
        "packageCount": 1,
        "plan": "example",
        "recipient": {
          "email": "example",
          "externalId": "example",
          "name": "example",
          "phone": "example"
        },
        "route": {
          "driver": "example",
          "id": "example",
          "plan": "example",
          "state": {
            "completed": true,
            "completedAt": 1,
            "distributed": true,
            "distributedAt": 1,
            "notifiedRecipients": true,
            "started": true,
            "startedAt": 1
          },
          "stopCount": 1,
          "title": "example"
        },
        "stopPosition": 1,
        "timing": {
          "earliestAttemptTime": {
            "hour": 1,
            "minute": 1
          },
          "estimatedAttemptDuration": 1,
          "latestAttemptTime": {
            "hour": 1,
            "minute": 1
          }
        },
        "trackingLink": "example",
        "type": "stop",
        "webAppLink": "example"
      }
    ]
  }
}
```

### List custom stop properties

List the custom properties the team has defined for stops.

**Inputs**: None.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "customStopProperties": [
      {
        "id": "example",
        "name": "example",
        "visibleToDrivers": true,
        "visibleToRecipients": true
      }
    ]
  }
}
```

### List depots

List the team's depots.

**Inputs**

- Page size (`max_page_size`, number): How many to return, at most 50. Spoke returns 10 when left empty. From 1 to 50.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "depots": [
      {
        "id": "example",
        "name": "example"
      }
    ],
    "nextPageToken": "example"
  }
}
```

### List drivers

List the team's drivers.

**Inputs**

- Active (`active`, true/false): On for only active drivers, off for only paused ones. Left empty, all drivers.
- Page size (`max_page_size`, number): How many to return, at most 50. Spoke returns 10 when left empty. From 1 to 50.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "drivers": [
      {
        "active": true,
        "depots": [
          "example"
        ],
        "displayName": "example",
        "email": "example",
        "id": "example",
        "name": "example",
        "phone": "example"
      }
    ],
    "nextPageToken": "example"
  }
}
```

### List optimizations

List plan optimizations, finished or still running.

**Inputs**

- Finished (`done`, true/false): On for only finished optimizations, off for only running ones. Left empty, all.
- Page size (`max_page_size`, number): How many to return, at most 10. Spoke returns 10 when left empty. From 1 to 10.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "nextPageToken": "example",
    "operations": [
      {
        "done": true,
        "id": "example",
        "metadata": {
          "canceled": true,
          "finishedAt": 1,
          "startedAt": 1,
          "startedBy": "example",
          "targetPlanId": "example"
        },
        "result": {
          "code": "example",
          "message": "example",
          "numOptimizedStops": 1
        },
        "type": "plan_optimization"
      }
    ]
  }
}
```

### List plans

List the team's plans, optionally only those starting between two dates.

**Inputs**

- Title (`title`, text): Only the plan with exactly this title.
- Starting from (`starts_from`, date): Only plans starting on or after this date.
- Starting until (`starts_to`, date): Only plans starting on or before this date.
- Page size (`max_page_size`, number): How many to return, at most 20. Spoke returns 10 when left empty. From 1 to 20.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "nextPageToken": "example",
    "plans": [
      {
        "depot": "example",
        "distributed": true,
        "drivers": [
          "example"
        ],
        "id": "example",
        "optimization": "creating",
        "routes": [
          "example"
        ],
        "starts": {
          "day": 1,
          "month": 1,
          "year": 1
        },
        "title": "example",
        "writable": true
      }
    ]
  }
}
```

### List routes

List routes, optionally only those starting between two dates.

**Inputs**

- Starting from (`starts_from`, date): Only routes starting on or after this date.
- Starting until (`starts_to`, date): Only routes starting on or before this date.
- Page size (`max_page_size`, number): How many to return, at most 10. Spoke returns 10 when left empty. From 1 to 10.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "nextPageToken": "example",
    "routes": [
      {
        "driver": "example",
        "id": "example",
        "plan": "example",
        "state": {
          "completed": true,
          "completedAt": 1,
          "distributed": true,
          "distributedAt": 1,
          "notifiedRecipients": true,
          "started": true,
          "startedAt": 1
        },
        "stopCount": 1,
        "title": "example"
      }
    ]
  }
}
```

### List unassigned stops

List stops waiting to be added to a plan.

**Inputs**

- External ID (`external_id`, text): Only stops with this external ID.
- Page size (`max_page_size`, number): How many to return, at most 100. Spoke returns 10 when left empty. From 1 to 100.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "nextPageToken": "example",
    "unassignedStops": [
      {
        "activity": "delivery",
        "address": {
          "address": "example",
          "addressLineOne": "example",
          "addressLineTwo": "example",
          "latitude": 1,
          "longitude": 1,
          "placeId": "example"
        },
        "barcodes": [
          "example"
        ],
        "clientId": "example",
        "customProperties": {},
        "depot": "example",
        "id": "example",
        "notes": "example",
        "orderInfo": {
          "invoiceNumber": "example",
          "products": [
            "example"
          ],
          "sellerName": "example",
          "sellerOrderId": "example",
          "sellerWebsite": "example"
        },
        "packageCount": 1,
        "recipient": {
          "email": "example",
          "externalId": "example",
          "name": "example",
          "phone": "example"
        },
        "trackingLink": "example"
      }
    ]
  }
}
```

### Optimize a plan

Start optimizing a plan's routes. It returns an operation to follow with Get an optimization.

**Inputs**

- Plan (`plan_id`, text, required): The plan to optimize.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "done": true,
    "id": "example",
    "metadata": {
      "canceled": true,
      "finishedAt": 1,
      "startedAt": 1,
      "startedBy": "example",
      "targetPlanId": "example"
    },
    "result": {
      "code": "example",
      "message": "example",
      "numOptimizedStops": 1
    },
    "type": "plan_optimization"
  }
}
```

### Remove a driver

Remove a driver from the team.

**Inputs**

- Driver (`driver_id`, text, required): The driver to remove.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {}
}
```

### Search stops

Search all stops, planned and unassigned, by keywords and an optional filter.

**Inputs**

- Keywords (`keyword`, text): Words to look for in the stops' addresses, recipients and notes.
- Filter (`filter`, text): A filter in Spoke's search language, such as deliveryInfo.succeeded = true and address ~= "London".
- Page size (`max_page_size`, number): How many to return, at most 100. Spoke returns 10 when left empty. From 1 to 100.
- Page token (`page_token`, text): The next page token from an earlier answer, to read the page after it.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "nextPageToken": "example",
    "stops": [
      {
        "stop": {
          "activity": "delivery",
          "address": {
            "address": "example",
            "addressLineOne": "example",
            "addressLineTwo": "example",
            "latitude": 1,
            "longitude": 1,
            "placeId": "example"
          },
          "allowedDrivers": [
            "example"
          ],
          "barcodes": [
            "example"
          ],
          "clientId": "example",
          "customProperties": {},
          "deliveryInfo": {
            "attempted": true,
            "attemptedAt": 1,
            "driverProvidedRecipientNotes": "example",
            "photoUrls": [
              "example"
            ],
            "recipientProvidedNotes": "example",
            "signatureUrl": "example",
            "signeeName": "example",
            "state": "example",
            "succeeded": true
          },
          "id": "example",
          "notes": "example",
          "orderInfo": {
            "invoiceNumber": "example",
            "products": [
              "example"
            ],
            "sellerName": "example",
            "sellerOrderId": "example",
            "sellerWebsite": "example"
          },
          "packageCount": 1,
          "plan": "example",
          "recipient": {
            "email": "example",
            "externalId": "example",
            "name": "example",
            "phone": "example"
          },
          "route": {
            "driver": "example",
            "id": "example",
            "plan": "example",
            "state": {
              "completed": true,
              "completedAt": 1,
              "distributed": true,
              "distributedAt": 1,
              "notifiedRecipients": true,
              "started": true,
              "startedAt": 1
            },
            "stopCount": 1,
            "title": "example"
          },
          "stopPosition": 1,
          "timing": {
            "earliestAttemptTime": {
              "hour": 1,
              "minute": 1
            },
            "estimatedAttemptDuration": 1,
            "latestAttemptTime": {
              "hour": 1,
              "minute": 1
            }
          },
          "trackingLink": "example",
          "type": "stop",
          "webAppLink": "example"
        },
        "type": "example",
        "unassignedStop": {
          "activity": "delivery",
          "address": {
            "address": "example",
            "addressLineOne": "example",
            "addressLineTwo": "example",
            "latitude": 1,
            "longitude": 1,
            "placeId": "example"
          },
          "barcodes": [
            "example"
          ],
          "clientId": "example",
          "customProperties": {},
          "depot": "example",
          "id": "example",
          "notes": "example",
          "orderInfo": {
            "invoiceNumber": "example",
            "products": [
              "example"
            ],
            "sellerName": "example",
            "sellerOrderId": "example",
            "sellerWebsite": "example"
          },
          "packageCount": 1,
          "recipient": {
            "email": "example",
            "externalId": "example",
            "name": "example",
            "phone": "example"
          },
          "trackingLink": "example"
        }
      }
    ]
  }
}
```

### Update a driver

Change a driver's name or depots. Fields left empty stay as they are.

**Inputs**

- Driver (`driver_id`, text, required): The driver.
- Name (`name`, text): The driver's full name.
- Display name (`display_name`, text): The name shown for the driver in Spoke.
- Depots (`depot_ids`, list): The driver's depots, replacing the ones they have.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "active": true,
    "depots": [
      "example"
    ],
    "displayName": "example",
    "email": "example",
    "id": "example",
    "name": "example",
    "phone": "example"
  }
}
```

### Update a plan

Change a plan's title, day, drivers or depot. Fields left empty stay as they are.

**Inputs**

- Plan (`plan_id`, text, required): The plan.
- Title (`title`, text): The plan's new title.
- Date (`starts`, date): The new day the plan runs.
- Drivers (`driver_ids`, list): The plan's drivers, replacing the ones it has.
- Depot (`depot_id`, text): The depot the routes start from.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "depot": "example",
    "distributed": true,
    "drivers": [
      "example"
    ],
    "id": "example",
    "optimization": "creating",
    "routes": [
      "example"
    ],
    "starts": {
      "day": 1,
      "month": 1,
      "year": 1
    },
    "title": "example",
    "writable": true
  }
}
```

### Update a stop

Change a stop's recipient, notes, timing or packages. Spoke can't move a stop to a new address.

**Inputs**

- Plan (`plan_id`, text, required): The plan.
- Stop (`stop_id`, text, required): The stop's ID, as Spoke gives it (plans/.../stops/...) or its last part.
- Recipient name (`recipient_name`, text): The recipient's name.
- Recipient email (`recipient_email`, text): The recipient's email address, for delivery updates.
- Recipient phone (`recipient_phone`, text): The recipient's phone number, for delivery updates.
- External ID (`external_id`, text): Your own ID for the recipient or order, which list steps can filter by.
- Notes (`notes`, text): Notes for the driver.
- Activity (`activity`, text): Whether the driver delivers or picks up here. One of: `delivery`, `pickup`.
- Package count (`package_count`, number): How many packages. At least 0.
- Position in route (`optimization_order`, text): Where the stop goes in the optimized route. One of: `default`, `first`, `last`.
- Arrive after (`earliest_time`, time): The earliest time of day the driver should arrive.
- Arrive before (`latest_time`, time): The latest time of day the driver should arrive.
- Minutes at stop (`time_at_stop_minutes`, number): How many minutes the driver spends here, when not the team's usual. From 0 to 1440.
- Products (`products`, list): The products in this stop.
- Seller order ID (`seller_order_id`, text): The seller's order ID.
- Barcodes (`barcodes`, list): Barcodes on the packages.
- Custom properties (`custom_properties`, object): Custom stop properties, by their IDs from List custom stop properties.

**Outputs**

- `data` (object): The response from Spoke Dispatch.

**Example output**

```json
{
  "data": {
    "activity": "delivery",
    "address": {
      "address": "example",
      "addressLineOne": "example",
      "addressLineTwo": "example",
      "latitude": 1,
      "longitude": 1,
      "placeId": "example"
    },
    "allowedDrivers": [
      "example"
    ],
    "barcodes": [
      "example"
    ],
    "clientId": "example",
    "customProperties": {},
    "deliveryInfo": {
      "attempted": true,
      "attemptedAt": 1,
      "driverProvidedRecipientNotes": "example",
      "photoUrls": [
        "example"
      ],
      "recipientProvidedNotes": "example",
      "signatureUrl": "example",
      "signeeName": "example",
      "state": "example",
      "succeeded": true
    },
    "id": "example",
    "notes": "example",
    "orderInfo": {
      "invoiceNumber": "example",
      "products": [
        "example"
      ],
      "sellerName": "example",
      "sellerOrderId": "example",
      "sellerWebsite": "example"
    },
    "packageCount": 1,
    "plan": "example",
    "recipient": {
      "email": "example",
      "externalId": "example",
      "name": "example",
      "phone": "example"
    },
    "route": {
      "driver": "example",
      "id": "example",
      "plan": "example",
      "state": {
        "completed": true,
        "completedAt": 1,
        "distributed": true,
        "distributedAt": 1,
        "notifiedRecipients": true,
        "started": true,
        "startedAt": 1
      },
      "stopCount": 1,
      "title": "example"
    },
    "stopPosition": 1,
    "timing": {
      "earliestAttemptTime": {
        "hour": 1,
        "minute": 1
      },
      "estimatedAttemptDuration": 1,
      "latestAttemptTime": {
        "hour": 1,
        "minute": 1
      }
    },
    "trackingLink": "example",
    "type": "stop",
    "webAppLink": "example"
  }
}
```
