Skip to main content
PUT
/
v1
/
groups
/
{id}
/
state
/
counters
/
{key}
Set a group counter
curl --request PUT \
  --url https://api.scrip.dev/v1/groups/{id}/state/counters/{key} \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "value": "42",
  "reset_after": "720h"
}
'
{
  "key": "purchases",
  "last_reset_at": "2024-01-15T10:30:00Z",
  "reset_after": "720h",
  "value": "42"
}
Sets a counter value on a group directly. The counter is identified by its key in the URL path. If the counter does not exist, it is created. If it already exists, its value is overwritten with the provided amount. This is an absolute set, not an increment. You can optionally include reset_after (a Go duration string like "24h" or "720h") to configure auto-reset. Pass an empty string to clear an existing reset interval.
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

Counter value and optional reset_after

value
string
required

Counter value as a string for precision

Minimum string length: 1
Example:

"42"

reset_after
string

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

Example:

"720h"

Response

Counter set

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"