<!-- Generated by scripts/build-docs.js. Edit docs/swagger.yaml or docs/guides/, then run `npm run docs:build`. -->

# Create a user from onboarding

`PUT https://marketplace-api.sequifi.com/v1/onboarding/hire`

Module: Onboarding · operationId: `hireOnboardingEmployee` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/hire-onboarding-employee

Creates an active user (a rep) from an onboarding record and marks the record as hired. This is not the same as **Hire** in the Sequifi app: it only copies the record's data into a new user. Nothing is set up with your company's payroll provider and the person's documents are not moved. No welcome email goes out unless you send `send_welcome_email: true`; without it the rep cannot log in until someone sends one from the app.

**Before you call:**

- Check the record's `status_id` with `GET /v1/onboarding/{id}`. This call does not check it: a Draft record that never got an offer, or a declined or expired one, is hired the same way. Gate on acceptance yourself (for example `status_id` 13, 22 or 23).
- Make sure no user already has the same email or mobile number. The call is refused if one does.
- Plan who will finish the hire in the app (see "Not done" below).

**What happens:**

Done, in one step:

- A new active user is created from the record: name, email, mobile, position, sub-position, office, department, manager, recruiter, team and agreement dates. `worker_type` comes from the sub-position (`1099` when not set). If the record has no recruiter, the recruiter is set to the Marketplace API system user.
- The user gets a new employee id, for example `EMP000245`. It is its own sequence, not derived from `user_id`.
- The record's pay (wages, commissions, upfronts, overrides, withholding, deductions), work emails, extra offices, and manager, office and department history are copied to the user, effective on the record's start date.
- The onboarding record moves to `status_id` 7. Its default name is **Onboarding**, not Hired. It then drops out of `GET /v1/onboarding`.

Not done (an admin has to do these in the Sequifi app):

- No welcome email unless you send `send_welcome_email: true`. Without it the user's password is random and nobody is told it; an admin can send the email from the rep's profile with **Resend Welcome Email**.
- No setup with your company's payroll provider. Payroll onboarding has to be finished in the app.
- The offer letter and onboarding documents stay on the onboarding record, and post-hire documents are not sent.
- No in-app notification, no updates to connected integrations, and no payroll recalculation.
- The person is not added to a team. `team_id` is copied as a label only; use `POST /v1/teams`.
- No background-check email.

**Welcome email (`send_welcome_email: true`):**

- Sends the same welcome email as **Resend Welcome Email** in the app: your company's welcome template with a single-use link to set a password. It sends no offer letter or documents. To send the offer letter and its documents, use `POST /v1/onboarding/{id}/send-offer` before hiring.
- The result is in `data.welcome_email`: `{ "status": "sent" }`, or `{ "status": "not_sent", "code", "message" }`.
- `not_sent` codes: `PASSWORD_ALREADY_SET` (the rep already set a password), `NOT_CONFIGURED` (contact Sequifi support), `NOT_SENT` (the email could not be sent or confirmed; the message says why).

**Idempotency and retries:**

- Not idempotent. A second call for the same record returns `400 Email or mobile number already exists.`
- A slow call can time out at the gateway (about 29 seconds) after the user was created. Before you retry, look for the user with `GET /v1/users?email=<email>` and compare the email exactly.
- `503 Server is busy, please retry.` means nothing was created. Retry after a short wait.
- Hire one record at a time. Two hires at the same moment can be given the same `employee_id`.
- The welcome email is sent after the user is created. If it fails, the call still returns `200` with `data.welcome_email.status` `not_sent`. Do not retry the hire: an admin can send the email with **Resend Welcome Email**.

**Formats:**

- `user_id` is an integer. `employee_id` is a string.
- `onboarding_id` is echoed exactly as you sent it (a string if you sent a string).
- `products` limits which products' commissions, upfronts, overrides and withholding are copied. Deductions are always copied in full. Leave it out to copy everything.
- The response key is `requested_by` here, but `requestedBy` on the GET routes.

**Errors:**

- `400 onboarding_id is required.` and `400 Invalid onboarding_id. Must be a positive integer.`
- `400 Invalid product id(s): <ids>`: a product does not exist, is inactive or was deleted.
- `400 send_welcome_email must be true or false.`
- `400 Email or mobile number already exists.`: a user already has this email or mobile number. Usually the record was already hired, by an earlier call or in the app.
- `400 A required field is missing. Please ensure the position is fully configured.`: the position's setup is incomplete. Ask your company admin to finish it.
- `404 Onboarding employee not found.`
- `503 Server is busy, please retry.`

**Common mistakes:**

- Treating a `200` as "the rep can start". They are not set up for payroll, and they cannot log in unless `data.welcome_email.status` is `sent`.
- Calling `GET /v1/onboarding/{id}` afterwards and treating the `404` as a failure. Hired records leave onboarding; follow the person at `GET /v1/users/{user_id}`.
- Expecting the person to be on a team. Create the membership with `POST /v1/teams`.

**Related:**

- `GET /v1/users/{user_id}` shows the new user with `hiring_status_id` 7 and `onboarding_complete` 0 or false.
- `POST /v1/teams` puts the rep on a team.
- `GET /v1/documents?user_id=<user_id>` finds the person's documents, including those still on the onboarding record.

## Request body

- `onboarding_id` (integer, **required**): The onboarding id to hire, from `POST /v1/onboarding` or `GET /v1/onboarding`. Example: `4821`.
- `products` (array of integer): Product ids. When set, only these products' commissions, upfronts, overrides and withholding are copied. Deductions are always copied. Each must be an active product.
- `send_welcome_email` (boolean): When true, sends the rep the welcome email with a link to set their password after the hire. The result is in `data.welcome_email`. Default false. Example: `true`.

Example (hire): Hire with all products

```json
{
  "onboarding_id": 4821
}
```

Example (hire_and_welcome): Hire and send the welcome email

```json
{
  "onboarding_id": 4821,
  "send_welcome_email": true
}
```

Example (hire_some_products): Hire and copy pay for two products only

```json
{
  "onboarding_id": 4821,
  "products": [
    1,
    2
  ]
}
```

## Example request

```bash
curl -X PUT "https://marketplace-api.sequifi.com/v1/onboarding/hire" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"onboarding_id":4821}'
```

## Responses

### 200: The user was created. They cannot log in yet and are not set up with the payroll provider.

- `status` (integer): Same as the HTTP status code. Example: `200`.
- `message` (string) Example: `success`.
- `data` (object)
  - `requested_by` (string): Label of the API credentials that made the call.
  - `user_id` (integer): The new user's id. Use it with `GET /v1/users/{id}` and `POST /v1/teams`.
  - `employee_id` (string): The new user's employee id, for example `EMP000245`.
  - `onboarding_id` (any): The onboarding id, echoed exactly as sent (number or string).
  - `welcome_email` (object): Only when `send_welcome_email` was true.
    - `status` (string) One of: `sent`, `not_sent`.
    - `code` (string): Only when `not_sent`. `PASSWORD_ALREADY_SET`, `NOT_CONFIGURED` or `NOT_SENT`.
    - `message` (string): Only when `not_sent`. Why it was not sent.

```json
{
  "status": 200,
  "message": "success",
  "data": {
    "requested_by": "acme",
    "user_id": 6150,
    "employee_id": "EMP000245",
    "onboarding_id": 4821,
    "welcome_email": {
      "status": "sent"
    }
  }
}
```

### 400: Invalid input, an inactive product, or a user with this email or mobile number already exists.

Example (missing_onboarding_id): onboarding_id not sent

```json
{
  "status": 400,
  "message": "onboarding_id is required.",
  "data": {}
}
```

### 401: Missing, unknown, expired or disabled token. Sent by the gateway as `{"message":"Unauthorized"}`, without `status` or `data`.

```json
{
  "message": "Unauthorized"
}
```

### 404: No onboarding record has this id.

```json
{
  "status": 404,
  "message": "Onboarding employee not found.",
  "data": {}
}
```

### 500: Unexpected server error. Check `GET /v1/users?email=` before retrying.

```json
{
  "status": 500,
  "message": "Internal Server Error",
  "data": {}
}
```

### 503: Busy assigning the next employee id. Nothing was created. Retry after a short wait.

```json
{
  "status": 503,
  "message": "Server is busy, please retry.",
  "data": {}
}
```
