# Assign user to jobs

Users can be assigned to fulfillmenttools jobs to designate responsibility for the work. This function helps distribute the workload in advance among different employees. The user must exist in the system before they can be assigned to a job.

{% hint style="warning" %}
Assigning a user to a job is for informational purposes only. fulfillmenttools doesn't restrict job interactions to the assigned user; any user with the appropriate permissions can interact with the job.
{% endhint %}

User assignment is available for the following job types:

* Pick jobs
* Pack jobs
* Handover jobs
* Service jobs
* Stow jobs

## Assignment during job creation

To assign one or more users when a job is created, include the `assignedUsers` array in the request body.

```http
POST https://{projectId}.api.fulfillmenttools.com/api/{JOB_ENTITY}
```

The `{JOB_ENTITY}` placeholder represents the specific job endpoint, such as `pickjobs` or `packjobs`. The body must include the `assignedUsers` array as shown in the following examples.

{% tabs %}
{% tab title="By `userId`" %}
This example assigns a user by their `userId`.

```json
{
  // Any job object
  ...
  "assignedUsers": [
    {
      "userId": "{USER_ID}"
    }
  ]
}
```

{% endtab %}

{% tab title="By `userName`" %}
This example assigns a user by their `userName`.

```json
{
  // Any job object
  ...
  "assignedUsers": [
    {
      "userName": "{USER_NAME}"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Updating assigned users

The `REPLACE_ASSIGNED_USERS` action updates the users assigned to a job. This action fully replaces the existing list of assigned users with the new list provided in the request body. If an empty array is provided, all current assignments are removed.

```http
POST https://{projectId}.api.fulfillmenttools.com/api/{JOB_ENTITY}/actions
```

The action body must conform to one of the following examples.

{% tabs %}
{% tab title="By `userId`" %}
This example replaces the assigned user list using a `userId`.

```json
{
  "name": "REPLACE_ASSIGNED_USERS",
  "assignedUsers": [
    {
      "userId": "{USER_ID}"
    }
  ],
  "version": 2
}
```

{% endtab %}

{% tab title="By `userName`" %}
This example replaces the assigned user list using a `userName`.

```json
{
  "name": "REPLACE_ASSIGNED_USERS",
  "assignedUsers": [
    {
      "userName": "{USER_NAME}"
    }
  ],
  "version": 2
}
```

{% endtab %}
{% endtabs %}
