Collection

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

Create a collection

post

Create a collection

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}/collections?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": {
      "attributes": {
        "name": "text"
      },
      "type": "resource"
    }
  }'
{
  "data": {
    "attributes": {
      "is_generated": true,
      "name": "text"
    },
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "relationships": {
      "created_by_user": {
        "data": {
          "id": "331ede0a-de94-456f-b788-166caeca58bf",
          "type": "user"
        }
      },
      "org": {
        "data": {
          "id": "331ede0a-de94-456f-b788-166caeca58bf",
          "type": "org"
        }
      }
    },
    "type": "resource"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://example.com/api/this_resource"
  }
}

Get collections

get

Return a list of organization's collections with issues counts and projects count.

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
sortstring · enumoptional

Return collections sorted by the specified attributes

Options: name, projectsCount, issues
directionstring · enum · default: "DESC"optional

Return collections sorted in the specified direction

Options: ASC, DESC
namestring · max: 255optional

Return collections which names include the provided string

is_generatedbooleanoptional

Return collections where is_generated matches the provided boolean

Responses
curl -L \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/collections?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "data": [
    {
      "attributes": {
        "is_generated": true,
        "name": "text"
      },
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "meta": {
        "issues_critical_count": 10,
        "issues_high_count": 10,
        "issues_low_count": 10,
        "issues_medium_count": 10,
        "projects_count": 7
      },
      "relationships": {
        "created_by_user": {
          "data": {
            "id": "331ede0a-de94-456f-b788-166caeca58bf",
            "type": "user"
          }
        },
        "org": {
          "data": {
            "id": "331ede0a-de94-456f-b788-166caeca58bf",
            "type": "org"
          }
        }
      },
      "type": "resource"
    }
  ],
  "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"
  }
}

Edit a collection

patch

Edit a collection

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

collection_idstring · uuidrequired

Unique identifier for a collection

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}/collections/{collection_id}?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": {
      "attributes": {
        "name": "text"
      },
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "type": "resource"
    }
  }'
{
  "data": {
    "attributes": {
      "is_generated": true,
      "name": "text"
    },
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "relationships": {
      "created_by_user": {
        "data": {
          "id": "331ede0a-de94-456f-b788-166caeca58bf",
          "type": "user"
        }
      },
      "org": {
        "data": {
          "id": "331ede0a-de94-456f-b788-166caeca58bf",
          "type": "org"
        }
      }
    },
    "type": "resource"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://example.com/api/this_resource"
  }
}

Get a collection

get

Get a collection

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

collection_idstring · uuidrequired

Unique identifier for a collection

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}/collections/{collection_id}?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "data": {
    "attributes": {
      "is_generated": true,
      "name": "text"
    },
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "relationships": {
      "created_by_user": {
        "data": {
          "id": "331ede0a-de94-456f-b788-166caeca58bf",
          "type": "user"
        }
      },
      "org": {
        "data": {
          "id": "331ede0a-de94-456f-b788-166caeca58bf",
          "type": "org"
        }
      }
    },
    "type": "resource"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://example.com/api/this_resource"
  }
}

Delete a collection

delete

Delete a collection

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

collection_idstring · uuidrequired

Unique identifier for a collection

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}/collections/{collection_id}?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'

No body

Add projects to a collection

post

Add projects to a collection by specifying an array of project ids

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

collection_idstring · uuidrequired

Unique identifier for a collection

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
dataobject[] · max: 100required

IDs of items to add to a collection

Responses
curl -L \
  --request POST \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/collections/{collection_id}/relationships/projects?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": [
      {
        "id": "123e4567-e89b-12d3-a456-426614174000",
        "type": "project"
      }
    ]
  }'

No body

Get projects from the specified collection

get

Return a list of organization's projects that are from the specified collection.

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

collection_idstring · uuidrequired

Unique identifier for a collection

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
sortstring · enumoptional

Return projects sorted by the specified attributes

Options: imported, last_tested_at, issues
directionstring · enum · default: "DESC"optional

Return projects sorted in the specified direction

Options: ASC, DESC
target_idstring · uuid[] · max: 25optional

Return projects that belong to the provided targets

showstring · enum[]optional

Return projects that are with or without issues

integrationstring · enum[]optional

Return projects that match the provided integration types

Responses
curl -L \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/collections/{collection_id}/relationships/projects?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "data": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "meta": {
        "imported": "2021-05-29T09:50:54.014Z",
        "issues_critical_count": 10,
        "issues_high_count": 10,
        "issues_low_count": 10,
        "issues_medium_count": 10,
        "last_tested_at": "2021-05-29T09:50:54.014Z"
      },
      "relationships": {
        "target": {
          "data": {
            "id": "331ede0a-de94-456f-b788-166caeca58bf",
            "type": "target"
          }
        }
      },
      "type": "resource"
    }
  ],
  "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"
  }
}

Remove projects from a collection

delete

Remove projects from a collection by specifying an array of project ids

Authorizations
Path parameters
org_idstring · uuidrequired

Org ID

collection_idstring · uuidrequired

Unique identifier for a collection

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
dataobject[] · max: 100required

IDs of items to remove from a collection

Responses
curl -L \
  --request DELETE \
  --url 'https://api.snyk.io/rest/orgs/{org_id}/collections/{collection_id}/relationships/projects?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": [
      {
        "id": "123e4567-e89b-12d3-a456-426614174000",
        "type": "project"
      }
    ]
  }'

No body

Last updated

Was this helpful?

Revision created

Add comment to emphasize required filters hidden in GitBook collapsed field