> ## 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.

# Create a shelf

> Creates a new shelf by saving the current state of a workspace's uncommitted changes.

**Parameters:**
- `name` (required)
- `workspace_id` (required)
- `reset_workspace` (optional, defaults to true) - clean the workspace after shelving

**Returns:**
- `409 Conflict` if a shelf with the same name exists
- `204 No Content` if the workspace has no changes
- `201 Created` with the shelf details on success




## OpenAPI

````yaml post /repos/{repo_id}/shelves
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:
    parameters:
      - $ref: '#/components/parameters/RepoParam'
    post:
      tags:
        - Repository Shelves Manipulation
      summary: Create a shelf
      operationId: src.handlersv2.shelf.post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateShelf'
      responses:
        '201':
          description: Shelf details returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Shelf'
        '409':
          $ref: '#/components/responses/Error'
          description: Shelf with the same name already exists
        default:
          $ref: '#/components/responses/Error'
      security:
        - 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.
  schemas:
    CreateShelf:
      type: object
      properties:
        name:
          description: Display name of the shelf
          type: string
        workspace_id:
          description: Workspace ID from which to shelve changes
          type: string
        reset_workspace:
          description: Should reset workspace changes after creating the shelf
          type: boolean
          default: true
      required:
        - name
        - workspace_id
    Shelf:
      type: object
      properties:
        id:
          description: Shelf identifier in Diversion
          type: string
        name:
          description: Display name of the shelf
          type: string
        created_timestamp:
          type: integer
          description: Seconds since epoch UTC
          format: int64
        branch_id:
          description: Optional branch ID from which the changes were shelved
          type: string
      required:
        - id
        - name
        - created_timestamp
    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:
    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

````