Datasets
POST
/v1/orgs/{org_id}/datasets/{dataset_id}/samplesAdd 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/sdkPath parameters
| Name | Type | Required | Description |
|---|---|---|---|
| org_id#path | string | required | — |
| dataset_id#path | string | required | — |
Header parameters
| Name | Type | Required | Description |
|---|---|---|---|
| X-API-Key#header | string | null | optional | — |
| authorization#header | string | null | optional | — |
Request bodyrequired
| Field | Type | Required | Description |
|---|---|---|---|
| samples | SampleInput[] | required | — |
Responses
| Status | Description |
|---|---|
| 200 | Successful Response |
| 422 | Validation Error |
Response schema
any
Errors & what triggers them
| Code | Trigger | Fix |
|---|---|---|
| 401 | Missing or expired Authorization header. | — |
| 403 | Token does not have the required role (admin / editor). | — |
| 404 | Target resource does not exist in this org. | — |
| 422 | Request 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_decision—ALLOW,BLOCK, orTRANSFORM. 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 justexpected_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.
Related
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