> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diversion.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Apply shelf

> Applies a shelf's saved changes to a workspace specified in the `workspace_id` parameter.

**Parameters:**
- `workspace_id` (required)
- `delete_shelf` (optional, defaults to false) - deletes the shelf after successful application

**Conflict handling:**
If conflicts occur during application, returns the merge ID for resolution.

**Returns:**
- `404 Not Found` if the shelf or workspace doesn't exist
- `202 Accepted` with merge_id if conflicts occurred
- `204 No Content` on clean application




## OpenAPI

````yaml post /repos/{repo_id}/shelves/{shelf_id}/apply
openapi: 3.0.3
info:
  title: Diversion Core API
  description: >-
    Definition of the Core API used to access low-level functionality of
    Diversion
  version: 0.2.0
servers:
  - url: https://api.diversion.dev/v0
    description: Base endpoint
security: []
paths:
  /repos/{repo_id}/shelves/{shelf_id}/apply:
    parameters:
      - $ref: '#/components/parameters/RepoParam'
      - $ref: '#/components/parameters/ShelfIdParam'
    post:
      tags:
        - Repository Shelves Manipulation
      summary: Apply a shelf onto a workspace
      operationId: src.handlersv2.shelf.apply
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApplyShelf'
      responses:
        '202':
          description: >-
            The merge is in progress. It has merge conflicts requiring active
            input from the user for conflict resolution. The response contains a
            merge ID, which can be used for querying
            /repos/{repo_id}/merges/{merge_id}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MergeId'
        '204':
          $ref: '#/components/responses/OKEmpty'
          description: The merge into a workspace was completed successfully
        default:
          $ref: '#/components/responses/Error'
      security:
        - OAuth2:
            - coreapi/read
        - OAuth2:
            - coreapi/write
components:
  parameters:
    RepoParam:
      in: path
      name: repo_id
      required: true
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      description: >-
        The repo ID of the repository. Repo _name_ can be used instead of the
        ID, but usage of ID for permanent linking and API requests is preferred.
    ShelfIdParam:
      in: path
      name: shelf_id
      description: Shelf identifier
      schema:
        type: string
        example: dv.shelf.12a37e91-bfc4-4e03-a330-13b5b84ab7cb
        minLength: 3
        maxLength: 128
      required: true
  schemas:
    ApplyShelf:
      type: object
      properties:
        workspace_id:
          description: Workspace ID on which to apply the shelved changes
          type: string
        delete_shelf:
          description: Should shelf be deleted after applying it
          type: boolean
          default: false
      required:
        - workspace_id
    MergeId:
      type: object
      properties:
        merge_id:
          type: string
          example: example_id
          minLength: 3
          maxLength: 128
      required:
        - merge_id
    Error:
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code
          example: 403
        detail:
          type: string
          example: User not authorized to perform the requested action on the resource
        title:
          type: string
        type:
          type: string
      required:
        - status
        - detail
  responses:
    OKEmpty:
      description: Request completed successfully
    Error:
      description: An error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    OAuth2:
      type: oauth2
      x-tokenInfoFunc: src.token_info.token_auth
      description: This API uses OAuth 2 with the implicit grant flow
      flows:
        implicit:
          authorizationUrl: https://auth.diversion.dev/oauth2/authorize
          scopes:
            coreapi/read: Operations with no possible side-effects
            coreapi/write: Modifying operations
            coreapi/admin: >-
              Organizational operations like adding a repo or changing repo
              properties

````