--apply.
Check the authentication requirement
POST /api/v1/standards requires a signed-in human’s short-lived access token and detection_rule.write. An API key, including a user-scoped API key, does not satisfy this endpoint’s human-authentication requirement. A refresh token is not an access token.
The example also reads the standard list before creating anything, so the signed-in user needs detection_rule.read. Obtain the access token through your deployment’s supported human sign-in flow, including any required MFA, and provide it as ALIGNR_ACCESS_TOKEN through your local secret-management environment. Do not put it in source code, command arguments or shared screenshots.
This is an explicitly invoked administrative workflow, not a service-key automation recipe. If you only have an API key, create the draft through the app instead.
Preview the exact configuration
Download the example or check out the docs repository. From that checkout, use Python 3.10 or newer:
The selected population and encryption observation must describe the same device. An encryption value of
false contradicts the expectation; a missing observation does not establish a pass. Reported encryption does not prove that a recovery key is available.
Create the reviewed draft
Choose a stable, unused slug for this request. Keep it in your change record so you can locate the draft if a response is lost. The child control slug is derived by adding-encryption.
After reviewing the dry run and confirming your environment, explicitly invoke the write:
GET /api/v1/standards, checking whether the standard slug already exists.- One
POST /api/v1/standardscontaining the parent and initial control together. - Response checks for HTTP 201, the expected slug, inactive parent state, one control and a valid returned standard ID.
Verify it in the app
Open Standards, locate the returned draft and inspect its Controls tab. Confirm the standard and control are both disabled and the definition matches the reviewed payload. Checkpoint: you can identify the saved standard, its one inactive control and the intended expectation. The script does not send activation, evaluation or remediation requests. Before enabling anything, follow test and rollout. Review evidence coverage, the control’s enabled state and client exceptions. Enabling a shared standard is not limited to the single client you may later select in Run checks.Recover without duplicating work
The example makes no automatic retries. A timeout or lost response after POST can occur even when creation committed.
After any uncertain write, reconcile the saved state first. Rerunning with the same slug is not an idempotent “get or create” operation, and retrying with a new slug can create a second standard.