> 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/terminate-employees/terminate-employee-known-end-date.md).

# Terminate employee (known end date)

{% hint style="info" %}
Only available in API v2.
{% endhint %}

In this scenario, the user and a contract have been created in the system.

The employee has either been dismissed or has resigned from his/her position. The user must be able to use the system until the contract ends.

&#x20;To end the employment, an end date must be updated on the contract.

<figure><img src="https://2670147116-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRlKDeTWSTdLA0zl6vlB2%2Fuploads%2FZgYtdGyoJuJF5HT6Oht4%2Fimage.png?alt=media&amp;token=986d5378-0100-4fda-b580-c73fd2e66253" alt=""><figcaption></figcaption></figure>

You will have these options to terminate the employment:

<details>

<summary>Terminate the user</summary>

To terminate the current active contract and the user in a single call, the following endpoint can be used:

POST /{clientToken}/users/{id}/terminate

The parameter `{id}` 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.

Request body is an object conforming to the `ChangeTerminationDateInput` schema.

{% hint style="info" %}
**Notice:**

Terminating a contract triggers background jobs that synchronize/clean-up the user’s calendar lines in the system. While these jobs are running, the user is temporarily marked as updating and contract creation/updating are blocked during the update process.

To make the integration resilient to this, we recommend a retry with backoff if you need to terminate the user and immediately rehire it again.

Example: Add a retry once after 5 seconds, then 30 seconds, and then one minute  rather than assuming the endpoint will always be immediately available.
{% endhint %}

</details>

<details>

<summary>Create new contract with "last" attribute to terminate the user</summary>

For employees with a known employment end date, you can create a new contract using the `last` attribute to define the termination as part of the contract creation.

This allows the employment period and its termination to be created in a single step, without subsequently calling the Terminate User endpoint.

This is particularly useful for temporary or fixed-term employees, where both the start and end date of the employment are already known when the contract is created.

Once the end date is reached, the employee will be considered terminated according to the contract.&#x20;

Use this endpoint to insert a contract:

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

&#x20;

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.

&#x20;Request body is an object conforming to the ContractCreateReplacingInput schema.&#x20;

You will need to set these:

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><code>last:true</code></td><td valign="top"><p>A Boolean. Set to <code>true</code> to terminate user when end date is reached.</p><p> </p></td></tr><tr><td valign="top"><code>enddate</code></td><td valign="top">Set end date. If you omit the <code>enddate</code> the end date will be the date, you call the endpoint.</td></tr></tbody></table>

</details>

After termination, you can see under Contracts that the employment will be ended after the termination date.

<figure><img src="https://2670147116-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRlKDeTWSTdLA0zl6vlB2%2Fuploads%2FyRekSLQqOoXdxOr0PvHp%2Fimage.png?alt=media&amp;token=9047f925-cfe6-45ba-9c1c-b4afe1d647fd" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
**Notice:**

There is an API endpoint for deleting a user. Using this endpoint will permanently remove the user and all associated data, including schedules, logs, files, and historical records.

When the delete endpoint is called, the user is immediately disabled, and the system schedules a background job to permanently destroy the user after 24 hours. During this 24-hour window, the user can still be restored by our support.

The recommended method is to terminate a user. Termination preserves all user data in the system and allows you to rehire the user later or review their historical information.

A terminated user will not have access to the system from the termination date onward, but their data remains available for reporting and audit purposes.
{% endhint %}


---

# 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/terminate-employees/terminate-employee-known-end-date.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.
