> ## Documentation Index
> Fetch the complete documentation index at: https://developer.findity.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fields - Per diem expenses

Create per diem (subsistence allowance) expenses with the dynamic Fields system: choose the trip type, build the travel route, record meals and accommodation, and save.

This guide walks you through a per diem from an empty form to a saved expense, then through the checks that run when the user sends it in a report. It builds on [Dynamic fields](https://developer.findity.com/docs/dynamic-fields), which explains the field object, control types and the update cycle. Do the [receipt](https://developer.findity.com/docs/fields-receipt-expenses.md) and [mileage](https://developer.findity.com/docs/fields-milage-expenses.md) guides first if you are new to Fields: per diem is the most complex expense type.

## Overview

A **per diem** (`SubsistenceAllowance`) is a daily allowance an employee claims for a business trip. The user enters where and when they travelled, and which meals and nights were already paid for. Findity calculates the allowance from the country's rules and the organization's settings. Your client never computes an amount.

A per diem has three parts:

* **A category**, which decides whether the trip is **domestic** or **international**.
* **A travel route**: a start stop, an end stop and, for an international trip, one or more stops in between, each with a destination and dates.
* **Deductions**: for each day (or 24-hour period) of the trip, whether breakfast, lunch or dinner was provided and whether accommodation was provided. Provided meals reduce the allowance.

The form is server-driven: the route and the deduction days change shape as the user edits dates and stops, so most edits go back to Findity with a `PUT` before the user continues.

## Prerequisites

1. Complete [Authentication](https://developer.findity.com/docs/accessing.md) and obtain a user-scoped access token. Per diems belong to the signed-in user.
2. Get the organization `id` from [Organizations](https://developer.findity.com/docs/organizations.md). The examples use `ff808181963979e20196397a2098004b`.
3. The organization must have per diem categories. If it has none, the fields call reports `NOT_VALID_CATEGORY_FOUND_FOR_ALLOWANCE` and no form can be opened. An administrator has to set them up.

## Key concepts

<table>
  <colgroup>
    <col width="226" />

    <col width="497" />
  </colgroup>

  <thead>
    <tr>
      <th>Concept</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>**Domestic and international**</td>
      <td>Set by the category. A domestic trip has only a start and an end stop. An international trip has at least one stop in between and an `addStop` command. The category list doesn't say which kind a category is: the fields response shows it.</td>
    </tr>

    <tr>
      <td>**Stop**</td>
      <td>One point of the route, with a destination and dates. Stops are numbered from **1**: the start stop is `1`, the stops in between follow, and the end stop is last.</td>
    </tr>

    <tr>
      <td>**`date1` and `date2`**</td>
      <td>The dates of a stop: departure from the start stop is `date1`, arrival at the end stop is `date2`. The value is local time in the format `yyyy-MM-dd HH:mm` (control type `LOCAL_DATE_TIME`). Which dates a stop shows depends on the organization's settings.</td>
    </tr>

    <tr>
      <td>**Destination**</td>
      <td>The country of a stop, picked from the destinations list. The start and end stops hold the organization's home country and don't show it.</td>
    </tr>

    <tr>
      <td>**Deduction period**</td>
      <td>One day or one 24-hour period of the trip, depending on the organization's settings. Findity creates one deduction group per period from the trip's start and end dates. Periods are numbered from **0**.</td>
    </tr>

    <tr>
      <td>**Recent destinations**</td>
      <td>The destinations list can return the user's recently used destinations first, as suggestions. Findity keeps the last 10 per user and organization, from the stops between start and end.</td>
    </tr>
  </tbody>
</table>

## API endpoints

All endpoints use the Expense API base URL. Examples use the **stage** environment; production uses the same paths on `https://api.findity.com/api/v1/expense`.

```text theme={"system"}
https://stage-api.findity.com/api/v1/expense
```

| Operation | Method | Endpoint |
| - | - | - |
| List per diem categories | `GET` | `/me/organizations/{id}/expensetypes/SubsistenceAllowance/categories` |
| Initialize fields | `GET` | `/me/organizations/{id}/expensetypes/SubsistenceAllowance/fields` |
| Update fields, or run a command | `PUT` | `/me/organizations/{id}/expensetypes/SubsistenceAllowance/fields` |
| List destinations | `GET` | `/me/organizations/{id}/expensetypes/SubsistenceAllowance/destinations` |
| Create the expense | `POST` | `/expenses?format=fields&organizationId={id}&expenseType=SubsistenceAllowance` |
| Update the expense | `PUT` | `/expenses/{expenseId}?format=fields` |

### Required headers

| Header | Value |
| - | - |
| `Content-Type` | `application/json` |
| `Authorization` | `Bearer {access_token}` |

## Step 1 — Initialize the fields

Fetch an empty per diem form:

```sh cURL theme={"system"}
curl -X GET \
  "https://stage-api.findity.com/api/v1/expense/me/organizations/ff808181963979e20196397a2098004b/expensetypes/SubsistenceAllowance/fields" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json"
```

Without a category, Findity picks the organization's first domestic per diem category. To open a saved per diem for editing, add `expenseRecordId={expenseId}`.

The response holds these top-level fields:

| Field property | controlType | Description |
| - | - | - |
| `categoryId` | `LIST` | The per diem category, which decides domestic or international. Mandatory. `requiresUpdate: true`. |
| `expenseReportId` | `LIST` | A draft expense report to add the per diem to. |
| `verification.description` | `TEXT` | What the trip was for, for example `Conference in Oslo`. At most 255 characters, or less if the organization set a lower limit. |
| `verification.accommodationType` | `LIST` | The type of accommodation. Shown only when the organization uses accommodation types, and mandatory when it requires one. |
| `verification.specifications` | `FIELD_GROUP` | The travel route. `requiresUpdate: true`. See Step 3. |
| `verification.mealCompensationOverSubsistenceAllowance` | `SWITCH` | Domestic trips only, when the organization pays meal compensation: claim meal compensation instead of a per diem. Shown only when the trip qualifies. `requiresUpdate: true`. |
| `verification.deductionAndAccommodation` | `FIELD_GROUP` | One group per deduction period. Appears once the start and end dates are valid. See Step 4. |
| `attachments` | `CONTENT_HOLDER` | Optional files, for example a travel invoice. |

Custom dimensions such as project or cost center come last. Render only fields with `visible: true`, and keep the hidden ones in your state.

## Step 2 — Choose the category

Let the user pick the category from the list in `categoryId.url`. Because `categoryId` has `requiresUpdate: true`, send the full fields array back with a `PUT` after the change. The response has the route of the new trip type.

> [!WARNING]
>
> Changing the category between a domestic and an international one clears the travel route and all deductions. Ask the user to pick the category before they fill in the route, or warn them before you send the change.

## Step 3 — Build the travel route

The route group `verification.specifications` holds the stops. The start and end stops' fields sit directly in the group; each stop in between is its own `FIELD_GROUP`, `verification.specifications[n]`.

| Field property | controlType | Description |
| - | - | - |
| `verification.specifications[n].destination` | `LIST` | The country of the stop. Shown and mandatory only on stops between start and end. |
| `verification.specifications[n].localTimeZone` | `LIST` | The time zone at the stop. Shown only on international trips when the organization keeps track of time zones. Findity fills it in from the destination and disables it when the country has one time zone. |
| `verification.specifications[n].date1` | `LOCAL_DATE_TIME` | Departure from the stop, `yyyy-MM-dd HH:mm`. Check `allowFutureDate`. |
| `verification.specifications[n].date2Enabled` | `SWITCH` | Shown when the organization lets the user say whether the assignment ended at this stop. Turning it on shows `date2`; turning it off hides `date2` and clears it. `requiresUpdate: true`. |
| `verification.specifications[n].date2` | `LOCAL_DATE_TIME` | Arrival at the stop, `yyyy-MM-dd HH:mm`. |

On a domestic trip the route is stop `1` (start, with `date1`) and stop `2` (end, with `date2`). An international trip from Sweden to Oslo and back looks like this: stop `1` departs Sweden, stop `2` is Norway, stop `3` returns to Sweden.

> [!NOTE]
>
> Treat a change to any field inside the route as a change that needs a `PUT`: the route group has `requiresUpdate: true`, and the server uses the dates to check their order and to create the deduction periods in Step 4.

### Pick a destination

The destination field's `url` points to the destinations list with `includeSuggestions=5`:

```sh cURL theme={"system"}
curl -X GET \
  "https://stage-api.findity.com/api/v1/expense/me/organizations/ff808181963979e20196397a2098004b/expensetypes/SubsistenceAllowance/destinations?includeSuggestions=5" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json"
```

```json JSON theme={"system"}
{
  "suggestions": [
    { "id": "c81e728d9d4c2f636f067f89cc14862c", "name": "Norway", "section": 0 }
  ],
  "data": [
    { "id": "c4ca4238a0b923820dcc509a6f75849b", "name": "Denmark" },
    { "id": "c81e728d9d4c2f636f067f89cc14862c", "name": "Norway" }
  ],
  "meta": {
    "total": 2,
    "count": 2,
    "sections": [ { "id": 0, "text": "Recent values" } ]
  }
}
```

Show `suggestions` first, under the section text from `meta.sections`, then the full list in `data`. Names come in the user's language, sorted by name. The list depends on the organization's booking country, not on the trip.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `includeSuggestions` | integer | — | Return up to this many of the user's recent destinations in `suggestions`. Only on the first page (`offset` 0) and only without `searchText` or `filter`. |
| `searchText` | string | — | Return destinations whose name contains the text, ignoring case. |
| `filter` | string | — | Return only the destination with this id. |
| `forDate` | string | today | A date, `yyyy-MM-dd`, whose organization settings decide the list. Any other format returns `400 INVALID_DATE`. |
| `max`, `offset` | integer | — | Paging, as on other list endpoints. |

A destination becomes a recent one when the user saves a per diem with it on a stop between start and end.

### Add and remove stops

On an international trip the route has a `COMMAND` field, `verification.specifications.addStop`, whose command is `action=addStop&afterIndex={n}`. Send the full fields array with the command in the query:

```sh cURL theme={"system"}
curl -X PUT \
  "https://stage-api.findity.com/api/v1/expense/me/organizations/ff808181963979e20196397a2098004b/expensetypes/SubsistenceAllowance/fields?action=addStop&afterIndex=2" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{ "fields": [ ...the complete fields array... ] }'
```

This adds an empty stop after stop `2`. The stops after it move up by one, so stop `3` becomes stop `4`. Re-read the indexes from the response; never keep them in your own state across a `PUT`.

| Command | Where you find it | Effect |
| - | - | - |
| `action=addStop&afterIndex={n}` | The `addStop` field's `commands` | Adds an empty stop after stop `n`. International trips only. |
| `action=removeStop&atIndex={n}` | A stop group's `deleteCommand` | Removes stop `n`. Offered only when the trip has at least two stops between start and end. |
| `action=clearAllRoutes` | The route group's `commands` | Removes all stops **and** all deductions. |
| `action=clearAllDeductionsAndAccommodations` | The deduction group's `commands` | Clears all meal and accommodation answers. |

The last three have `confirmationRequired: true`: show the `confirmation` text and send the command only when the user confirms. A command without its `afterIndex` or `atIndex` returns `400 MISSING_PARAMETER`.

## Step 4 — Record meals and accommodation

Once the start and end dates are valid, `verification.deductionAndAccommodation` holds one group per deduction period, `verification.deductionAndAccommodation[i]`, numbered from `0`:

| Field property | controlType | Description |
| - | - | - |
| `verification.deduction[i].date` | `TEXT` | The date of the period, `yyyy-MM-dd`. Hidden. |
| `verification.deduction[i].breakfast`, `.lunch`, `.dinner` | `SWITCH` or `LIST` | Whether the meal was provided. A `SWITCH` by default; a `LIST` when the organization uses meal types, with `NONE` for "not provided" and values from the field's `url`. |
| `verification.accommodation[i].accommodation` | `SWITCH` | Whether accommodation was provided. Left out of the last period, except with 24-hour periods when the organization counts the last one. |
| `verification.deduction[i].accommodationType` | `LIST` | The accommodation type for the day, when the organization sets it per day. |

The groups are regenerated from the dates on every `PUT`, and answers are matched back to their period by date. Shortening the trip drops the answers for the days that no longer exist.

On a domestic trip where the user chose meal compensation, the groups are `verification.mealCompensation[i]` with two switches, `meal1` and `meal2`, instead.

## Step 5 — Save the expense

When the form is complete, create the per diem with the full fields array:

```sh cURL theme={"system"}
curl -X POST \
  "https://stage-api.findity.com/api/v1/expense/expenses?format=fields&organizationId=ff808181963979e20196397a2098004b&expenseType=SubsistenceAllowance" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{ "fields": [ ...the complete fields array... ] }'
```

To change a saved per diem, send the full fields array to `PUT /expenses/{expenseId}?format=fields`.

A save with validation errors returns `400 VALIDATION_FAILED_FOR_EXPENSE_RECORD` and stores nothing. Add `forceSave=true` to save it anyway as a draft the user fixes later. A route without stops, a stop between start and end without a destination, or an enabled date without a value can't be force-saved.

### Using the JSON format

A backend integration that owns its data can send the per diem as JSON to `POST /expenses` instead. The stops go in `verification.specifications` in route order, and their role comes from their position: the first is the start, the last is the end. This is the Oslo trip from Step 3:

```json JSON theme={"system"}
{
  "organizationId": "ff808181963979e20196397a2098004b",
  "categoryId": "fad615ab023c4972a14877b2cd89efae",
  "verification": {
    "type": "SubsistenceAllowance",
    "description": "Conference in Oslo",
    "specifications": [
      { "destinationId": "2b9fbaa2630511e18824b0dd45bff075", "date1": "2026-03-03 08:00", "date1enabled": true, "date2enabled": false },
      { "destinationId": "c81e728d9d4c2f636f067f89cc14862c", "date1": "2026-03-05 15:00", "date1enabled": true, "date2enabled": false },
      { "destinationId": "2b9fbaa2630511e18824b0dd45bff075", "date2": "2026-03-05 18:00", "date1enabled": false, "date2enabled": true }
    ],
    "deductions": [
      { "date": "2026-03-03T00:00:00Z", "accommodation": true, "deductionTypeBreakfast": "PAID_YOURSELF", "deductionTypeLunch": "PAID_YOURSELF", "deductionTypeDinner": "PAID_YOURSELF" },
      { "date": "2026-03-04T00:00:00Z", "accommodation": true, "deductionTypeBreakfast": "BREAKFAST_IN_HOTEL", "deductionTypeLunch": "PAID_YOURSELF", "deductionTypeDinner": "PAID_YOURSELF" },
      { "date": "2026-03-05T00:00:00Z", "accommodation": false, "deductionTypeBreakfast": "BREAKFAST_IN_HOTEL", "deductionTypeLunch": "PAID_YOURSELF", "deductionTypeDinner": "PAID_YOURSELF" }
    ]
  }
}
```

`PAID_YOURSELF` means the meal was not provided. The other meal values are `FOOD_BENEFITS`, `BREAKFAST_IN_HOTEL`, `FOOD_IN_TICKET`, `FOOD_IN_REPRESENTATION` and `LUNCH_BENEFITS_SODEXO`. The [Create expense](https://developer.findity.com/reference/expense/expenses/create-a-new-expense.md) reference has the full schema.

## Step 6 — Send it in a report

Add the per diem to a report with `expenseReportId`, or through [Expense reports](https://developer.findity.com/docs/expense-reports.md), and send the report. When the report is sent, Findity checks that per diems don't overlap:

* `OVERLAPPING_SUBSISTENCE_ALLOWANCE_IN_CURRENT_REPORT`: the per diem's dates overlap another per diem in the same report. Only the later per diem of an overlapping pair gets the error.
* `OVERLAPPING_SUBSISTENCE_ALLOWANCE_IN_OTHER_REPORT`: the dates overlap a per diem in another of the user's submitted reports.

The code ends in `_TWO` when the per diem overlaps two others and in `_MORE` when it overlaps three or more. Both are `BLOCKER`s, so the report can't be sent until the user changes the dates or removes a per diem. `errorText` names the per diems and the dates, for example:

```json JSON theme={"system"}
{
  "result": "error",
  "description": "Error sending report",
  "validationErrors": [
    {
      "error": "OVERLAPPING_SUBSISTENCE_ALLOWANCE_IN_CURRENT_REPORT",
      "errorText": "\"Conference in Oslo\" overlaps \"Trip to Bergen\" on 3/3/26 – 3/5/26",
      "checkType": "BLOCKER",
      "expenseRecordId": "8b2f0a8d1c5e4f7a9d3b6e2c1a0f9e8d"
    }
  ]
}
```

A per diem without a description is named by its dates. An organization can turn the overlap check off.

## Error handling

| Status code | Error code | Description |
| - | - | - |
| `400` | `VALIDATION_FAILED_FOR_EXPENSE_RECORD` | The per diem has validation errors and was not saved. Show the errors, or save with `forceSave=true`. |
| `400` | `MISSING_PARAMETER` | A command was sent without `afterIndex` or `atIndex`. |
| `400` | `INVALID_DATE` | `forDate` on the destinations list is not `yyyy-MM-dd`. |

Validation errors come back in `validationErrors`, or on the field itself as `error` and `errorText`:

| Error code | checkType | When |
| - | - | - |
| `INVALID_DATE_OR_TIME` | Field error | A date is earlier than the date before it on the route. Set on the later field. |
| `REQUIRED_FIELD` | `ERROR` | The route has no stops, a stop between start and end has no destination, or an enabled date is empty. |
| `TRAVEL_END_BEFORE_START` | `BLOCKER` | The trip's end is not after its start. |
| `FUTURE_ALLOWANCE` | `BLOCKER` | When sending: the trip ends after today and the organization doesn't allow per diems in the future. |
| `OVERLAPPING_SUBSISTENCE_ALLOWANCE_IN_CURRENT_REPORT`, `..._IN_OTHER_REPORT` (and `_TWO`, `_MORE`) | `BLOCKER` | When sending: the per diem overlaps other per diems. See Step 6. |

## Next steps

> [card] [Dynamic fields](https://developer.findity.com/docs/dynamic-fields)
>
> The field object, control types and the update cycle.

> [card] [Expense reports](https://developer.findity.com/docs/expense-reports.md)
>
> Add per diems to a report and send it for approval.
