Policies

This document uses the REST API. For more details, see the Authentication for API page.

Create a new org-level policy

post

Create a new org-level policy.

Org level Policy APIs Access Notice: Access to our Org level Policy APIs is currently restricted via "snykCodeConsistentIgnores" feature flag and will result in a 403 Forbidden error without the flag enabled. Please contact your account representative for eligibility requirements.

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

Query parameters
versionstringrequired

Requested API version

Example: 2021-06-04
Pattern: ^(wip|work-in-progress|experimental|beta|((([0-9]{4})-([0-1][0-9]))-((3[01])|(0[1-9])|([12][0-9]))(~(wip|work-in-progress|experimental|beta))?))$
Body
dataobjectrequired

Responses
curl -L \
  --request POST \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/policies?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": {
      "attributes": {
        "action": {
          "data": {
            "expires": "2024-03-16T00:00:00Z",
            "ignore_type": "wont-fix",
            "reason": "text"
          }
        },
        "action_type": "ignore",
        "conditions_group": {
          "conditions": [
            {
              "field": "snyk/asset/finding/v1",
              "operator": "includes",
              "value": "text"
            }
          ],
          "logical_operator": "and"
        },
        "name": "text"
      },
      "type": "policy"
    }
  }'
{
  "data": {
    "attributes": {
      "action": {
        "data": {
          "expires": "2024-03-16T00:00:00Z",
          "ignore_type": "wont-fix",
          "reason": "text"
        }
      },
      "action_type": "ignore",
      "conditions_group": {
        "conditions": [
          {
            "field": "snyk/asset/finding/v1",
            "operator": "includes",
            "value": "text"
          }
        ],
        "logical_operator": "and"
      },
      "created_at": "2024-03-16T00:00:00Z",
      "created_by": {
        "email": "text",
        "id": "123e4567-e89b-12d3-a456-426614174000",
        "name": "text"
      },
      "name": "text",
      "review": "pending",
      "updated_at": "2024-03-16T00:00:00Z"
    },
    "id": "f16c31b5-6129-4571-add8-d589da9be524",
    "type": "policy"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://example.com/api/this_resource"
  }
}

Get org-level policies

get

Get all policies for the requested organisation.

Org level Policy APIs Access Notice: Access to our Org level Policy APIs is currently restricted via "snykCodeConsistentIgnores" feature flag and will result in a 403 Forbidden error without the flag enabled. Please contact your account representative for eligibility requirements.

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

Query parameters
versionstringrequired

Requested API version

Example: 2021-06-04
Pattern: ^(wip|work-in-progress|experimental|beta|((([0-9]{4})-([0-1][0-9]))-((3[01])|(0[1-9])|([12][0-9]))(~(wip|work-in-progress|experimental|beta))?))$
starting_afterstringoptional

Return the page of results immediately after this cursor

Example: v1.eyJpZCI6IjEwMDAifQo=
ending_beforestringoptional

Return the page of results immediately before this cursor

Example: v1.eyJpZCI6IjExMDAifQo=
limitinteger · int32 · min: 10 · max: 100 · default: 10optional

Number of results to return per page

Example: 10
reviewstring · enum[]optional

Policy rule review state e.g. approved

expires_beforestring · date-timeoptional

Select only policies with an expiry strictly before the given time.

Example: 2024-03-16T00:00:00Z
expires_afterstring · date-timeoptional

Select only policies with an expiry strictly past the given time.

Example: 2024-03-16T00:00:00Z
expires_neverbooleanoptional

Select only policies that never expire.

Example: true
Responses
curl -L \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/policies?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "data": [
    {
      "attributes": {
        "action": {
          "data": {
            "expires": "2024-03-16T00:00:00Z",
            "ignore_type": "wont-fix",
            "reason": "text"
          }
        },
        "action_type": "ignore",
        "conditions_group": {
          "conditions": [
            {
              "field": "snyk/asset/finding/v1",
              "operator": "includes",
              "value": "text"
            }
          ],
          "logical_operator": "and"
        },
        "created_at": "2024-03-16T00:00:00Z",
        "created_by": {
          "email": "text",
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "name": "text"
        },
        "name": "text",
        "review": "pending",
        "updated_at": "2024-03-16T00:00:00Z"
      },
      "id": "f16c31b5-6129-4571-add8-d589da9be524",
      "type": "policy"
    }
  ],
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "first": "https://example.com/api/resource?ending_before=v1.eyJpZCI6IjExIn0K",
    "last": "https://example.com/api/resource?starting_after=v1.eyJpZCI6IjMwIn0K",
    "next": "https://example.com/api/resource?starting_after=v1.eyJpZCI6IjEwIn0K"
  }
}

Update an org-level policy

patch

Update the org-level policy.

Org level Policy APIs Access Notice: Access to our Org level Policy APIs is currently restricted via "snykCodeConsistentIgnores" feature flag and will result in a 403 Forbidden error without the flag enabled. Please contact your account representative for eligibility requirements.

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

policy_idstring · uuidrequired

Policy ID

Query parameters
versionstringrequired

Requested API version

Example: 2021-06-04
Pattern: ^(wip|work-in-progress|experimental|beta|((([0-9]{4})-([0-1][0-9]))-((3[01])|(0[1-9])|([12][0-9]))(~(wip|work-in-progress|experimental|beta))?))$
Body
dataobjectrequired

Responses
curl -L \
  --request PATCH \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/policies/{policy_id}?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": {
      "attributes": {
        "action": {
          "data": {
            "expires": "2024-03-16T00:00:00Z",
            "ignore_type": "wont-fix",
            "reason": "text"
          }
        },
        "conditions_group": {
          "conditions": [
            {
              "field": "snyk/asset/finding/v1",
              "operator": "includes",
              "value": "text"
            }
          ],
          "logical_operator": "and"
        },
        "name": "text",
        "review": "pending"
      },
      "id": "f16c31b5-6129-4571-add8-d589da9be524",
      "meta": {
        "key1": "value1",
        "key2": {
          "sub_key": "sub_value"
        },
        "key3": [
          "array_value1",
          "array_value2"
        ]
      },
      "type": "policy"
    }
  }'
{
  "data": {
    "attributes": {
      "action": {
        "data": {
          "expires": "2024-03-16T00:00:00Z",
          "ignore_type": "wont-fix",
          "reason": "text"
        }
      },
      "action_type": "ignore",
      "conditions_group": {
        "conditions": [
          {
            "field": "snyk/asset/finding/v1",
            "operator": "includes",
            "value": "text"
          }
        ],
        "logical_operator": "and"
      },
      "created_at": "2024-03-16T00:00:00Z",
      "created_by": {
        "email": "text",
        "id": "123e4567-e89b-12d3-a456-426614174000",
        "name": "text"
      },
      "name": "text",
      "review": "pending",
      "updated_at": "2024-03-16T00:00:00Z"
    },
    "id": "f16c31b5-6129-4571-add8-d589da9be524",
    "type": "policy"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://example.com/api/this_resource"
  }
}

Get an org-level policy

get

Get a specific org-level policy based on its ID.

Org level Policy APIs Access Notice: Access to our Org level Policy APIs is currently restricted via "snykCodeConsistentIgnores" feature flag and will result in a 403 Forbidden error without the flag enabled. Please contact your account representative for eligibility requirements.

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

policy_idstring · uuidrequired

Policy ID

Query parameters
versionstringrequired

Requested API version

Example: 2021-06-04
Pattern: ^(wip|work-in-progress|experimental|beta|((([0-9]{4})-([0-1][0-9]))-((3[01])|(0[1-9])|([12][0-9]))(~(wip|work-in-progress|experimental|beta))?))$
Responses
curl -L \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/policies/{policy_id}?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "data": {
    "attributes": {
      "action": {
        "data": {
          "expires": "2024-03-16T00:00:00Z",
          "ignore_type": "wont-fix",
          "reason": "text"
        }
      },
      "action_type": "ignore",
      "conditions_group": {
        "conditions": [
          {
            "field": "snyk/asset/finding/v1",
            "operator": "includes",
            "value": "text"
          }
        ],
        "logical_operator": "and"
      },
      "created_at": "2024-03-16T00:00:00Z",
      "created_by": {
        "email": "text",
        "id": "123e4567-e89b-12d3-a456-426614174000",
        "name": "text"
      },
      "name": "text",
      "review": "pending",
      "updated_at": "2024-03-16T00:00:00Z"
    },
    "id": "f16c31b5-6129-4571-add8-d589da9be524",
    "type": "policy"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "first": "https://example.com/api/resource",
    "last": "https://example.com/api/resource",
    "next": "https://example.com/api/resource",
    "prev": "https://example.com/api/resource",
    "related": "https://example.com/api/resource",
    "self": "https://example.com/api/resource"
  }
}

Delete an org-level policy

delete

Delete an existing org-level policy.

Org level Policy APIs Access Notice: Access to our Org level Policy APIs is currently restricted via "snykCodeConsistentIgnores" feature flag and will result in a 403 Forbidden error without the flag enabled. Please contact your account representative for eligibility requirements.

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

policy_idstring · uuidrequired

Policy ID

Query parameters
versionstringrequired

Requested API version

Example: 2021-06-04
Pattern: ^(wip|work-in-progress|experimental|beta|((([0-9]{4})-([0-1][0-9]))-((3[01])|(0[1-9])|([12][0-9]))(~(wip|work-in-progress|experimental|beta))?))$
Responses
curl -L \
  --request DELETE \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/policies/{policy_id}?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'

No body

Last updated

Was this helpful?

Revision created

Add comment to emphasize required filters hidden in GitBook collapsed field