Skip to main content
POST
Increment a group counter
Atomically adds delta to a counter. Concurrent increments never lose updates, unlike set counter, which replaces the value with last-write-wins semantics. Negative deltas decrement. If the counter does not exist, it is created with delta as its value.
For usage patterns and examples, see the State Management guide.

Authorizations

X-API-Key
string
header
required

API key passed in the X-API-Key header.

Path Parameters

id
string<uuid>
required

Group ID

key
string
required

Counter key

Body

application/json

Delta to add and optional reset_after

delta
string
required

Amount to add to the counter, as a string for precision. Negative values decrement

Minimum string length: 1
Example:

"5"

reset_after
string

Auto-reset duration (e.g. "24h", "720h"). Empty string removes auto-reset. Omit to leave unchanged

Example:

"720h"

Response

New counter value

key
string

Counter key

Example:

"purchases"

last_reset_at
string<date-time>

When the counter was last reset

Example:

"2024-01-15T10:30:00Z"

reset_after
string

Auto-reset duration, if configured

Example:

"720h"

value
string

Counter value as a string for precision

Example:

"42"