Skip to main content
PUT
/
v1
/
participants
/
{id}
/
state
/
counters
/
{key}
Set participant counter
curl --request PUT \
  --url https://api.scrip.dev/v1/participants/{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 to a specific value. You can also configure reset_after in the same call to enable auto-reset behavior. The key is passed as a path parameter. This endpoint sets the counter to an absolute value, unlike the COUNTER rule action which increments the existing value. Use this for manual corrections or initializing counters from an external data source. If the counter does not exist, it is created.
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

Participant 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"