# Update next IDs for site

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

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

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

## Overview

Sets the identifier counters for one site. These counters are how the platform allocates the next
member number, booking id, sale invoice id and so on: when a record is created, the counter is
incremented and the record gets the value it held beforehand. The numbers live in configuration,
which is why they are editable at all, and why editing them is dangerous.

**Treat this endpoint as a repair tool, not part of a normal integration.**

**Setting a counter backwards re-issues numbers that are already in use.** The next record created
will be given an identifier that an existing record already has, so you should expect failed
record creation — members, invoices and so on — and, for references that are not required to be
unique, two records sharing one number. There is no validation against the highest identifier already
issued; the value you send is saved as-is. Only ever move a counter forwards unless you have
verified that nothing occupies the range you are moving into. Gaps are harmless: a reserved
identifier that is not used is simply skipped.

**This is a full replacement of all 23 counters, not a partial update.** Every field is written on
every call from the value in the body, and there is no "leave this one alone". All 23 are
required integers, so an omitted field cannot be distinguished from a deliberate `0`
— and `0` would reset that counter. Read the current values with
`GET /api/configuration/system/sites/{id}/next-ids`, change only what you mean to change, and send
all 23 back.

**Site-specific identifiers must be switched on.** If the system configuration
`Database_EnableSiteSpecificIDs` is not `1`, the request is rejected with `400 Site specific ids is
not enabled` — and note that when it is `0` identifiers are allocated from the counters held
against site `HO` whatever the site, so per-site counters would have no effect anyway.

The site must already have counter records; a site with none returns `404`. The 23 writes are saved
together, so the call is all-or-nothing.

On success the response is `204 No Content`.

## Endpoint

`PUT {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 are setting. It must already have counter records — if none are found the request fails with `404 System configuration with the site id {id} could not be found`. Note that when site-specific identifiers are disabled the platform allocates from the `HO` site's counters regardless of the site a record belongs to. |

## Request body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `nextAccompaniedAttendance` | integer (int32) | Yes | Counter keyed `NextAccompaniedAttendance` — the next number issued for accompanied attendance records at this site. Between 0 and 2100000000. |
| `nextBookingID` | integer (int32) | Yes | Counter keyed `NextBookingID` — the next identifier issued to a booking created at this site. Lowering it risks collisions with existing bookings. Between 0 and 2100000000. |
| `nextBookingRef` | integer (int32) | Yes | Counter keyed `NextBookingRef` — the next booking reference issued at this site. Distinct from `nextBookingID`: a reference is the customer-facing number, an id is the booking's identifier. Between 0 and 2100000000. |
| `nextCancellationRef` | integer (int32) | Yes | Counter keyed `NextCancellationRef` — the next cancellation reference issued at this site. Between 0 and 2100000000. |
| `nextCorrespondenceID` | integer (int32) | Yes | Counter keyed `NextCorrespondenceID` — the next identifier issued to a correspondence record at this site. Between 0 and 2100000000. |
| `nextDirectDebitDate` | integer (int32) | Yes | Counter keyed `NextDirectDebitDate`. Despite the name it is an integer counter like the rest, not a date, and is validated on the same 0–2100000000 range. Between 0 and 2100000000. |
| `nextEFTRunID` | integer (int32) | Yes | Counter keyed `NextEFTRunID` — the next identifier issued to an electronic funds transfer run at this site. Between 0 and 2100000000. |
| `nextEFTTransactionID` | integer (int32) | Yes | Counter keyed `NextEFTTransactionID` — the next identifier issued to a transaction within an electronic funds transfer run. Between 0 and 2100000000. |
| `nextEventLogID` | integer (int32) | Yes | Counter keyed `NextEventLogID` — the next identifier issued to an event log record at this site. Between 0 and 2100000000. |
| `nextInvoiceID` | integer (int32) | Yes | Counter keyed `NextInvoiceID` — the next invoice identifier issued at this site. Note that sale invoices use `nextSalesInvoiceID`, not this counter. Between 0 and 2100000000. |
| `nextMailID` | integer (int32) | Yes | Counter keyed `NextMailID` — the next identifier issued to a mail record at this site. Between 0 and 2100000000. |
| `nextMemberActionID` | integer (int32) | Yes | Counter keyed `NextMemberActionID` — the next identifier issued to a member action record at this site. Between 0 and 2100000000. |
| `nextMemberID` | integer (int32) | Yes | Counter keyed `NextMemberID` — the number given to the next member created at this site. Member creation uses this value as the new member's id and login id. **Lowering it makes member creation attempt ids that already exist.** Between 0 and 2100000000. |
| `nextOnlineAuthID` | integer (int32) | Yes | Counter keyed `NextOnlineAuthID` — the next identifier issued to an online authorisation record at this site. Between 0 and 2100000000. |
| `nextProductReferenceId` | integer (int32) | Yes | Counter keyed `NextProductReferenceId` — the next product reference issued at this site. Between 0 and 2100000000. |
| `nextSalesInvoiceID` | integer (int32) | Yes | Counter keyed `NextSalesInvoiceID` — the next sale invoice identifier at this site. Sale invoice ids are allocated from this counter whenever invoices are raised — by invoicing, payments, bookings and memberships alike — so lowering it causes duplicate invoice ids across all of those. Gaps are expected and harmless, because a reserved id is abandoned if the operation fails. Between 0 and 2100000000. |
| `nextSalesReceiptID` | integer (int32) | Yes | Counter keyed `NextSalesReceiptID` — the next sale receipt identifier at this site. Like `nextSalesInvoiceID`, receipt ids are allocated from this counter, so lowering it causes duplicate receipt ids. Between 0 and 2100000000. |
| `nextSubscriptionRef` | integer (int32) | Yes | Counter keyed `NextSubscriptionRef` — the next membership subscription reference issued at this site. Between 0 and 2100000000. |
| `nextTerminalReadingId` | integer (int32) | Yes | Counter keyed `NextTerminalReadingId` — the next identifier issued to a terminal reading at this site. Between 0 and 2100000000. |
| `nextUserReadingId` | integer (int32) | Yes | Counter keyed `NextUserReadingId` — the next identifier issued to a user reading at this site. Between 0 and 2100000000. |
| `nextWaitinglistRef` | integer (int32) | Yes | Counter keyed `NextWaitinglistRef` — the next waiting list reference issued at this site. Between 0 and 2100000000. |
| `nextXReadingId` | integer (int32) | Yes | Counter keyed `NextXReadingId` — the next identifier issued to an X reading at this site. Between 0 and 2100000000. |
| `nextZReadingId` | integer (int32) | Yes | Counter keyed `NextZReadingId` — the next identifier issued to a Z reading at this site. Between 0 and 2100000000. |

## Sample request

```bash title="cURL"
curl -X PUT '{base_url}/api/configuration/system/sites/{id}/next-ids' \
  -H 'Authorization: Bearer {accessToken}' \
  -H 'X-Use-SSO: true' \
  -H 'Content-Type: application/json' \
  -d '{
  "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 |
|--------|---------|------|
| `400` | Bad request | Site-specific identifiers are switched off — body is the string `Site specific ids is not enabled`. This is checked first, before the site is looked up. |
| `400` | Bad request | Validation failed: a value is missing, negative, or above `2100000000`. The body is a validation problem document keyed by field name. |
| `404` | Not found | The site has no counter records — `System configuration with the site id {id} could not be found`. |
| `422` | Unprocessable entity | One of the 23 counters does not exist for this site, so it cannot be set (`Could not find {counterName}`). **The response body is empty**, so you cannot tell which counter is missing from the response alone. |
| `500` | Internal server error | The save failed, or any other unexpected server-side failure. No detail is returned. |
