alert-policies

Create Org Alert Policy

Changed on

Create an alert policy. A repo label with the same name is created to scope the policy; repositories carrying that label are governed by the policy. Requires a token with org-wide repository access; repo-restricted tokens receive 403.

This endpoint consumes 1 unit of your quota.

This endpoint requires the following org token scopes:

  • alert-policy:create
post/orgs/{org_slug}/alert-policies

Request

  • Base URL
    https://api.socket.dev/v0
  • URL
    https://api.socket.dev/v0/orgs/{org_slug}/alert-policies
  • Auth
    • HTTP bearer
    • or HTTP basic

Path parameters

org_slugstring required

The slug of the organization

Query parameters

dry_runboolean

Rehearse the write: authorize and validate the request and return the response body a real write would produce, then discard it. Accepts true, 1, or yes. Other present values return 400 so a typo cannot persist. Nothing is persisted. A dry-run success is HTTP 200 with dry_run: true, not 201.

Request body

namestring required

The policy name (1-120 characters). Also used as the name of the repo label that scopes the policy.

descriptionstring nullable

Operator-provided description (up to 256 characters).

repository_idsstring[] nullable

Repositories to scope the policy to.

baselinestring nullable

Baseline rule bundle the policy starts from. One of: essential, balanced, comprehensive. Null for no baseline.

Response

Dry-run: the write was not persisted.

idstring required

The ID of the policy: a UUID, or default for the default policy until it is first customized.

namestring nullable required

The policy name. Null for the default policy, which applies to all repositories without a policy label.

descriptionstring nullable required

Operator-provided description.

apply_method'labeled_repos' | 'unlabeled_repos' required

How the policy scopes to repositories: labeled_repos applies to repositories carrying the policy repo label; unlabeled_repos is the default policy for all unlabeled repositories.

repo_label_idstring nullable required

The repo label that scopes this policy. Null for the default policy.

repository_idsstring[] required

Repositories the policy scopes to. Empty for the default policy and for policies with no repository assignments.

baselinestring nullable required

Baseline rule bundle the policy starts from. One of: essential, balanced, comprehensive. Null when the policy has no baseline.

created_bystring nullable required

User ID that created the policy.

updated_bystring nullable required

User ID that last updated the policy.

created_atstring nullable required

ISO-8601 creation timestamp. Null for the default policy until it is first customized.

updated_atstring nullable required

ISO-8601 last-update timestamp. Null for the default policy until it is first customized.

dry_runboolean

True when ?dry_run=true (or 1 / yes) rehearsed the write; nothing was persisted.

Changes