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

# Create a bonus, fine/fee or reimbursement request

`POST https://marketplace-api.sequifi.com/v1/requests`

Module: Requests · operationId: `createRequest` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/create-request

Creates one bonus, fine/fee or reimbursement request for a worker. It is the same request an admin creates on the Requests & Approvals page, except that it always starts as **Pending**: it waits for an admin to approve it, and nothing is paid until they do. Use it to send the bonuses and fines you track in your own system instead of entering them one at a time.

**Before you call:**

- Name the worker with `user_email` or `user_id`, not both. `GET /v1/users` returns both.
- Send every amount as a positive number, including a fine. The type says whether it adds to or comes out of pay.
- Write `description` for the worker. It is what they see on their pay stub.
- Send your own `external_id` with every request. It is what makes a retry safe (see below).

**What happens:**

- Sequifi creates the request as `Pending`, numbered like any other request (`B` for a bonus, `FF` for a fine/fee, `R` for a reimbursement).
- It goes to your company's admins, not the worker's manager. Admins find it under Requests & Approvals, Pending, and approve or decline it there.
- Once approved, it is paid like a request created in the app.
- **Straight onto a payroll (on request):** send `pay_period_from`, `pay_period_to` and `approve: true` and the request skips admin approval and goes onto that payroll, the same as Add Request on Run Payroll. The worker then appears on Run Payroll even with no other pay that period. Sequifi turns this on per company; ask your Sequifi contact. The period must be an open pay period on the worker's own pay schedule, with both dates exactly matching it. `approve: true` is your approval of that one request: Sequifi records it on the request as approved through the API by your credential.
- `date` is the request date for a bonus or fine/fee, and the cost date for a reimbursement.

**Limits (per company):**

- 60 calls a minute. Over the limit returns `429` with a `Retry-After` header.
- Creates run one at a time. A call that waits more than 10 seconds behind another returns `409` with `data.code` `CREATE_IN_PROGRESS`. To send many requests, send them one after another.

**Idempotency and retries:**

- With an `external_id`, a retry is safe. If a request with that `external_id` already exists, the call returns `409` with `data.code` `REQUEST_ALREADY_EXISTS` and the existing request in `data.request`, and creates nothing. Treat that as success.
- Without an `external_id`, two identical calls create two requests. That is right for two identical fines and wrong for a retry.
- After a `504`, the request may still have been created. Re-send the identical body with the same `external_id` to find out.

**Errors:**

- `400`: a field failed validation. The message names it. Nothing was sent to Sequifi.
- `409` with `data.code` `REQUEST_ALREADY_EXISTS` (see above) or `CREATE_IN_PROGRESS` (retry in a moment).
- `422` with `data.code` `USER_NOT_FOUND` (no user with that email or id), `USER_AMBIGUOUS` (more than one user has that email; `data.user_ids` lists them, send `user_id` instead) or `USER_NOT_ACTIVE` (the worker was terminated, dismissed or past their contract end on `date`).
- `422` with `data.errors`: a field was refused by Sequifi's own validation, keyed by field.
- `403` with `data.code` `PAYROLL_SCHEDULING_NOT_ENABLED`: a pay period was sent but your company is not set up for it. Send without the two dates to create a pending request.
- `422` with `data.code` `APPROVAL_REQUIRED`: a pay period was sent without `approve: true`.
- `422` with `data.code` `PAY_PERIOD_NOT_OPEN` (the dates are not an open pay period on the worker's schedule) or `NO_PAY_SCHEDULE` (the worker has no pay schedule).
- `409` with `data.code` `PAY_PERIOD_CLOSED`: that payroll is being finalized or has been paid.
- `429`: over the rate limit. Wait for `Retry-After` seconds.
- `500` `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.
- `503`: your company is not set up for this endpoint (`data.code` `NOT_PROVISIONED`, `TYPE_NOT_CONFIGURED` or `CREDENTIAL_MISSING`, or no code). Contact Sequifi support.
- `504`: no answer in time. See retries above.
- `401` when the token is missing, malformed, expired or revoked. It is rejected before the request is processed, so nothing is created.

**Related:**

- `GET /v1/users` to look up a worker's email or id.
- `GET /v1/payroll/{id}/line-items` to see approved requests on a pay stub.

## Request body

- `type` (string, **required**): What the request is. A bonus and a reimbursement add to pay; a fine/fee comes out of it. One of: `bonus`, `fine_fee`, `reimbursement`.
- `user_email` (string (email)): The worker's email in Sequifi. Send this or `user_id`, not both. Max length: 255.
- `user_id` (integer): The worker's Sequifi user id. Send this or `user_email`, not both. Minimum: 1.
- `amount` (number | string, **required**): Positive, at most 2 decimal places, at most 1000000. A number or a numeric string. A fine is positive too. Example: `150`.
- `date` (string (date), **required**): The request date (bonus, fine/fee) or the cost date (reimbursement), as `YYYY-MM-DD`.
- `description` (string, **required**): What the request is for, written for the worker. Shown on their pay stub. Max length: 1000.
- `external_id` (string): Your own id for this request. A second call with the same `external_id` returns the first request instead of creating another. Max length: 100.
- `pay_period_from` (string (date)): Optional, with `pay_period_to`. Puts the request straight onto this payroll instead of leaving it pending. Only for companies Sequifi has turned this on for.
- `pay_period_to` (string (date)): Optional, with `pay_period_from`. The last day of the pay period.
- `approve` (boolean): Required as `true` with a pay period. Your approval of this one request, recorded on it in Sequifi. Ignored without a pay period.

Example (bonus_by_email): A bonus, worker named by email

```json
{
  "type": "bonus",
  "user_email": "carson@example.com",
  "amount": 150,
  "date": "2026-10-19",
  "description": "Top closer, week of Oct 12",
  "external_id": "bonus-2026-10-19-0042"
}
```

Example (fine_by_id): A fine, worker named by id

```json
{
  "type": "fine_fee",
  "user_id": 428,
  "amount": 25,
  "date": "2026-10-19",
  "description": "Late to team meeting",
  "external_id": "fine-2026-10-19-0007"
}
```

Example (bonus_onto_payroll): A bonus straight onto a payroll (companies set up for it)

```json
{
  "type": "bonus",
  "user_email": "carson@example.com",
  "amount": 150,
  "date": "2026-10-19",
  "description": "Top closer, week of Oct 12",
  "external_id": "bonus-2026-10-19-0043",
  "pay_period_from": "2026-10-19",
  "pay_period_to": "2026-10-25",
  "approve": true
}
```

## Example request

```bash
curl -X POST "https://marketplace-api.sequifi.com/v1/requests" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"type":"bonus","user_email":"carson@example.com","amount":150,"date":"2026-10-19","description":"Top closer, week of Oct 12","external_id":"bonus-2026-10-19-0042"}'
```

## Responses

### 201: Created as Pending. It waits for an admin to approve it.

- `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)
  - `id` (integer): The request's id in Sequifi.
  - `req_no` (string): The request number shown in the app, for example `B000124`.
  - `status` (string): `Pending` (waiting for an admin), or `Scheduled` when sent with a pay period (already on that payroll).
  - `type` (string) One of: `bonus`, `fine_fee`, `reimbursement`.
  - `user_id` (integer)
  - `user_email` (string)
  - `amount` (number): As stored, always positive.
  - `date` (string (date))
  - `description` (string)
  - `external_id` (string, nullable)
  - `pay_period_from` (string (date), nullable): The payroll the request is on, when scheduled.
  - `pay_period_to` (string (date), nullable)
  - `warnings` (array of string): Present only when a pay period was sent but not applied (the request was created as pending). Do not re-send; contact Sequifi support.
  - `created_at` (string (date-time))

```json
{
  "status": 201,
  "message": "Request created. It is waiting for an admin to approve it.",
  "data": {
    "id": 9001,
    "req_no": "B000124",
    "status": "Pending",
    "type": "bonus",
    "user_id": 428,
    "user_email": "carson@example.com",
    "amount": 150,
    "date": "2026-10-19",
    "description": "Top closer, week of Oct 12",
    "external_id": "bonus-2026-10-19-0042",
    "created_at": "2026-10-20T16:04:11+00:00"
  }
}
```

### 400: A field failed validation. Nothing was sent to Sequifi.

Example (both_users): Both user_email and user_id

```json
{
  "status": 400,
  "message": "Send exactly one of user_email or user_id to say who the request is for",
  "data": {}
}
```

### 401: Missing, malformed, expired or revoked token. Rejected before processing, so nothing is created.

```json
{
  "status": 401,
  "message": "Unauthorized",
  "data": {}
}
```

### 403: A pay period was sent but your company is not set up to add requests to a payroll

```json
{
  "status": 403,
  "message": "This company is not set up to add requests to a payroll over the API. Send the request without pay_period_from and pay_period_to to create it as pending for an admin to approve.",
  "data": {
    "code": "PAYROLL_SCHEDULING_NOT_ENABLED"
  }
}
```

### 409: A request with this `external_id` already exists, another create is still running, or the payroll is closed

Example (already_exists): Same external_id already used (treat as success)

```json
{
  "status": 409,
  "message": "A request with external_id \"bonus-2026-10-19-0042\" already exists (B000124).",
  "data": {
    "code": "REQUEST_ALREADY_EXISTS",
    "request": {
      "id": 9001,
      "req_no": "B000124",
      "status": "Pending",
      "type": "bonus",
      "user_id": 428,
      "user_email": "carson@example.com",
      "amount": 150,
      "date": "2026-10-19",
      "description": "Top closer, week of Oct 12",
      "external_id": "bonus-2026-10-19-0042",
      "created_at": "2026-10-20T16:04:11+00:00"
    }
  }
}
```

### 422: The worker could not be used, or Sequifi refused a field

Example (user_not_found): No user with that email or id

```json
{
  "status": 422,
  "message": "No user with email carson@example.com in this company.",
  "data": {
    "code": "USER_NOT_FOUND",
    "user_email": "carson@example.com"
  }
}
```

### 429: Over 60 calls a minute. Wait for `Retry-After` seconds.

```json
{
  "status": 429,
  "message": "Too Many Attempts.",
  "data": {}
}
```

### 500: Sequifi could not resolve your company's host

```json
{
  "status": 500,
  "message": "Could not resolve the tenant host",
  "data": {}
}
```

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

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

### 503: Your company is not set up for this endpoint. Contact Sequifi support.

Example (not_configured): Not configured

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

### 504: No answer in time. The request may still have been created; re-send with the same `external_id`.

```json
{
  "status": 504,
  "message": "The tenant did not respond in time. The request may still have been created. Re-post the identical body: you will get 201 if it was not, or 409 REQUEST_ALREADY_EXISTS with the existing request if it was.",
  "data": {}
}
```
