Datasets
POST
/v1/orgs/{org_id}/datasets/{dataset_id}/samplesAdd 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/sdkCode 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
| 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.