# Get next IDs for site

`GET /api/configuration/system/sites/{id}/next-ids`

- **Success:** `200 OK`
- **Products:** Operator (`FOH`)
- **Features:** Front of House Generic Access (`FOHGENERIC`)

HTML version: [Get next IDs for site](https://support.gladstonesoftware.cloud/reference/configuration/get-next-ids-for-site)

## Overview

Returns the 23 sequence counters a site uses to allocate its own record numbers — the next booking ID it will issue, the next member ID, the next invoice number and so on. Each counter is a system-configuration setting held against the site, and this endpoint reads them all in one call and returns them as integers.

**This is a read, not an allocation.** Calling it does not reserve a number or advance any counter, and two callers reading at the same moment see the same values. Do not use it to generate identifiers of your own — the platform advances these counters itself as records are created, and a number you read here will very likely be taken by the time you try to use it. Its legitimate uses are inspection and reconciliation: confirming a site has been provisioned, checking that counters are where a data migration left them, or reading current values before writing new ones with the matching `PUT`.

Two things catch integrators out:

- **The call is all-or-nothing across all 23 counters.** If even one of them is missing for that site, the whole request fails with `422` rather than returning the ones it found. A site provisioned through the create-site endpoint gets all 23 set up automatically, so this normally only bites on sites created by other means or partially migrated.
- **The `422` and `500` responses have empty bodies.** The reason is not returned to you, so you cannot tell from the response which counter was missing or malformed.

Note also that these counters are only meaningfully per-site when the operator has the `Database_EnableSiteSpecificIDs` configuration switched on. Reads always work regardless; it is the corresponding update that is rejected when the switch is off.

## Endpoint

`GET {base_url}/api/configuration/system/sites/{id}/next-ids`

`{base_url}` is the environment URL issued to your integration. See [Authenticating with Gladstone APIs](../../guides/authenticating-with-gladstone-apis.md).

## Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | Yes | The site whose counters you want — a site ID, despite the generic parameter name. Take it from the `id` of a site returned by [Get site by ID](get-site-by-id.md). A site ID with no matching configuration settings returns `404`; the endpoint does not verify that the site itself exists, so an unknown site and an unprovisioned one are indistinguishable. |

## Sample request

```bash title="cURL"
curl -X GET '{base_url}/api/configuration/system/sites/{id}/next-ids' \
  -H 'Authorization: Bearer {accessToken}' \
  -H 'X-Use-SSO: true'
```

## Response fields

Every field below is the value the site will use next, read from the identically named system-configuration setting on that site. All start at `1` when a site is created, except `nextDirectDebitDate`, which starts empty. A counter whose value is an empty string is returned as `0`; a counter whose value is not an integer fails the whole request with `422`.

| Field | Type | Description |
|-------|------|-------------|
| `nextAccompaniedAttendance` | integer (int32) | Next sequence number for an accompanied-attendance record — the attendance record created when a member brings a child or dependant in with them, which carries the child's name and ID alongside the member's. |
| `nextBookingID` | integer (int32) | Next booking record number for the site. Counted separately from `nextBookingRef`. |
| `nextBookingRef` | integer (int32) | Next booking reference the site will issue, counted separately from `nextBookingID`. |
| `nextCancellationRef` | integer (int32) | Next cancellation reference the site will issue. |
| `nextCorrespondenceID` | integer (int32) | Next record number for a correspondence record at this site. |
| `nextDirectDebitDate` | integer (int32) | Returned as `0` on any site that has not had a value set. |
| `nextEFTRunID` | integer (int32) | Next run number for an EFT (electronic funds transfer) batch — the collection run the site submits to its configured EFT system, whose bank details you can read with [Get site bank accounts by EFT system ID](get-site-bank-accounts-by-eft-system-id.md). |
| `nextEFTTransactionID` | integer (int32) | Next record number for an individual EFT transaction, counted separately from the run number in `nextEFTRunID`. |
| `nextEventLogID` | integer (int32) | Next record number for an event log entry at this site. |
| `nextInvoiceID` | integer (int32) | Next invoice number for the site, counted separately from `nextSalesInvoiceID`. |
| `nextMailID` | integer (int32) | Next record number for a mail record at this site, counted separately from `nextCorrespondenceID`. |
| `nextMemberActionID` | integer (int32) | Next record number for a member action record at this site. |
| `nextMemberID` | integer (int32) | Next member number the site will allocate. Reading it does not reserve it — the platform advances this counter itself when a member is created, so never use the value here as the member ID for a member you are about to create. |
| `nextOnlineAuthID` | integer (int32) | Next record number for an online authorisation at this site. Sites carry a matching set of `OnlineAuth*` settings covering an account ID, fund code and fund name, so this counter numbers records in that online authorisation feature. |
| `nextProductReferenceId` | integer (int32) | Next product reference number for this site. |
| `nextSalesInvoiceID` | integer (int32) | Next sales invoice number for the site, counted separately from `nextInvoiceID`. Note that a related `NextTempSalesInvoiceID` setting exists on every site — starting at `-1` rather than `1` — but is not returned by this endpoint and has no field here. |
| `nextSalesReceiptID` | integer (int32) | Next sales receipt number for the site, counted separately from `nextSalesInvoiceID`. |
| `nextSubscriptionRef` | integer (int32) | Next subscription reference the site will issue. |
| `nextTerminalReadingId` | integer (int32) | Next record number for a terminal reading. Readings are till totals recorded against a site, a user and a run date; terminal, X and Z are three of the seven reading types the platform records, and each of the three has its own counter here. |
| `nextUserReadingId` | integer (int32) | Next record number for a user reading. |
| `nextWaitinglistRef` | integer (int32) | Next waiting list reference the site will issue. |
| `nextXReadingId` | integer (int32) | Next record number for an X reading, one of the till reading types the platform records, counted separately from Z readings. |
| `nextZReadingId` | integer (int32) | Next record number for a Z reading, counted separately from `nextXReadingId`. The platform distinguishes plain Z readings from auto-Z and reprint-Z readings, but all draw on this one counter. |

## Sample response

```json title="200 OK"
{
  "nextAccompaniedAttendance": 1,
  "nextBookingID": 12345,
  "nextBookingRef": 1,
  "nextCancellationRef": 1,
  "nextCorrespondenceID": 12345,
  "nextDirectDebitDate": 1,
  "nextEFTRunID": 12345,
  "nextEFTTransactionID": 12345,
  "nextEventLogID": 12345,
  "nextInvoiceID": 12345,
  "nextMailID": 12345,
  "nextMemberActionID": 12345,
  "nextMemberID": 12345,
  "nextOnlineAuthID": 12345,
  "nextProductReferenceId": 12345,
  "nextSalesInvoiceID": 12345,
  "nextSalesReceiptID": 12345,
  "nextSubscriptionRef": 1,
  "nextTerminalReadingId": 12345,
  "nextUserReadingId": 12345,
  "nextWaitinglistRef": 1,
  "nextXReadingId": 12345,
  "nextZReadingId": 12345
}
```

## Errors

| Status | Meaning | When |
|--------|---------|------|
| `404` | Not found | No system-configuration settings whose key contains `next` exist for that site ID — the site has never been provisioned, or the ID does not exist. The body is the plain-text string `System configuration with the site id {id} could not be found`. |
| `422` | Unprocessable entity | The site has some next-ID settings but not all 23 the response requires, or one of them holds a value that is not an integer. Both cases fail the whole call — you never receive a partial object. **The response body is empty**, so the offending key is not reported to you; if you hit this, compare the site's settings against a known-good site. |
| `500` | Internal server error | Any other unexpected server-side failure. The response body is empty. |
