Skip to main content

Datasets

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

Add Samples

Bulk add samples to a dataset.

Bearer token or X-API-Keyscope: org memberoperation_id: datasets.addSamples

Authentication

Send either Authorization: Bearer <token> or X-API-Key: <token>. Any org token with sufficient scope. Create tokens from the console or the /v1/orgs/{org_id}/tokens endpoints. Requests without a valid credential are rejected with 401.

SDK install

pip install znyx-sdknpm install @znyx/sdk

Code samples

Request

curl -X POST "$ZNYX_API_URL/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": [
    {
      "output_text": null,
      "context_documents": null,
      "tool_calls": null,
      "tool_results": null,
      "expected_categories": null,
      "expected_score_range": null,
      "language": null,
      "attack_type": null,
      "source": null,
      "license": null,
      "sensitivity": null,
      "annotator_id": null,
      "label_confidence": null,
      "created_from_trace_id": null,
      "input_text": "string",
      "context": "input",
      "expected_decision": null,
      "expected_rule_hits": null,
      "metadata": null
    }
  ]
}'

Response

application/json

Successful Response

null

Schema: any

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.