# Console: billing

Source: https://docs.neode.sk/development/api-reference/console-billing/
Last updated: 2026-12-03

> 28 operations. Billing: packages, contracts, sessions, reports and the clock.

These routes are on the console, port 3375. They take an API token as `Authorization: Bearer ndt_...`; see [API tokens](https://docs.neode.sk/command-line/api-tokens.md).

Billing: packages, contracts, sessions, reports and the clock.

## GET /api/panel/billing/check

Check whether a device may start a billed session.

Answers allowed: true without a contract. For an account limited to some devices, a device_id outside its devices answers 403.

Needs `device.connect`. `neodesk billing check` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `device_id` | query | string | yes | The device |

**200**: Done (`application/json`)

[BillingConnectionCheck](https://docs.neode.sk/development/api-reference/schemas.md#billingconnectioncheck).

| Error | When |
|---|---|
| 400 | device_id is missing (device_id required) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/panel/billing/clock/detect-timezone

Show the time zone of the console's machine and the zones to pick from.

Needs server.config or billing.view.

`neodesk billing timezone` calls it.

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `success` | `true` |  |
| `timezone` | string | The time zone of the machine the console runs on; UTC when it can't tell |
| `common` | array of string | The time zones the settings page lists |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/panel/billing/clock/settings

Show the billing clock settings.

Needs server.config or billing.view. The settings come from the server where it takes them at once (dockerMode), else from the console's .env file; what is not set there has its default.

`neodesk billing clock` calls it.

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `success` | `true` |  |
| `settings` | [BillingClockSettings](https://docs.neode.sk/development/api-reference/schemas.md#billingclocksettings) |  |
| `dockerMode` | boolean | true where the server takes a save at once, without a restart |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The settings could not be read |

## PUT /api/panel/billing/clock/settings

Change the billing clock settings (they apply after a restart).

A setting not in the body gets its default: ntp_servers pool.ntp.org,time.google.com,time.cloudflare.com, max_skew_ms 2000, require_synced_clock true, trust_os_ntp true on Linux, server_timezone UTC. Outside Docker the settings go into the .env file and the server's service definition and apply after a restart: the save joins your restart transaction (restartRequired), which can put the old settings back. Where the server takes them at once (dockerMode) there is no restart.

Needs `server.config`. `neodesk billing clock-set` calls it.

Request body, `application/json`:

At least one of the fields.

| Field | Type | What it is |
|---|---|---|
| `ntp_servers` | string | Host names or IP addresses, separated by commas; at least one |
| `max_skew_ms` | integer | at least 1, at most 600000 |
| `require_synced_clock` | boolean |  |
| `trust_os_ntp` | boolean |  |
| `server_timezone` | string | The server's time zone (SERVER_TIMEZONE), an IANA name |

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `success` | `true` |  |
| `settings` | [BillingClockSettings](https://docs.neode.sk/development/api-reference/schemas.md#billingclocksettings) |  |
| `serviceConfig` |  | What the check of the server's service definition found; null in the layout with two containers |
| `status` |  | The server's clock status after a save in the layout with two containers; null otherwise |
| `restart` | null |  |
| `restartRequired` | object or null | Your restart transaction with this change; null in dockerMode |
| `restartRequired.id` | string |  |
| `restartRequired.phase` | string |  |
| `restartRequired.status` | string |  |
| `restartRequired.ready` | boolean |  |
| `restartRequired.failed` | boolean |  |
| `restartRequired.startedAt` | string (date-time) |  |
| `restartRequired.updatedAt` | string (date-time) |  |
| `restartRequired.changes` | array of object |  |
| `restartRequired.changes[].key` | string |  |
| `restartRequired.changes[].label` | string |  |
| `restartRequired.error` |  | What failed in the restart; null otherwise |
| `dockerMode` | boolean |  |

| Error | When |
|---|---|
| 400 | No setting in the body (No settings to save), or a value is refused: invalid_ntp_servers, invalid_max_skew or invalid_server_timezone |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | Another operator's restart transaction waits (restart_transaction_owned); nothing was written |

## GET /api/panel/billing/contracts

List billing contracts.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. For an account limited to some devices the list keeps the contracts of its devices, of the device groups and folders open to it, and of organizations that hold one of its devices.

Needs `billing.view`. `neodesk billing contracts` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `target_type` | query | string, one of `device_group`, `org`, `device`, `folder` | Only contracts of this kind of target |
| `target_key` | query | string | With target_type: only the contract of this target |
| `org_id` | query | string | Only the contract of this organization; ignored when target_type and target_key are given |
| `status` | query | string | Only contracts with this status |

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `contracts` | array of [BillingContract](https://docs.neode.sk/development/api-reference/schemas.md#billingcontract) | Last changed first |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/panel/billing/contracts

Make a billing contract.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Gives a package to a device group, an organization or a device. A target has at most one contract in force.

Needs `billing.manage`. `neodesk billing contract-create` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `target_type` | string, one of `device_group`, `org`, `device` |  | What the package is given to. A folder is refused. |
| `target_key` | string | yes | The device group GUID, organization id or device id |
| `org_id` | string |  | Older form: stands for target_type org with this target_key |
| `package_id` | string | yes |  |
| `status` | string |  | active when empty; default `"active"` |
| `remaining_minutes` | integer |  | The package's included minutes when 0 or missing |
| `overage_rate_minor` | integer or null |  | The contract's own price per hour beyond the included minutes, in minor units of currency: cents of EUR, yen of JPY, fils of BHD; null or left out: the package's; at least 0 |
| `hourly_rate_minor` | integer |  | Price per hour of the included minutes, in minor units of currency: cents of EUR, yen of JPY, fils of BHD; at least 0 |
| `currency` | string |  | A contract bills in its package's currency: a currency other than the package's is refused with 400 |
| `valid_from` | string (date-time) |  |  |
| `valid_until` | string (date-time) |  |  |
| `id` | string |  | A new UUID when empty |

**201**: Created (`application/json`)

[BillingContract](https://docs.neode.sk/development/api-reference/schemas.md#billingcontract).

| Error | When |
|---|---|
| 400 | target_type and target_key required, an invalid or folder target_type, or package_id required |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | The target already has a contract (assignment already exists for this target) |

## PUT /api/panel/billing/contracts/{contractId}

Change a billing contract.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Changes only the fields in the body.

Needs `billing.manage`. `neodesk billing contract-set` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `contractId` | path | string | yes | The contract id |

Request body, `application/json`:

The fields to change. Fields not in the body, and values of the wrong type, keep their value.

| Field | Type | What it is |
|---|---|---|
| `status` | string | Kept when empty; active or suspended |
| `remaining_minutes` | integer |  |
| `overage_rate_minor` | integer or null | The contract's own price per hour beyond the included minutes, in minor units of currency: cents of EUR, yen of JPY, fils of BHD; null or left out: the package's; at least 0 |
| `hourly_rate_minor` | integer | Price per hour of the included minutes, in minor units of currency: cents of EUR, yen of JPY, fils of BHD; at least 0 |
| `currency` | string | A contract bills in its package's currency: a currency other than the package's is refused with 400 |
| `valid_from` | string or null (date-time) | null clears it |
| `valid_until` | string or null (date-time) | null clears it |

**200**: The contract as saved (`application/json`)

[BillingContract](https://docs.neode.sk/development/api-reference/schemas.md#billingcontract).

| Error | When |
|---|---|
| 400 | The server API refused the request, or a path parameter has characters the console does not pass on |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 404 | There is no such contract (contract not found) |

## DELETE /api/panel/billing/contracts/{contractId}

Delete a billing contract.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Answers ok for an id that does not exist too.

Needs `billing.manage`. `neodesk billing contract-delete` calls it. It cannot be undone.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `contractId` | path | string | yes | The contract id |

**200**: Done (`application/json`)

| Field | Type |
|---|---|
| `ok` | `"true"` |

| Error | When |
|---|---|
| 400 | The server API refused the request, or a path parameter has characters the console does not pass on |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/panel/billing/packages

List billing packages.

Needs `billing.view`. `neodesk billing packages` calls it.

**200**: Done (`application/json`)

| Field | Type |
|---|---|
| `packages` | array of [BillingPackage](https://docs.neode.sk/development/api-reference/schemas.md#billingpackage) |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/panel/billing/packages

Make a billing package.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}.

Needs `billing.manage`. `neodesk billing package-create` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `name` | string | yes |  |
| `description` | string |  |  |
| `included_minutes` | integer |  | Minutes per billing month |
| `rounding_minutes` | integer |  | Billing step in minutes; 10 when 0 or less; default `10` |
| `overage_rate_minor` | integer |  | Price per hour once the included minutes are used up, in minor units of currency: cents of EUR, yen of JPY, fils of BHD. The float overage_rate of earlier versions is refused with 400.; at least 0 |
| `currency` | string |  | ISO 4217 code in capitals (EUR, JPY, BHD); other codes are refused with 400. Left out: the default_currency of the billing rules (EUR unless set). It cannot change while the package has contracts (409). |
| `id` | string |  | A new UUID when empty |

**201**: Created (`application/json`)

[BillingPackage](https://docs.neode.sk/development/api-reference/schemas.md#billingpackage).

| Error | When |
|---|---|
| 400 | name is missing or empty (name required) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/panel/billing/packages/{packageId}

Replace a billing package.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Replaces the whole package: a field not in the body is stored empty or 0 (rounding_minutes 1). Send every field.

Needs `billing.manage`. `neodesk billing package-set` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `packageId` | path | string | yes | The package id |

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `name` | string |  |
| `description` | string |  |
| `included_minutes` | integer | Minutes per billing month |
| `rounding_minutes` | integer | Billing step in minutes; 10 when 0 or less; default `10` |
| `overage_rate_minor` | integer | Price per hour once the included minutes are used up, in minor units of currency: cents of EUR, yen of JPY, fils of BHD. The float overage_rate of earlier versions is refused with 400.; at least 0 |
| `currency` | string | ISO 4217 code in capitals; left out: the package keeps its currency. It cannot change while the package has contracts (409). |

**200**: The body as stored; created_at and updated_at are not read back (`application/json`)

[BillingPackage](https://docs.neode.sk/development/api-reference/schemas.md#billingpackage).

| Error | When |
|---|---|
| 400 | The server API refused the request, or a path parameter has characters the console does not pass on |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## DELETE /api/panel/billing/packages/{packageId}

Delete a billing package.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Refused while a contract uses the package. Answers ok for an id that does not exist too.

Needs `billing.manage`. `neodesk billing package-delete` calls it. It cannot be undone.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `packageId` | path | string | yes | The package id |

**200**: Done (`application/json`)

| Field | Type |
|---|---|
| `ok` | `"true"` |

| Error | When |
|---|---|
| 400 | The server API refused the request, or a path parameter has characters the console does not pass on |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | A contract uses the package (package has active assignments) |

## GET /api/panel/billing/packages/{packageId}/preview

Show what a package billed in one month.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}.

Needs `billing.view`. `neodesk billing package-preview` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `packageId` | path | string | yes | The package id |
| `period` | query | string |  | The billing month, YYYY-MM; the current month in the server's time zone when missing |

**200**: Done (`application/json`)

[BillingPackagePreview](https://docs.neode.sk/development/api-reference/schemas.md#billingpackagepreview).

| Error | When |
|---|---|
| 400 | The server API refused the request, or a path parameter has characters the console does not pass on |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 404 | There is no such package (package not found) |

## GET /api/panel/billing/reports

List the work reports of billed sessions.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. For an account limited to some devices the list keeps the reports of sessions of its devices among the 500 newest sessions.

Needs `billing.view`. `neodesk billing reports` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `org_id` | query | string | Only reports of sessions of this organization |
| `limit` | query | integer | Most reports to answer, newest first. Default 100; a value above 500, 0 or below gives 100.; default `100`, at least 1, at most 500 |

**200**: Done (`application/json`)

| Field | Type |
|---|---|
| `reports` | array of [BillingWorkReport](https://docs.neode.sk/development/api-reference/schemas.md#billingworkreport) |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/panel/billing/reports/export

Export billing work reports as CSV or PDF (use --output).

With format=csv the console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. With format=pdf the console makes the PDF from the server API's CSV: labels in the request's language, dates, durations and amounts in the formats of the account (its time zone, the browser's region), A4, or US Letter for a reader in the US or Canada. Holds up to 5000 reports, each with its session. The CSV is UTF-8 with a byte order mark, comma separated with CRLF line ends; times are RFC 3339 UTC with milliseconds, amounts decimal strings in the currency's major unit with the currency in the next column.

Needs `billing.export`. `neodesk billing reports-export` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `format` | query | string, one of `csv`, `pdf` | default `"csv"` |
| `org_id` | query | string | Only rows of this organization |
| `device_ids` | query | string | Only rows of these devices, separated by commas; an empty value keeps none. The console replaces it with the devices of an account limited to some. |

**200**: The file billing-reports-YYYY-MM-DD.csv or .pdf, dated in the server's time zone (`text/csv`, `application/pdf`)

String (binary).

String (binary).

| Error | When |
|---|---|
| 400 | format is not csv or pdf (format must be csv or pdf) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/panel/billing/rules

Show the billing rules of the server.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Rules never saved have their defaults: rounding and the work report from the server's environment, an idle threshold of 2 minutes, everything else off.

Needs `billing.view`. `neodesk billing rules` calls it.

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `rules` | [BillingRules](https://docs.neode.sk/development/api-reference/schemas.md#billingrules) | yes |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 503 | Billing is not set up on the server (billing not enabled) |

## PUT /api/panel/billing/rules

Change the billing rules of the server.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Rules the body leaves out keep their value. Sessions that end after the change follow the new rules.

Needs `billing.manage`. `neodesk billing rules-set` calls it.

Request body, `application/json`:

The rules to change; a rule left out keeps its value

| Field | Type | What it is |
|---|---|---|
| `default_rounding_minutes` | integer | The rounding step a new package starts with; at least 1, at most 240 |
| `require_work_report` | boolean | A finished session waits for the technician's work report |
| `free_seconds` | integer | Sessions with less billable time are not billed; 0: off; at least 0, at most 3600 |
| `minimum_minutes` | integer | A billed session counts at least this long; 0: off; at least 0, at most 1440 |
| `cap_minutes` | integer | A session never bills more; 0: off. Not below minimum_minutes; at least 0, at most 10080 |
| `idle_exclude` | boolean | Leave stretches without input on the device out of the billed time |
| `idle_threshold_minutes` | integer | How long a stretch without input has to be to count as idle; at least 1, at most 120 |
| `idle_bill_threshold` | boolean | Still bill the first idle_threshold_minutes of an idle stretch; off leaves out the whole stretch |

**200**: The rules as saved (`application/json`)

| Field | Type | Required |
|---|---|---|
| `rules` | [BillingRules](https://docs.neode.sk/development/api-reference/schemas.md#billingrules) | yes |

| Error | When |
|---|---|
| 400 | The body is not JSON (invalid JSON), or a rule is out of bounds (invalid billing rules: and the rule's name) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 503 | Billing is not set up on the server (billing not enabled) |

## GET /api/panel/billing/sessions

List billed sessions.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. For an account limited to some devices the list keeps the sessions of its devices.

Needs `billing.view`. `neodesk billing sessions` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `org_id` | query | string | Only sessions of this organization |
| `status` | query | string, one of `active`, `pending_report`, `closed` | Only sessions with this status |
| `limit` | query | integer | Most sessions to answer, newest first. Default 100; a value above 500, 0 or below gives 100.; default `100`, at least 1, at most 500 |

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `sessions` | array of [BillingSession](https://docs.neode.sk/development/api-reference/schemas.md#billingsession) | Newest first |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/panel/billing/sessions/export

Export billed sessions as CSV (use --output).

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Holds up to 5000 sessions, newest first. The CSV is UTF-8 with a byte order mark, comma separated with CRLF line ends; times are RFC 3339 UTC with milliseconds, amounts decimal strings in the currency's major unit with the currency in the next column.

Needs `billing.export`. `neodesk billing sessions-export` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `format` | query | string, one of `csv` | yes | Must be csv |
| `org_id` | query | string |  | Only rows of this organization |
| `device_ids` | query | string |  | Only rows of these devices, separated by commas; an empty value keeps none. The console replaces it with the devices of an account limited to some. |

**200**: The file billing-sessions-YYYY-MM-DD.csv, dated in the server's time zone (`text/csv`)

String (binary).

| Error | When |
|---|---|
| 400 | format is not csv (only csv supported) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/panel/billing/sessions/pending

Show the billed session of a device that waits for its report.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. For an account limited to some devices, a device_id outside its devices answers 403.

Needs `billing.reports`. `neodesk billing sessions-pending` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `device_id` | query | string | yes | The device |

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `session` | [BillingSession](https://docs.neode.sk/development/api-reference/schemas.md#billingsession) or null | The newest session of the device that waits for its report; null when none |

| Error | When |
|---|---|
| 400 | device_id is missing (device_id required) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/panel/billing/sessions/{sessionId}

Show one billed session with its pauses, the idle time left out and the rules that changed its minutes.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. An account limited to some devices gets 403 for a session of a device outside them.

Needs `billing.view`. `neodesk billing session` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `sessionId` | path | string | yes | The billed session id |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `session` | [BillingSession](https://docs.neode.sk/development/api-reference/schemas.md#billingsession) | yes |  |
| `device` | object or null |  | The device as the device routes show it; null when it has no row or the account does not see it |
| `breakdown` | object |  | Only when billing is set up on the server |
| `breakdown.pauses` | array of object | yes | The stretches without input the device reported |
| `breakdown.pauses[].from` | string (date-time) | yes |  |
| `breakdown.pauses[].to` | string (date-time) |  | Only when the stretch ended |
| `breakdown.pauses[].seconds` | integer | yes |  |
| `breakdown.pauses[].unbilled_seconds` | integer | yes | How much of it the idle rules leave out |
| `breakdown.unbilled_seconds` | integer | yes | The idle time left out of the billed time |
| `breakdown.rules` | array of string | yes | The rules that changed the billed minutes: free, minimum or cap |

| Error | When |
|---|---|
| 400 | The session id has characters the console does not pass on |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 404 | There is no such session (billing session not found) |

## POST /api/panel/billing/sessions/{sessionId}/report

Write the report of a billed session.

The console passes the call on to the server API and answers with what it said, errors as {"error": "..."}. Saves the report and closes the session. Without user.edit you can only report your own sessions (the session's operator is your account); an account limited to some devices only sessions of its devices.

Needs `billing.reports`. `neodesk billing session-report` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `sessionId` | path | string | yes | The billed session id |

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `summary` | string | yes | What was done; cut at 8000 bytes |
| `category` | string |  | Cut at 128 bytes |
| `ticket_ref` | string |  | Cut at 128 bytes |

**200**: Done (`application/json`)

| Field | Type |
|---|---|
| `ok` | `"true"` |

| Error | When |
|---|---|
| 400 | summary required, session already closed, report already submitted, an unknown session, or a path the console refuses |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 404 | The server API does not know the session (billing session not found); asked only for the checks above |
| 503 | Billing is not set up on the server (billing not configured) |

## GET /api/panel/billing/stats

Show billing totals.

Needs `billing.view`. `neodesk billing stats` calls it.

**200**: Done (`application/json`)

[BillingStats](https://docs.neode.sk/development/api-reference/schemas.md#billingstats).

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/panel/billing/timesync/check

Check the server's clock against time servers now.

Queries the time servers now and answers the new status. The console passes the call on to the server API.

Needs `server.config`. `neodesk billing timesync-check` calls it.

**200**: Done (`application/json`)

[BillingClockStatus](https://docs.neode.sk/development/api-reference/schemas.md#billingclockstatus).

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 503 | The server has no time sync (timesync not configured) |

## GET /api/panel/billing/timesync/status

Show how far the server's clock is off.

Needs server.config or billing.view. The console passes the call on to the server API.

`neodesk billing timesync` calls it.

**200**: Done (`application/json`)

[BillingClockStatus](https://docs.neode.sk/development/api-reference/schemas.md#billingclockstatus).

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 503 | The server has no time sync (timesync not configured) |

## GET /api/panel/commercialization/email-config

Show the mail settings of help requests.

Every switch is on until the settings are saved.

Needs `billing.view`. `neodesk billing mail-settings` calls it.

**200**: Done (`application/json`)

| Field | Type |
|---|---|
| `success` | `true` |
| `config` | [HelpMailConfig](https://docs.neode.sk/development/api-reference/schemas.md#helpmailconfig) |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The settings could not be read |

## PUT /api/panel/commercialization/email-config

Change the mail settings of help requests.

Each switch is on unless the body has it as false, so send all four.

Needs `billing.manage`. `neodesk billing mail-settings-set` calls it.

Request body, `application/json`:

At least one of the fields.

| Field | Type | What it is |
|---|---|---|
| `help_requests_enabled` | boolean | default `true` |
| `notify_assigned_operators` | boolean | default `true` |
| `fallback_alert_email` | boolean | default `true` |
| `include_folder_in_subject` | boolean | default `true` |

**200**: The settings as saved (`application/json`)

| Field | Type |
|---|---|
| `success` | `true` |
| `config` | [HelpMailConfig](https://docs.neode.sk/development/api-reference/schemas.md#helpmailconfig) |

| Error | When |
|---|---|
| 400 | None of the fields is in the body (No settings to save) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The settings could not be saved |

## GET /api/panel/commercialization/smtp-status

Show whether help request mails can go out.

Needs `billing.view`. `neodesk billing mail-status` calls it.

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `configured` | boolean | true when SMTP is set up on the settings page |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
