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

# Distribute Jobs

> You can distribute multiple jobs, e.g. 100 jobs, into a few regions/clusters, e.g. 10 clusters.

This API endpoint is designed to distribute a set of jobs across specified regions or clusters.

### REQUEST

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

{
	data: {
		jobs:  [
			"<job_id_1>",
			"<job_id_2>",
			   ...
			"<job_id_n>"
		],
		regions: 5,
		max: 10,
		method: "distance",
	}
}
```

<ParamField body="jobs" type="array" required>
  Array of job ids.
</ParamField>

<ParamField body="regions" type="number" required>
  Number of regions/clusters to split all jobs ids into.
</ParamField>

<ParamField body="max" type="number" default={28} optional>
  The maximum number of jobs per cluster.
</ParamField>

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

### RESPONSE

```shell theme={null}
{
	"status": 0,
	"clusters": [
			{
				"id": <number>,
				"name": "Cluster 1",
				"center_lat": <latitude>,
				"center_lng": <longitude>,
				"jobs": ["<job_id>",...,"<job_id>"]
			},
			...
			{ ... }
	]
}
```

<ResponseField name="status" type="number">
  Status code. `0` indicates success.
</ResponseField>

<ResponseField name="clusters" type="array">
  An array of cluster objects, each containing:

  * `id` (number): Unique cluster identifier
  * `name` (string): Cluster name (e.g., "Cluster 1", "Cluster 2")
  * `center_lat` (double): Latitude of cluster center point
  * `center_lng` (double): Longitude of cluster center point
  * `jobs` (array): Array of job IDs assigned to this cluster
</ResponseField>

### Usage Notes

* The clustering algorithm groups jobs geographically to minimize travel distance within each cluster
* The `max` parameter prevents any single cluster from becoming too large
* Empty clusters may be returned if the number of jobs is less than the requested regions
* The algorithm uses the company location as the initial center point for all clusters
