splitch

DocsSDKmethods.md

The four methods.

Which calls fire an Exposure, and which credential each needs.

An Exposure is the “this subject saw this Variant” event that experiment analysis counts. Which methods fire one is the core thing to get right: an Exposure recorded outside the real user path inflates the denominator and biases the result.

MethodReturnsFires an ExposureCredential
evaluatethe Variant valueyesClient Key only
evaluateDetailsfull ResolutionDetailsyesClient Key only
peekVariantthe Variant valuenoAPI Key only
verifyfull ResolutionDetailsnoClient Key or API Key
  • evaluate or evaluateDetails on the real user path. These are the calls that belong in production request handling; reach for evaluateDetails when the handler needs ResolutionDetails.
  • peekVariant to inspect a resolution without polluting experiment data: admin screens, support tooling, debugging.
  • verify to confirm setup end to end. Same shape as evaluateDetails, no Exposure, safe to run repeatedly in CI.

Reading ResolutionDetails

evaluateDetails and verify return the reason the value was chosen, not just the value. Branch on reason when you need to distinguish a real resolution from a fallback.

const details = await splitch.evaluateDetails("new-checkout", {
  targetingKey: user.id,
  idempotencyKey: crypto.randomUUID(),
  defaultValue: false,
});

if (details.reason === "ERROR") {
  // details.value is your defaultValue, and details.errorCode says why.
  // Every code is documented at https://splitch.dev/docs/error/{code}
}