Skip to main content

Datasets

POST/v1/orgs/{org_id}/datasets/{dataset_id}/samples

Add Samples

Bulk add samples to a dataset.

CI or Admin tokenscope: writeoperation_id: datasets.addSamples

Authentication

Requires a CI- or admin-level token. Runtime tokens are rejected for mutations.

SDK install

pip install znyx-sdknpm install @znyx/sdk

Path parameters

NameTypeRequiredDescription
org_id#pathstringrequired
dataset_id#pathstringrequired

Header parameters

NameTypeRequiredDescription
X-API-Key#headerstring | nulloptional
authorization#headerstring | nulloptional

Request bodyrequired

FieldTypeRequiredDescription
samplesSampleInput[]required

Responses

StatusDescription
200Successful Response
422Validation Error

Response schema

any

Errors & what triggers them

CodeTriggerFix
401Missing or expired Authorization header.
403Token does not have the required role (admin / editor).
404Target resource does not exist in this org.
422Request body failed validation.

Notes & examples

Sample shape

Each sample in the samples array carries:

  • input_text *(required)* — the text the guardrails will be run against.
  • context"input" (default) or "output". Drives which detectors fire.
  • expected_decisionALLOW, BLOCK, or TRANSFORM. Powers the pass/fail check when this dataset is used in a benchmark.
  • expected_rule_hits — optional list of detector rule IDs expected to fire. Tighter than just expected_decision — catches cases where you got the right outcome for the wrong reason.
  • metadata — free-form, flows through to benchmark result rows. Stash source URL, a labeller name, the original ticket ID.

Dedup responsibility is yours

The endpoint does not deduplicate — adding the same input_text twice creates two rows. If you're syncing from an external source, keep your own idempotency layer or hash the text before adding.

Size limits

Soft-limit the body to ~2 MB per call. Above that, chunk into multiple requests. The server doesn't enforce a hard cap today but may in future.

  • POST /v1/orgs/{org_id}/datasets/{id}/import — upload a raw JSON / CSV file instead.
  • POST /v1/orgs/{org_id}/annotations/export — build a dataset out of trace annotations in one call.

Request

curl -X POST 'https://api.znyx.ai/v1/orgs/00000000-0000-0000-0000-000000000000/datasets/00000000-0000-0000-0000-000000000000/samples' \
  -H 'Authorization: Bearer $ZNYX_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "samples": [
    {
      "input_text": "string",
      "context": "input",
      "expected_decision": null,
      "expected_rule_hits": null,
      "metadata": null
    }
  ]
}'

Response

application/json

Successful Response

null

Schema: any