---
title: "Link a container image to a repository"
method: POST
path: "/api/v2/containerImages/linkRepository"
tags: ["Container Scanning"]
---

# Link a container image to a repository

`POST /api/v2/containerImages/linkRepository`

## Request

- Base URL: `https://zeropath.com`
- URL: `https://zeropath.com/api/v2/containerImages/linkRepository`
- Auth: API key in header `X-ZeroPath-API-Token-Id` and API key in header `X-ZeroPath-API-Token-Secret`

(Re)link a tracked container image to a different repository so it is tracked under a real repository instead of the ephemeral standalone one. The caller must have scan-start access to both the image's current repository and the target repository, and both must be in the same organization. The image and its scan history are moved together so issue/repository resolution stays consistent. Fails with a conflict if the target repository already tracks an image with the same reference.

## Request body

- ContainerImageLinkRepositoryRequest: Input for (re)linking a tracked container image to a different repository. The caller must have access to both the image's current repository and the target repository, and both must be in the same organization.
  - `organizationId` string: Organization ID (optional).
  - `containerImageId` string, required: ID of the container image to relink.
  - `repositoryId` string, required: ID of the repository to link the image to.

## Response `200`

Image relinked

- ContainerImageLinkRepositoryResponse: The relinked image and the repository it is now linked to.
  - `containerImageId` string, required
  - `repositoryId` string, required: The repository the image is now linked to.

## Other responses

- `400`: Error Response
- `401`: Error Response
- `403`: Error Response
- `404`: Error Response
- `409`: Error Response

---

[API](https://skmtc.dev/zeropath/apis/zeropath-api.md) - [All operations](https://skmtc.dev/zeropath/apis/zeropath-api/llms.txt) - [OpenAPI document](https://skmtc.dev/zeropath/apis/zeropath-api/revisions/126e9c80ba0d?raw)
