GoHarbor Retention API

The Retention API from GoHarbor — 7 operation(s) for retention.

Operations 10

GET /retentions/metadatas Get Retention Metadatas #
POST /retentions Create Retention Policy #
GET /retentions/{id} Get Retention Policy #
PUT /retentions/{id} Update Retention Policy #
DELETE /retentions/{id} Delete Retention Policy #
POST /retentions/{id}/executions Trigger a Retention Execution #
GET /retentions/{id}/executions Get Retention executions #
PATCH /retentions/{id}/executions/{eid} Stop a Retention execution #
GET /retentions/{id}/executions/{eid}/tasks Get Retention tasks #
GET /retentions/{id}/executions/{eid}/tasks/{tid} Get Retention job task log #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/goharbor-retention-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

goharbor-retention-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Harbor Retention API
  description: These APIs provide services for manipulating Harbor project.
  version: '2.0'
servers:
- url: http://localhost/api/v2.0
- url: https://localhost/api/v2.0
security:
- basic: []
- {}
tags:
- name: Retention
paths:
  /retentions/metadatas:
    get:
      summary: Get Retention Metadatas
      description: Get Retention Metadatas.
      operationId: getRentenitionMetadata
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      responses:
        '200':
          description: Get Retention Metadatas successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RetentionMetadata'
        '401':
          $ref: '#/components/responses/401'
        '500':
          $ref: '#/components/responses/500'
  /retentions:
    post:
      summary: Create Retention Policy
      operationId: createRetention
      description: Create Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when no retention policy binded to project yet.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      responses:
        '201':
          $ref: '#/components/responses/201'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RetentionPolicy'
        description: Create Retention Policy successfully.
        required: true
  /retentions/{id}:
    get:
      summary: Get Retention Policy
      operationId: getRetention
      description: Get Retention Policy.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      - name: id
        in: path
        required: true
        description: Retention ID.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: Get Retention Policy successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RetentionPolicy'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
    put:
      summary: Update Retention Policy
      operationId: updateRetention
      description: Update Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      - name: id
        in: path
        required: true
        description: Retention ID.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: Update Retention Policy successfully.
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RetentionPolicy'
        required: true
    delete:
      summary: Delete Retention Policy
      operationId: deleteRetention
      description: Delete Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      - name: id
        in: path
        required: true
        description: Retention ID.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: Update Retention Policy successfully.
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
  /retentions/{id}/executions:
    post:
      summary: Trigger a Retention Execution
      operationId: triggerRetentionExecution
      description: Trigger a Retention Execution, if dry_run is True, nothing would be deleted actually.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      - name: id
        in: path
        required: true
        description: Retention ID.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: Trigger a Retention job successfully.
        '201':
          $ref: '#/components/responses/201'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                dry_run:
                  type: boolean
        required: true
    get:
      summary: Get Retention executions
      operationId: listRetentionExecutions
      description: Get Retention executions, execution status may be delayed before job service schedule it up.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      - name: id
        in: path
        required: true
        description: Retention ID.
        schema:
          type: integer
          format: int64
      - name: page
        in: query
        required: false
        description: The page number.
        schema:
          type: integer
          format: int64
      - name: page_size
        in: query
        required: false
        description: The size of per page.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: Get a Retention execution successfully.
          headers:
            X-Total-Count:
              description: The total count of available items
              schema:
                type: integer
            Link:
              description: Link to previous page and next page
              schema:
                type: string
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  $ref: '#/components/schemas/RetentionExecution'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
  /retentions/{id}/executions/{eid}:
    patch:
      summary: Stop a Retention execution
      operationId: operateRetentionExecution
      description: Stop a Retention execution, only support "stop" action now.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      - name: id
        in: path
        required: true
        description: Retention ID.
        schema:
          type: integer
          format: int64
      - name: eid
        in: path
        required: true
        description: Retention execution ID.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: Stop a Retention job successfully.
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
        description: The action, only support "stop" now.
        required: true
  /retentions/{id}/executions/{eid}/tasks:
    get:
      summary: Get Retention tasks
      operationId: listRetentionTasks
      description: Get Retention tasks, each repository as a task.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      - name: id
        in: path
        required: true
        description: Retention ID.
        schema:
          type: integer
          format: int64
      - name: eid
        in: path
        required: true
        description: Retention execution ID.
        schema:
          type: integer
          format: int64
      - name: page
        in: query
        required: false
        description: The page number.
        schema:
          type: integer
          format: int64
      - name: page_size
        in: query
        required: false
        description: The size of per page.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: Get Retention job tasks successfully.
          headers:
            X-Total-Count:
              description: The total count of available items
              schema:
                type: integer
            Link:
              description: Link to previous page and next page
              schema:
                type: string
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  $ref: '#/components/schemas/RetentionExecutionTask'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
  /retentions/{id}/executions/{eid}/tasks/{tid}:
    get:
      summary: Get Retention job task log
      operationId: getRetentionTaskLog
      description: Get Retention job task log, tags ratain or deletion detail will be shown in a table.
      tags:
      - Retention
      parameters:
      - $ref: '#/components/parameters/requestId'
      - name: id
        in: path
        required: true
        description: Retention ID.
        schema:
          type: integer
          format: int64
      - name: eid
        in: path
        required: true
        description: Retention execution ID.
        schema:
          type: integer
          format: int64
      - name: tid
        in: path
        required: true
        description: Retention execution ID.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: Get Retention job task log successfully.
          content:
            text/plain:
              schema:
                type: string
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '500':
          $ref: '#/components/responses/500'
components:
  responses:
    '400':
      description: Bad request. The request body or query parameters are invalid. Inspect the `errors` array in the response body for details.
      headers:
        X-Request-Id:
          description: The ID of the corresponding request for the response
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
    '201':
      description: Created
      headers:
        X-Request-Id:
          description: The ID of the corresponding request for the response
          schema:
            type: string
        Location:
          description: The location of the resource
          schema:
            type: string
    '401':
      description: Unauthorized. Authentication is required to access this resource.
      headers:
        X-Request-Id:
          description: The ID of the corresponding request for the response
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
    '403':
      description: Forbidden. The caller does not have sufficient permission to perform the requested operation.
      headers:
        X-Request-Id:
          description: The ID of the corresponding request for the response
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
    '500':
      description: Internal server error. Inspect the `errors` array in the response body for details.
      headers:
        X-Request-Id:
          description: The ID of the corresponding request for the response
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
  parameters:
    requestId:
      name: X-Request-Id
      description: An unique ID for the request
      in: header
      required: false
      schema:
        type: string
        minLength: 1
  schemas:
    Error:
      description: a model for all the error response coming from harbor
      type: object
      properties:
        code:
          type: string
          description: The error code
        message:
          type: string
          description: The error message
      example:
        code: NOT_FOUND
        message: artifact library/hello-world:latest not found
    Errors:
      description: The error array that describe the errors got during the handling of request
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Error'
    RetentionPolicy:
      type: object
      description: retention policy
      properties:
        id:
          type: integer
          format: int64
        algorithm:
          type: string
        rules:
          type: array
          items:
            $ref: '#/components/schemas/RetentionRule'
        trigger:
          type: object
          $ref: '#/components/schemas/RetentionRuleTrigger'
        scope:
          type: object
          $ref: '#/components/schemas/RetentionPolicyScope'
    RetentionMetadata:
      type: object
      description: the tag retention metadata
      properties:
        templates:
          type: array
          description: templates
          items:
            $ref: '#/components/schemas/RetentionRuleMetadata'
        scope_selectors:
          type: array
          description: supported scope selectors
          items:
            $ref: '#/components/schemas/RetentionSelectorMetadata'
        tag_selectors:
          type: array
          description: supported tag selectors
          items:
            $ref: '#/components/schemas/RetentionSelectorMetadata'
    RetentionExecutionTask:
      type: object
      properties:
        id:
          type: integer
          format: int64
        execution_id:
          type: integer
          format: int64
        repository:
          type: string
        job_id:
          type: string
        status:
          type: string
        status_code:
          type: integer
          x-omitempty: false
        status_revision:
          type: integer
          format: int64
        start_time:
          type: string
        end_time:
          type: string
        total:
          type: integer
          x-omitempty: false
        retained:
          type: integer
          x-omitempty: false
    RetentionRule:
      type: object
      properties:
        id:
          type: integer
        priority:
          type: integer
        disabled:
          type: boolean
        action:
          type: string
        template:
          type: string
        params:
          type: object
          additionalProperties:
            type: object
        tag_selectors:
          type: array
          items:
            $ref: '#/components/schemas/RetentionSelector'
        scope_selectors:
          type: object
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/RetentionSelector'
    RetentionRuleMetadata:
      type: object
      description: the tag retention rule metadata
      properties:
        rule_template:
          type: string
          description: rule id
        display_text:
          type: string
          description: rule display text
        action:
          type: string
          description: rule action
        params:
          type: array
          description: rule params
          items:
            $ref: '#/components/schemas/RetentionRuleParamMetadata'
    RetentionRuleTrigger:
      type: object
      properties:
        kind:
          type: string
        settings:
          type: object
        references:
          type: object
    RetentionExecution:
      type: object
      properties:
        id:
          type: integer
          format: int64
        policy_id:
          type: integer
          format: int64
        start_time:
          type: string
        end_time:
          type: string
        status:
          type: string
        trigger:
          type: string
        dry_run:
          type: boolean
    RetentionSelector:
      type: object
      properties:
        kind:
          type: string
        decoration:
          type: string
        pattern:
          type: string
        extras:
          type: string
    RetentionPolicyScope:
      type: object
      properties:
        level:
          type: string
        ref:
          type: integer
    RetentionSelectorMetadata:
      type: object
      description: retention selector
      properties:
        display_text:
          type: string
        kind:
          type: string
        decorations:
          type: array
          items:
            type: string
    RetentionRuleParamMetadata:
      type: object
      description: rule param
      properties:
        type:
          type: string
        unit:
          type: string
        required:
          type: boolean
  securitySchemes:
    basic:
      type: http
      scheme: basic