API referenceCustom moments

Evaluate a custom moment

POST
/moments/{id}/evaluate

Runs a saved custom moment, its current or an earlier version, over up to 1,000 turns as it would run live. Returns where it fired and, when expected labels the turns it should fire on, hits, misses, false fires, precision and a suggestion. Also returns the threshold a turn needed and up to 3 near misses: the turns that scored highest without firing, each with its score and why it did not fire. Gives up after 90 seconds. An organization starts at most 10 evaluations a minute.

Authorization

apiKey
X-API-Key<token>

API key (prefix spk_test_ or spk_live_) or personal access token (prefix pat_)

In: header

Path Parameters

id*string

Custom moment ID

Header Parameters

Idempotency-Key*string

Idempotency key that prevents processing a request twice. Use a unique UUID v4 per request.

Lengthlength <= 255

Request Body

application/json

conversation_id?string

A conversation whose stored final turns to read, up to 1,000. Send this or turns.

expected?array<string>

Your ids of the turns it should fire on; every other turn should not. Absent leaves the label fields of the result null.

turns?array<>

Up to 1,000 turns under the turn contract; only final ones are read. Send these or conversation_id.

Itemsitems <= 1000
version?integer

The version to evaluate; the current one when absent

Formatint64

Response Body

application/json

application/json

curl -X POST "https://example.com/moments/mdef_2jxsy8cc8v0348asy6t1/evaluate" \  -H "Idempotency-Key: string" \  -H "Content-Type: application/json" \  -d '{}'
{  "expected": 0,  "false": [    {      "text": "string",      "turn": "t_12"    }  ],  "false_fires": 0,  "fires": [    {      "at": 0.1,      "confidence": 0.1,      "text": "string",      "turn": "t_88"    }  ],  "hits": 0,  "misses": [    {      "text": "string",      "turn": "t_12"    }  ],  "near_misses": [    {      "reason": "below_threshold",      "score": 0.1,      "threshold": 0.1,      "turn_id": "t_12"    }  ],  "precision": 0,  "stats": {    "fires": 0,    "ms": 0,    "turns": 0  },  "suggestion": "string",  "threshold": 0.1}