> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.hellotracks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto-assign Jobs

> Use this endpoint to automatically assign jobs to workers.

This API endpoint allows for the automated assignment of a set of jobs to a specified group of workers.

### REQUEST

Initiate a POST request to auto-assign jobs based on specified criteria.

```shell theme={null}
POST https://api.hellotracks.com/api/autoassign

{
	"data": {
		"jobs":  [ "<job_id_1>", "<job_id_2>" , "<job_id_n>" ],
		"workers": [ "<username_1>", "<username_2>" , "<username_n>" ],
		"method": <String> (optional),
		"pickupCapacity": <Int> (optional),
		"dropoffCapacity": <Int> (optional),
		"day": <Int> (optional) // format YYYYMMDD e.g. 20210701
	}
}
```

<ParamField body="jobs" type="array" required>
  Array of job IDs to be assigned.
</ParamField>

<ParamField body="workers" type="array" required>
  Array of worker usernames for job assignment.
</ParamField>

<ParamField body="method" type="string" default={"distance"} optional>
  Assignment method: `distance`, `zones`, or `size`.
</ParamField>

<ParamField body="pickupCapacity" type="integer" optional>
  Pickup capacity constraint for assignment.
</ParamField>

<ParamField body="dropoffCapacity" type="integer" optional>
  Dropoff capacity constraint for assignment.
</ParamField>

<ParamField body="day" type="integer" default={0} optional>
  The specific day for assignment, format YYYYMMDD. Defaults to today when set to `0` or omitted.
</ParamField>

### Configuration

The auto-assignment algorithm considers:

* **Working Hours:** Respects worker availability and shift times
* **Capacity Constraints:** Honors pickup and dropoff capacity limits if specified
* **Zones:** Considers assigned zones for workers (when using `zones` method)
* **Distance:** Optimizes for minimal travel distance (when using `distance` method)

### RESPONSE

Response detailing the assignment status of the jobs.

```
{
	"status": 0,
	"assignedJobs": [ "<job_id_1>", "<job_id_2>" ],
	"unassignedJobs": [ "<job_id_1>", "<job_id_2>" ],
	"jobs": [
		{ <job_1> },
		{ <job_2> },
		   ...
		{ <job_n> }
	]
}
```

<ParamField body="assignedJobs" type="array">
  List of job IDs that were successfully assigned.
</ParamField>

<ParamField body="unassignedJobs" type="array">
  List of job IDs that could not be assigned.
</ParamField>

<ParamField body="jobs" type="array">
  A comprehensive list of all jobs considered during the assignment process.
</ParamField>
