Guides

Custom moments

Define your own moment kind in plain English, test it on a transcript, then make it live.

The ten built-in kinds cover what most calls share. Every business also has moments nobody else names: a pricing objection on a sales call, a promise about returns a compliance team must review, a question an interviewer isn't allowed to ask. A custom moment is one of those, written in plain English. No prompt engineering and no model training: you describe it, measure it on a transcript, and turn it on.

@sparkle/sdk is in private beta

The TypeScript tabs use @sparkle/sdk, which isn't on npm yet. To try it, ask us for access. Python and Go have no SDK yet: the cURL, Python and Go tabs call the HTTP API directly.

Describe it

A custom moment has a name, which becomes the kind of its moments, and four parts that decide when it fires:

FieldWhat it is
whenWhen it fires, in plain English. Up to 1,000 characters.
not_whenThe near misses it should skip, though they look alike. Up to 1,000 characters.
examplesUp to 10 lines it should fire on and 10 it should skip.
timingThe timing profile: act (the default), answer or ideas.
min_confidenceThe probability a turn needs to fire it, above 0 and up to 1. Defaults to 0.5.

Two more fields decide how it's shown, not when it fires. Its moments carry both, so your own UI can render them the way the dashboard does:

FieldWhat it is
labelA display name, 1 to 60 characters. Defaults to the name in words: pricing_objection is "Pricing objection".
colorOne of violet, blue, teal, green, yellow, orange, red, pink or gray, the dashboard's label colors. Defaults to one picked from the name.
curl https://api.sparkle.ai/public/v1/moments \
  -H "X-API-Key: $SPARKLE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "pricing_objection",
    "when": "The customer pushes back on price: says it costs too much or is over budget, asks for a discount, or compares us to a cheaper option.",
    "not_when": "Price is only mentioned, asked about or explained without resistance, including a clarifying question about price.",
    "examples": {
      "fire": ["That'\''s way over what we budgeted."],
      "skip": ["What does the Pro plan cost?"]
    },
    "timing": "act",
    "min_confidence": 0.6
  }'

It starts as a draft at version 1. A draft runs on no conversation until you make it live:

{
  "id": "mdef_2kd8a4c7f1h5k9n3q6sb",
  "name": "pricing_objection",
  "label": "Pricing objection",
  "color": "violet",
  "when": "The customer pushes back on price: says it costs too much or is over budget, asks for a discount, or compares us to a cheaper option.",
  "not_when": "Price is only mentioned, asked about or explained without resistance, including a clarifying question about price.",
  "examples": {
    "fire": ["That's way over what we budgeted."],
    "skip": ["What does the Pro plan cost?"]
  },
  "timing": "act",
  "min_confidence": 0.6,
  "version": 1,
  "status": "draft",
  "live_version": null,
  "shadow_version": null,
  "created_at": "2026-12-03T16:10:00Z",
  "updated_at": "2026-12-03T16:10:00Z"
}

name is snake_case, up to 40 characters, unique in your organization and not a built-in kind. It can't change later.

Test it on a transcript

Evaluate the moment on a transcript before it touches a live call. Send up to 1,000 turns, or the conversation_id of one you already have, and in expected the IDs of the turns it should fire on:

evaluate.json
{
  "turns": [
    {
      "id": "c1",
      "final": true,
      "speaker": "tom",
      "name": "Tom",
      "channel": "mic",
      "start": 3.0,
      "end": 7.0,
      "text": "Of course. The Team plan is twelve dollars per seat per month."
    },
    {
      "id": "c2",
      "final": true,
      "speaker": "priya",
      "name": "Priya",
      "channel": "remote",
      "start": 7.5,
      "end": 9.0,
      "text": "Is that price per seat or per team?"
    },
    {
      "id": "c3",
      "final": true,
      "speaker": "tom",
      "name": "Tom",
      "channel": "mic",
      "start": 9.5,
      "end": 11.0,
      "text": "Per seat, billed annually."
    },
    {
      "id": "c4",
      "final": true,
      "speaker": "priya",
      "name": "Priya",
      "channel": "remote",
      "start": 24.0,
      "end": 28.0,
      "text": "Honestly, that's way over what we budgeted for this quarter."
    },
    {
      "id": "c5",
      "final": true,
      "speaker": "tom",
      "name": "Tom",
      "channel": "mic",
      "start": 28.5,
      "end": 30.0,
      "text": "I hear you."
    },
    {
      "id": "c6",
      "final": true,
      "speaker": "priya",
      "name": "Priya",
      "channel": "remote",
      "start": 44.0,
      "end": 47.5,
      "text": "Northwind quoted us about half that."
    },
    {
      "id": "c7",
      "final": true,
      "speaker": "tom",
      "name": "Tom",
      "channel": "mic",
      "start": 48.0,
      "end": 51.0,
      "text": "We could look at a two-year term."
    },
    {
      "id": "c8",
      "final": true,
      "speaker": "priya",
      "name": "Priya",
      "channel": "remote",
      "start": 66.0,
      "end": 70.0,
      "text": "We'd need it closer to eight dollars a seat to make this work."
    }
  ],
  "expected": ["c4", "c6", "c8"]
}
curl https://api.sparkle.ai/public/v1/moments/mdef_2kd8a4c7f1h5k9n3q6sb/evaluate \
  -H "X-API-Key: $SPARKLE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @evaluate.json

The evaluation runs the moment as it would run live, timing included, and reports where it fired and how that compares with your labels:

{
  "hits": 2,
  "expected": 3,
  "false_fires": 1,
  "precision": 0.67,
  "misses": [
    { "turn": "c8", "text": "We'd need it closer to eight dollars a seat to make this work." }
  ],
  "false": [{ "turn": "c2", "text": "Is that price per seat or per team?" }],
  "fires": [
    { "turn": "c2", "at": 9.0, "text": "Is that price per seat or per team?", "confidence": 0.63 },
    {
      "turn": "c4",
      "at": 28.0,
      "text": "Honestly, that's way over what we budgeted for this quarter.",
      "confidence": 0.94
    },
    { "turn": "c6", "at": 47.5, "text": "Northwind quoted us about half that.", "confidence": 0.81 }
  ],
  "threshold": 0.6,
  "near_misses": [
    { "turn_id": "c8", "score": 0.52, "threshold": 0.6, "reason": "below_threshold" },
    { "turn_id": "c7", "score": 0.31, "threshold": 0.6, "reason": "below_threshold" }
  ],
  "suggestion": "Add a clarifying question about how the price is counted, like \"is that per seat?\", to not_when, and name a counter-offer below the quoted price in when.",
  "stats": { "turns": 8, "fires": 3, "ms": 4210 }
}

precision is the share of fires that were on a labelled turn. suggestion is a change to the wording that would fix the most common mistake. Without expected, the label fields are null; fires, near_misses and stats are always there.

An evaluation reads up to 1,000 turns and can take 30 seconds or more; it gives up after 90. Give your HTTP client a timeout above that, about 100 seconds, and don't retry a timeout: the first run may still be going, so a retry with the same Idempotency-Key gets a 409. The TypeScript SDK's evaluate waits 100 seconds per attempt and never retries a timeout; pass { timeoutMs } as its last argument to change the wait.

threshold is the score a turn needed: the evaluated version's min_confidence. near_misses are the turns it came closest to firing on without firing, at most 3, highest score first. Each one's reason says why it didn't fire:

reasonMeaning
below_thresholdThe score fell short of threshold. Add the line as a fire example, or loosen when.
settled_awayIt cleared threshold as the pick, but timing let it go unfired: a later turn of the same exchange fired, or a cooldown held it.
absentIt cleared threshold, but another option was the classifier's pick for that turn.

Here the missed counter-offer (c8) scored 0.52 against 0.6: a fire example like it would catch it.

To try wording before saving it, POST /moments/evaluate (sparkle.moments.evaluate(params) in the SDK) takes the whole definition in definition beside the same turns and expected.

Revise it

Send only the fields to change to PUT /moments/{id}. Until the moment first goes live, an edit changes the draft in place, and it stays version 1:

{
  "not_when": "Price is only mentioned, asked about or explained without resistance, including a clarifying question about how the price is counted (\"is that per seat?\").",
  "when": "The customer pushes back on price: says it costs too much or is over budget, asks for a discount, compares us to a cheaper option, or names a price they would accept below ours."
}

Evaluate again on the same transcript, and repeat until the misses and false fires are ones you can live with. Once the moment is live, edits work differently: see the last step.

label and color are the exception: they never make a version, before or after it goes live. A change reaches live conversations within about 5 seconds, and moments already detected keep the label and color they were sent with.

Make it live

Set status to live:

curl -X PUT https://api.sparkle.ai/public/v1/moments/mdef_2kd8a4c7f1h5k9n3q6sb \
  -H "X-API-Key: $SPARKLE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"status": "live"}'

Within about 5 seconds, live conversations start running it: every conversation created without moment_types, and every one whose moment_types names it. Version 1 is now its live_version. Its moments arrive like any other, with its name as the kind, and in definition the version that fired with the label and color it had then:

{
  "id": "mom_2kd8b7e1h5l9p3t7x0ac",
  "object": "moment",
  "conversation_id": "cnv_2kd8b0a4d8g2j6m0q3tf",
  "kind": "pricing_objection",
  "title": "Priya · Over budget for this quarter",
  "text": "Honestly, that's way over what we budgeted for this quarter.",
  "speaker": { "key": "priya", "name": "Priya" },
  "at": 812.4,
  "confidence": 0.94,
  "turn_ids": ["u_204"],
  "settled_ms": 5000,
  "classifier": "typesafe:…",
  "definition": {
    "id": "mdef_2kd8a4c7f1h5k9n3q6sb",
    "version": 1,
    "label": "Pricing objection",
    "color": "violet"
  },
  "created_at": "2026-12-04T10:13:41.902113Z"
}

Custom moments are read in the same call as the built-in kinds, as a second pick: a turn can be a decision and a pricing_objection at once, and adding custom moments never takes a turn away from a built-in kind.

To stop it, set status to disabled. Like going live, it reaches live conversations within about 5 seconds. Setting it back to live resumes its live_version, not a newer draft. A custom moment never goes back to draft, and deleting it keeps its name on the moments it already detected.

Shadow, then promote

Once a moment has a live_version, an edit no longer changes what live conversations run. PUT /moments/{id} writes the next version as a draft, and live_version keeps running until you promote the draft. Before you do, run it in shadow: beside the live version, on the same live calls, with its fires stored for comparison and never sent to your streams or webhooks. You can evaluate it on a transcript first, too: pass its version to POST /moments/{id}/evaluate.

Say your edit wrote version 2. Start its shadow:

curl -X POST https://api.sparkle.ai/public/v1/moments/mdef_2kd8a4c7f1h5k9n3q6sb/versions/2/shadow \
  -H "X-API-Key: $SPARKLE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

After some calls, GET /moments/{id}/versions (sparkle.moments.versions.list(id)) lists every version with the moments it detected, and compares the shadow with the live version on the same conversations:

{
  "versions": [
    { "version": 2, "status": "shadow", "fires": 41, "…": "…" },
    { "version": 1, "status": "live", "fires": 44, "…": "…" }
  ],
  "comparison": {
    "live_version": 1,
    "shadow_version": 2,
    "since": "2026-12-04T09:00:00Z",
    "both": [
      {
        "conversation_id": "cnv_2kd8b0a4d8g2j6m0q3tf",
        "turn_ids": ["u_204"],
        "at": 812.4,
        "text": "Honestly, that's way over what we budgeted for this quarter."
      }
    ],
    "only_live": [
      {
        "conversation_id": "cnv_2kd8c5h9m3q7u1y5b8ej",
        "turn_ids": ["u_77"],
        "at": 301.2,
        "text": "Is the onboarding fee included in that price?"
      }
    ],
    "only_shadow": [
      {
        "conversation_id": "cnv_2kd8d2j6n0r4v8z2c5fk",
        "turn_ids": ["u_19"],
        "at": 95.8,
        "text": "We'd sign today if you could meet us at nine a seat."
      }
    ]
  }
}

Read only_live and only_shadow: those are the calls where the two versions disagree. Here the new wording drops a clarifying question and catches a counter-offer. When it wins, promote it with POST /moments/{id}/versions/2/promote (sparkle.moments.versions.promote(id, 2)). Live conversations switch to version 2 in one step, version 1 is archived, and the shadow ends. You can also promote a draft directly, without a shadow.

If the shadow loses, stop it instead. The version goes back to draft, the shadow moments it already stored are kept, and live conversations stop running it within about 5 seconds:

curl -X DELETE https://api.sparkle.ai/public/v1/moments/mdef_2kd8a4c7f1h5k9n3q6sb/versions/2/shadow \
  -H "X-API-Key: $SPARKLE_API_KEY"

It answers 204, also when the version isn't in shadow, so stopping twice is safe. A version the moment doesn't have is a 404.

List where a moment fired

GET /moments/{id}/fires lists the moments a custom moment detected across your conversations, newest first and cursor-paged, from since on (a week ago when absent). It lists the moments it sent; add include_shadow=true for those a version in shadow detected too, marked shadow, and version to keep one version's:

curl "https://api.sparkle.ai/public/v1/moments/mdef_2kd8a4c7f1h5k9n3q6sb/fires?since=2026-12-01T00:00:00Z" \
  -H "X-API-Key: $SPARKLE_API_KEY"

Each item names the moment and its conversation, with what it read and where:

{
  "moment_id": "mom_2kd8b7e1h5l9p3t7x0ac",
  "conversation_id": "cnv_2kd8b0a4d8g2j6m0q3tf",
  "conversation_title": "Northwind renewal",
  "turn_ids": ["u_204"],
  "text": "Honestly, that's way over what we budgeted for this quarter.",
  "title": "Priya · Over budget for this quarter",
  "speaker": { "key": "priya", "name": "Priya" },
  "at": 812.4,
  "confidence": 0.94,
  "version": 1,
  "shadow": false,
  "created_at": "2026-12-04T10:13:41.902113Z"
}

Without include_shadow, a version's moments in the window number its fires less its shadow_fires in GET /moments/{id}/versions. Reading fires needs only view access to conversations, so a viewer key can list them.

Limits

  • name is fixed once created; label and color can change at any time.
  • At most 25 custom moments can be live in an organization at a time.
  • An evaluation reads at most 1,000 final turns, enough for an hour-long call, and expected is a list of your own turn IDs. It gives up after 90 seconds, and answers 502 with bad_gateway.classifier when the classifier fails; try again.
  • An organization starts at most 10 evaluations a minute, from the dashboard and the API together. The 11th answers 429 with rate_limit.custom_moment_evaluations; wait the seconds in Retry-After. Every attempt counts, a refused one included.
  • An API key limited to scopes needs custom_moment:* for these calls.

Writing good definitions

The wording is the tuning surface. A few habits make the difference:

  • Say who says what. "The customer pushes back on price" is sharper than "price objection": it rules out the rep explaining a discount.
  • Quote the phrasing. Short quoted lines in when ("that's over our budget", "can you do better?") show the classifier the range you mean.
  • Spend not_when on the near misses. Name what looks like the moment but isn't: a clarifying question, a hypothetical, the same words from the other side. When an evaluation shows a false fire, the fix usually goes here.
  • Make examples disagree with each other. A skip line that is one word away from a fire line teaches more than an unrelated one.
  • Invent your examples. Write them in the style of your calls, but don't paste real customers' words into a definition.
  • Choose timing by what you'll do with it. act when you want the settled outcome of an exchange, answer when you need to react while the question still hangs, ideas when one moment per brainstorm is enough.
  • Raise min_confidence to trade recall for precision. Start at 0.5 to 0.6, evaluate, and raise it when false fires cost you more than misses.

Templates

Seven ready-made custom moments are written and tested the same way. GET /moments/templates lists them, each with your organization's own custom moment of that name once you have one.

TemplateFires whenTiming
competitor_mentionedSomeone names a competing product or vendor, or an alternative the customer uses instead.answer
pricing_objectionThe customer pushes back on price, asks for a discount or compares a cheaper option.act
pricing_discussedThe conversation turns to what you charge, without pushback.act
commitment_with_dateSomeone commits to doing something by a specific day, date or time.act
risk_or_blockerSomeone names something that could stop or delay the work, the deal or the plan.act
next_meeting_scheduledThe people talking agree on when they'll meet next.act
frustration_expressedA speaker shows frustration or disappointment with the product, the service or the process.answer

Enable one, and it becomes your organization's own custom moment, live at once, with the template's label and color. You can evaluate, revise, relabel and disable it like one you wrote:

curl -X POST https://api.sparkle.ai/public/v1/moments/templates/commitment_with_date/enable \
  -H "X-API-Key: $SPARKLE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

Enabling a template you already have a custom moment of returns 409.

On this page