Custom Base Images

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

Create a Custom Base Image from an existing container project

post

In order to create a custom base image, you first need to import your base images into Snyk. You can do this through the CLI, UI, or API.

This endpoint marks an image as a custom base image. This means that the image will get added to the pool of images from which Snyk can recommend base image upgrades.

Note, after the first image in a repository gets added, a versioning schema cannot be passed in this endpoint. To update the versioning schema, the PATCH endpoint must be used.

Authorizations
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/custom_base_images?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": {
      "attributes": {
        "include_in_recommendations": true,
        "project_id": "2cab3939-d112-4ef0-836d-e09c87cbe69b",
        "versioning_schema": {
          "type": "semver"
        }
      },
      "type": "custom_base_image"
    }
  }'
{
  "data": {
    "attributes": {
      "include_in_recommendations": true,
      "project_id": "2cab3939-d112-4ef0-836d-e09c87cbe69b",
      "versioning_schema": {
        "type": "semver"
      }
    },
    "id": "2cab3939-d112-4ef0-836d-e09c87cbe69b",
    "type": "custom_base_image"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://example.com/api/this_resource"
  }
}

Get a custom base image collection

get

Get a list of custom base images with support for ordering and filtering. Either the org_id or group_id parameters must be set to authorize successfully. If sorting by version, the repository filter is required.

Authorizations
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
project_idstring · uuidoptional

The ID of the container project that the custom base image is based off of.

org_idstring · uuidoptional

The organization ID of the custom base image

group_idstring · uuidoptional

The group ID of the custom base image

repositorystringoptional

The image repository

tagstringoptional

The image tag

include_in_recommendationsbooleanoptional

Whether this image should be recommended as a base image upgrade

sort_bystring · enumoptional

Which column to sort by. If sorting by version, the versioning schema is used.

Options: repository, tag, version
sort_directionstring · enum · default: "ASC"optional

Which direction to sort

Options: ASC, DESC
Responses
curl -L \
  --url 'https://api.snyk.io/rest/custom_base_images?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "data": [
    {
      "attributes": {
        "group_id": "123e4567-e89b-12d3-a456-426614174000",
        "include_in_recommendations": true,
        "org_id": "123e4567-e89b-12d3-a456-426614174000",
        "project_id": "123e4567-e89b-12d3-a456-426614174000",
        "repository": "text",
        "tag": "text"
      },
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "type": "text"
    }
  ],
  "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 a custom base image

patch

Updates a custom base image's attributes

Authorizations
Path parameters
custombaseimage_idstring · uuidrequired

Unique identifier for custom base image

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/custom_base_images/{custombaseimage_id}?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": {
      "attributes": {
        "include_in_recommendations": true,
        "versioning_schema": {
          "type": "semver"
        }
      },
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "type": "custom_base_image"
    }
  }'
{
  "data": {
    "attributes": {
      "include_in_recommendations": true,
      "project_id": "2cab3939-d112-4ef0-836d-e09c87cbe69b",
      "versioning_schema": {
        "type": "semver"
      }
    },
    "id": "2cab3939-d112-4ef0-836d-e09c87cbe69b",
    "type": "custom_base_image"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://example.com/api/this_resource"
  }
}

Get a custom base image

get

Get a custom base image

Authorizations
Path parameters
custombaseimage_idstring · uuidrequired

Unique identifier for custom base image

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/custom_base_images/{custombaseimage_id}?version=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "data": {
    "attributes": {
      "include_in_recommendations": true,
      "project_id": "2cab3939-d112-4ef0-836d-e09c87cbe69b",
      "versioning_schema": {
        "type": "semver"
      }
    },
    "id": "2cab3939-d112-4ef0-836d-e09c87cbe69b",
    "type": "custom_base_image"
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://example.com/api/this_resource"
  }
}

Delete a custom base image

delete

Delete a custom base image resource. (the related container project is unaffected)

Authorizations
Path parameters
custombaseimage_idstring · uuidrequired

Unique identifier for custom base image

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

No body

Last updated

Was this helpful?