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

# Create Jobs

> Create one or multiple jobs.

### Request

```shell theme={null}
POST https://api.hellotracks.com/api/createjobs
{
	data: {
		jobs: [
			 job_1,
			 job_2,
			   ...
			 job_n
		 ],
		 sendRouteChange: <boolean>,
		 autoassign: <boolean>,
		 isTemplate: <boolean>
	}
}
```

<Note>See also [Job-API-Object](../job-object) to see properties of a job.</Note>

<Note>To directly assign a user, set the `worker` property in the job to the worker's username. To get
the worker's username, retrieve the `username` in [Member-API-Object](../member-object), for
example via `/getaccounts`.</Note>

<RequestExample>
  ```bash Example Request theme={null}
  curl -X POST https://api.hellotracks.com/api/createjobs \
  --header 'API-Key: ...' -d \
  '
  {
      "data": {
          "jobs": [
              {
                  "destinationLat": 37.7749,
                  "destinationLng": -122.4194,
                  "destinationName": "Job in San Francisco created via API",
                  "worker": "username@company.com",
                  "day": 20231110
              }
          ]
      }
  }
  '
  ```
</RequestExample>

<ParamField body="jobs" type="array" required>
  An array of objects, each object needs to confirm the Job API Object schema.

  **Important Notes:**

  * Do not set the `id` field, this will be set automatically upon creation.
  * You can optionally set the `uidSecondary` field as a custom external identifier. If a job with the same `uidSecondary` already exists for the company, the existing job will be updated instead of creating a new one.
  * To assign a job during creation, set the `worker` field to the worker's username or set `receiverUid` to the worker's UID.
  * For custom job fields, use either `customFields` as an array of `{ "key": "...", "val": "..." }` objects, or use `custom_<fieldName>` for single fields.
</ParamField>

<ParamField body="sendRouteChange" default="false" type="boolean">
  If true, assigned and day set to today, notifies assignee immediately of jobs being updated. The list
  of jobs will be updated automatically on their device.
</ParamField>

<ParamField body="autoassign" default="false" type="boolean">
  Indicates that the created jobs should automatically be assigned to a member.
  It will choose the nearest member that is available, taking the shift and day-route into account.
</ParamField>

<ParamField body="isTemplate" default="false" type="boolean">
  If set to `true`, creates jobs as templates rather than regular jobs. Job templates can be reused to create multiple jobs with the same configuration.
</ParamField>

### Custom Fields in `jobs`

Inside each job object, custom fields can be sent in the following format:

* `customFields` array (recommended for multiple fields):

```json theme={null}
"customFields": [
  { "key": "PO_Number", "val": "PO-2026-1234" },
  { "key": "Department", "val": "Facilities" }
]
```

<RequestExample>
  ```bash Example Request (with customFields) theme={null}
  curl -X POST https://api.hellotracks.com/api/createjobs \
  --header 'API-Key: ...' -d \
  '
  {
      "data": {
          "jobs": [
              {
                  "destinationName": "Create job with custom fields",
                  "day": 20260224,
                  "customFields": [
                      { "key": "PO_Number", "val": "PO-2026-1234" },
                      { "key": "Department", "val": "Facilities" }
                  ]
              }
          ]
      }
  }
  '
  ```
</RequestExample>

### Response

```shell theme={null}
{
	status: 0,
	jobs : [
		job_1,
		job_2,
		...
	    job_n
	]
}
```

<ResponseField name="status" type="number" required>
  Guaranteed to be set. Set to `0` if successful.
</ResponseField>

<ResponseField name="jobs" type="array" required>
  The array of all jobs created by this request.
</ResponseField>

<RequestExample>
  ```bash Example Request theme={null}
  curl -X POST https://api.hellotracks.com/api/createjobs --header 'API-Key: ...' -d '
  {
      "data": {
          "jobs": [
              {
                  "destinationLat": 37.7749,
                  "destinationLng": 122.4194,
                  "destinationName": "This is a new job in San Francisco created via API"
              }
          ]
      }
  }
  '
  ```
</RequestExample>

<Snippet file="jobs-response.mdx" />
