# Create an employee advance request

Operation ID: `createEmployeeAdvanceRequest`

Group: Accounting › Employee Advances

[Open in the interactive reference](https://docs.api.lensing.ai/lensing/v1/endpoints/createEmployeeAdvanceRequest)

`POST /accounting/employee-advances`

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Creates an employee advance request for the employee who sends it. The advance is in that employee's legal entity. There is no field to name another employee. The response is only the new request's id.

The request is created in 'pendingApproval' and goes straight into your tenant's approval policy. The request can already be approved by the time the response arrives, for example when that employee is also the policy's approver.

No payment or journal entry is created until the approved request is issued with POST accounting/employee-advances/:id/issue.

Read the request's status with GET accounting/employee-advances/:id.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | string · v1 | yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version `v1`. |
| `Idempotency-Key` | header | string | no | An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with `400 IDEMPOTENCY_NOT_SUPPORTED` rather than silently ignored. |

## Request body

Required, `application/json`: createEmployeeAdvanceRequestInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `categoryId` | string | yes | Id (a UUID) of the AdvancePaymentCategory this request draws from. Must belong to the calling employee's own entity. Example: `"5c8e2f14-9a3b-4d67-8e21-1b4c6a9d3e02"`. |
| `amount` | decimal | yes | Requested amount, in the calling employee's entity functional currency. Must be greater than zero. Stored as the request's single purpose line. Example: `"750.00"`. |
| `purpose` | string | yes | What the advance is for, e.g. the trip or event. Required, non-blank. Stored as the request's single purpose line. Example: `"Client site visit — flights and hotel"`. |
| `tripStart` | date | no | First day of the trip the advance covers. Optional. Example: `"2026-09-10"`. |
| `tripEnd` | date | no | Last day of the trip the advance covers. Must not be before tripStart. Optional. Example: `"2026-09-13"`. |
| `notes` | string | no | Free-text notes from the requester. Optional. |
| `requestDate` | date | no | The requester's own calendar day, as observed client-side. Omit to default to the appserver's current day. |
| `attachments` | array<object> | no | Files to attach to the request. Each names an already-uploaded file by its id. A tenant may require at least one; see ATTACHMENT_REQUIRED. Example: `[{"fileName":"itinerary.pdf","fileId":"3f9c1e2a-7b4d-4e6f-9a1c-2d5e8f0b6c3a"}]`. |
| `attachments[].fileName` | string | yes | Display name of the attached file. |
| `attachments[].fileId` | string | yes | Id of the already-uploaded file. |

```json
{
  "categoryId": "5c8e2f14-9a3b-4d67-8e21-1b4c6a9d3e02",
  "amount": "750.00",
  "purpose": "Client site visit — flights and hotel",
  "tripStart": "2026-09-10",
  "tripEnd": "2026-09-13",
  "notes": "<notes>",
  "requestDate": "2026-01-15",
  "attachments": [
    {
      "fileName": "itinerary.pdf",
      "fileId": "3f9c1e2a-7b4d-4e6f-9a1c-2d5e8f0b6c3a"
    }
  ]
}
```

## Response

`200` Success

Under `data` (createEmployeeAdvanceRequestOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Id (a UUID) assigned to the newly created advance request. Example: `"b81f4a22-6d90-4c53-8e17-9f2a4b6c8d05"`. |

```json
{
  "data": {
    "id": "b81f4a22-6d90-4c53-8e17-9f2a4b6c8d05"
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}
```

## Response headers

- `Idempotency-Replayed` — Present and `true` only when this response replays a previously stored one for the same Idempotency-Key, rather than reflecting a live execution. Absent on a live response - never sent as `false`.

## Errors

| Code | Status |
| --- | --- |
| `CATEGORY_NOT_FOUND` | 400 |
| `CATEGORY_WRONG_ENTITY` | 400 |
| `NO_FUNCTIONAL_CURRENCY` | 400 |
| `INVALID_AMOUNT` | 400 |
| `MISSING_PURPOSE` | 400 |
| `PURPOSE_NOT_FOUND` | 400 |
| `INVALID_TRIP_DATES` | 400 |
| `ATTACHMENT_REQUIRED` | 400 |
| `ADVANCE_LIMIT_EXCEEDED` | 400 |
| `UNEXPECTED_ERROR` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: CATEGORY_NOT_FOUND, CATEGORY_WRONG_ENTITY, NO_FUNCTIONAL_CURRENCY, INVALID_AMOUNT, MISSING_PURPOSE, PURPOSE_NOT_FOUND, INVALID_TRIP_DATES, ATTACHMENT_REQUIRED, ADVANCE_LIMIT_EXCEEDED, UNEXPECTED_ERROR
- `401` — The request carries no valid access token.
- `403` — Not authorized
- `404` — Not found
- `409` — The Idempotency-Key is still being processed by another request.
- `422` — The Idempotency-Key was already used with a different request payload.
- `429` — Too many requests from this client address. The response has no body and no `Retry-After` header.
- `500` — Internal server error
