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

# Dismiss a worker with an effective date

`POST https://marketplace-api.sequifi.com/v1/users/{id}/terminate`

Module: Users · operationId: `terminateUser` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/terminate-user

Records an effective-dated dismissal for a worker, using the last working day you supply, which may be in the past. The same date twice is a safe retry; a different date for a worker already dismissed this way returns `409`.

**Before you call:**

- `id` is the user id from `GET /v1/users`, not an onboarding id.
- Decide the last working day. `effective_date` is required and has no default.

**What happens:**

- The dismissal is added to the worker's employment history with your `effective_date`. App sign-in is turned off and the rest of Sequifi updates as it does for the same change made in the app.
- `effective_date` is the last day worked, not the first day gone. A worker dismissed effective the 15th is still paid for a pay period that starts on the 15th, and is left out of every period that starts after it.
- Commissions already earned are not affected. Amounts already owed keep paying out through normal payroll, and a later milestone on a sale the rep already owns still earns commission. Holding back a departed rep's pending pay is a separate admin action that this API does not offer.
- This API cannot reverse the record. A worker is brought back with Rehire in the web app, which starts a new contract. A call sent in error needs Sequifi support.
- `POST /v1/users/termination` is different: it toggles a dismissal dated today and records no last working day.

**Idempotency and retries:**

- Sending the same `effective_date` again returns `200` with `already_terminated: true` and changes nothing, so a timed-out call is safe to retry with the same date.
- A different `effective_date` for a worker already dismissed this way returns `409` with the date on file.

**Formats:**

- `effective_date` is `YYYY-MM-DD` and must be a real calendar day. Other body fields are ignored.
- The success response `status` is the number `200`.

**Errors:**

- `400` `Invalid user id`, `Invalid JSON body`, or one of the two `effective_date` messages in the examples.
- `404` with `data.code` `NOT_FOUND`: no user with that id.
- `409` with `data.code` `ALREADY_TERMINATED`: terminated on another date (`data.effective_date`).
- `500` with `data.code` `TERMINATION_FAILED`, or `Could not resolve the tenant host`. Contact Sequifi support if it repeats.
- `502` `The tenant returned an unreadable response` or `Could not reach the tenant`: retry later with the same date.
- `503`: your company is not set up for this endpoint yet. Contact Sequifi support.
- `504`: no answer in time. The dismissal may still have been applied, so retry with the same date and read `already_terminated`.
- Errors passed back from Sequifi carry `data.code` and `data.requestedBy`.
- `401` when the token is missing, malformed, expired or revoked. It is rejected before the request is processed, so the body is only `{"message":"Unauthorized"}`, with no `status` or `data`.

**Related:**

- `GET /v1/users/{id}` to confirm the change.
- `POST /v1/users/termination` to dismiss a worker without a last working day, or undo that dismissal.

## Path parameters

- `id` (integer, **required**): User id from `GET /v1/users`. Minimum: 1. Example: `4821`.

## Request body

- `effective_date` (string (date), **required**): The worker's last working day, YYYY-MM-DD. May be in the past. Example: `2026-09-15`.

Example

```json
{
  "effective_date": "2026-09-15"
}
```

## Example request

```bash
curl -X POST "https://marketplace-api.sequifi.com/v1/users/4821/terminate" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"effective_date":"2026-09-15"}'
```

## Responses

### 200: Dismissal applied, or already on file for this date

- `status` (integer): The HTTP status code, repeated. Example: `200`.
- `message` (string): Short text. Wording varies by endpoint; branch on the HTTP status, not on this text. Example: `success`.
- `data` (object)
  - `requestedBy` (string): Name of the API credential your token belongs to.
  - `user_id` (integer): The dismissed worker.
  - `effective_date` (string (date)): Last working day on file, YYYY-MM-DD.
  - `already_terminated` (boolean): True when this date was already on file and nothing changed.

Example (applied): Dismissal applied

```json
{
  "status": 200,
  "message": "Termination applied.",
  "data": {
    "requestedBy": "acme",
    "user_id": 4821,
    "effective_date": "2026-09-15",
    "already_terminated": false
  }
}
```

Example (repeated): Same date sent again (safe retry)

```json
{
  "status": 200,
  "message": "User is already terminated effective this date.",
  "data": {
    "requestedBy": "acme",
    "user_id": 4821,
    "effective_date": "2026-09-15",
    "already_terminated": true
  }
}
```

### 400: Invalid id, body or date

Example (missing_effective_date): effective_date not sent

```json
{
  "status": 400,
  "message": "effective_date is required. It is the employee's last working day, in YYYY-MM-DD format.",
  "data": {}
}
```

### 401: Missing, malformed, expired or revoked token. Rejected before processing, so the body has only `message`.

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

### 404: No user with that id

```json
{
  "status": 404,
  "message": "No user with id 4821.",
  "data": {
    "requestedBy": "acme",
    "code": "NOT_FOUND"
  }
}
```

### 409: Already dismissed with a different effective date

```json
{
  "status": 409,
  "message": "User 4821 is already terminated effective 2026-09-15.",
  "data": {
    "requestedBy": "acme",
    "code": "ALREADY_TERMINATED",
    "user_id": 4821,
    "effective_date": "2026-09-15"
  }
}
```

### 500: The dismissal could not be applied

```json
{
  "status": 500,
  "message": "The termination could not be applied.",
  "data": {
    "requestedBy": "acme",
    "code": "TERMINATION_FAILED"
  }
}
```

### 502: Sequifi could not complete the request. Retry later with the same date.

```json
{
  "status": 502,
  "message": "Could not reach the tenant",
  "data": {
    "user_id": 4821
  }
}
```

### 503: Your company is not set up for effective-dated dismissals over the API. Contact Sequifi support; this is not a problem with your token.

Example (not_configured): Not configured

```json
{
  "status": 503,
  "message": "This tenant is not configured for termination over the API. Contact Sequifi support.",
  "data": {}
}
```

### 504: No answer in time. The dismissal may still have been applied; retry with the same `effective_date` and read `already_terminated`.

```json
{
  "status": 504,
  "message": "The tenant did not respond in time. The termination may still have been applied — retry this call with the same effective_date: it returns already_terminated=true if the first attempt landed.",
  "data": {
    "user_id": 4821
  }
}
```
