> For the complete documentation index, see [llms.txt](https://docs.samesystem.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.samesystem.dev/business-guides/employee-lifecycle-management/new-employees/hire-employee.md).

# Hire employee

{% hint style="info" %}
**Note:** Users can also be created using **API v1**. However, for user and contract integrations, we strongly recommend using **API v2**, and this guide therefore describes user creation using API v2 only.

If you need to create users using API v1, please refer to the [**API v1 OpenAPI specification**](https://docs.samesystem.dev/api-v1-reference/) for the available endpoint, request parameters, and data model.
{% endhint %}

A new employee with immediate start will require a new user and a new contract. The new employee becomes active on the start date.

<figure><img src="https://2670147116-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRlKDeTWSTdLA0zl6vlB2%2Fuploads%2FDB23oiuhJRuUqnMzVVtt%2Fimage.png?alt=media&amp;token=bcdd0633-d1c7-4d3c-a91d-dbb14faa43d1" alt=""><figcaption></figcaption></figure>

You will have the following options to create the records:

<details>

<summary>Create user and contract in two separate calls</summary>

The user can be created using a post method to this endpoint:

POST /{clientToken}/users

The call returns an object conforming to the `User` schema. The object will contain `id`, which is the SameSystem unique id of the newly created user. Use this <kbd>id</kbd> or a custom id to create a contract on this user.

The contract can afterwards be created using a post method to this endpoint:

POST /{clientToken}/users/{userId}/contracts/insert

The parameter `{userId}` is the unique id number of the user in SameSystem. The value is present in the user object: `user.id`.

It can also be a custom Id, like an employee id or payroll number from an external system. If a custom id is used, you must include the parameter `useCustomId=true` in the call.

</details>

<details>

<summary>Create user and contract in a single call</summary>

To create both the user and the contract in a single call, the following endpoint can be used:

POST /{clientToken}/users/create\_with\_contract

</details>

<details>

<summary>Create/update multiple users and contracts in one call (bulk update/create)</summary>

To create and/or update multiple users with contract in a single call from a payroll or HR system with the use of a custom id (external user id), the following endpoint can be used:

POST /{clientToken}/users/upsert\_with\_contracts

Request body is an array of objects conforming to the `UsertUsersWithContractInput` schema. Each object in the array has a required `externalUserId` and two objects. These two objects conform with the `CreateUserWithContractUserInput` schema for the user data and the `CreateUserWithContractContractInput` for the contract data.

The endpoint will create new users and contracts but can also update existing users with new contracts or update existing contracts on existing users.

**To create new users:**\
If a user in SameSystem with the externalUserId is not found, then it will create a new user with the contract.\
It will primarily use externalUserId to locate the user, but we have built in other logic to prevent the same user from being created.

**To update existing users:**\
If a user in SameSystem with the externalUserId is found, then it will update the user with information from CreateUserWithContractUserInput.

**To update existing contracts on users:**\
If a user in SameSystem with the externalUserId is found, then it will update the user with information from CreateUserWithContractUserInput and it will try to locate the contract based on startDate, and if the contract is found, it will update it using information from CreateUserWithContractContractInput.\
\
Flow:

<figure><img src="https://2670147116-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRlKDeTWSTdLA0zl6vlB2%2Fuploads%2FfbKZzDfUT0WtXor9E0rU%2Fimage.png?alt=media&amp;token=7ad1c570-55d5-489f-a69c-83dc326cd826" alt=""><figcaption></figcaption></figure>

The response will return an object conforming to the `UpsertUsersWithContractsResponse` schema. It will return information about the numbers of created, failed and updated users:

`UpsertUsersWithContractsResponse.createdCount`

`UpsertUsersWithContractsResponse.failedCount`

`UpsertUsersWithContractsResponse.updatedCount`

&#x20;More information about failed users can be found in:\
`UpsertUsersWithContractsResponse.failedUsers`, which contains an array of objects conforming to the `FailedUpsertUser` schema. The object will contain an error message and the externalUserId.

</details>

### **How to choose?**

If you need to create multiple users and contracts from an HR-system in a daily scheduled run and you have all available information, it could be an idea to create all users and contracts in one call.

If you need to create a single user and contract immediately from an HR-system, you can create the user and contract in two separate calls or combine the creation of the user and contract in one call.

### Hints

{% hint style="info" %}
Use the field `customId` if you want to add a custom id number to a user. This is useful if you want to integrate with a HR or Payroll system that is using this number. It could be a unique payroll id or employee id.\
The setting “Use custom IDs for employees” must be enabled in General settings – General before customId can be used in the API, otherwise you will get this error:

```json
{
    "errors":[
       {
            "message": "Custom attribute action \"write\" is not allowed",
            "type": "validation error",
            "field": "custom_id",
            "short_message": "attribute action \"write\" is not allowed"
        }
    ]
}
```

If you add a date in `seniorityStartDate`, you will get the error below if the setting “Enable seniority date” is not enabled under **General settings – Vacation planner**.

<pre class="language-json"><code class="lang-json">{
    "errors":[
       {
            "message": "Seniority start date<a data-footnote-ref href="#user-content-fn-1"> attribute action \"write\" is not allowed</a>",
            "type": "validation error",
            "field": "seniority_start_date",
            "short_message": "attribute action \"write\" is not allowed"
        }
    ]
}
</code></pre>

{% endhint %}

[^1]:


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.samesystem.dev/business-guides/employee-lifecycle-management/new-employees/hire-employee.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
