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

# Create or update a KV bucket

> Creates a new key-value bucket with optional indexing or updates it if one does not exist



## OpenAPI

````yaml /api-reference/endpoint/storage/openapi.json put /storage/kv/{bucket}
openapi: 3.0.3
info:
  title: quiva.ai Gateway
  description: >-
    A comprehensive interface for managing key-value stores, object stores,
    streams, and search indexing
  contact:
    name: quiva.ai Support
    url: https://quiva.ai/help-center/
  version: 1.0.0
servers:
  - url: https://api.quiva.ai
    description: Production API server
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /storage/kv/{bucket}:
    put:
      tags:
        - KV Buckets
      summary: Create or update a KV bucket
      description: >-
        Creates a new key-value bucket with optional indexing or updates it if
        one does not exist
      operationId: createOrUpdateKVBucket
      parameters:
        - $ref: '#/components/parameters/bucketName'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateKVBucketRequest'
            examples:
              update-description:
                summary: Update bucket description
                value:
                  description: Updated product catalog with extended metadata
              update-limits:
                summary: Update storage limits
                value:
                  max_bytes: 21474836480
                  max_value_size: 2097152
              add-indexing:
                summary: Add indexing to existing bucket
                value:
                  indexing:
                    mappings:
                      - field: title
                        field_type: text
                      - field: category
                        field_type: keyword
                    partitions: 2
                    replicas: 1
                    storage_type: file
      responses:
        '200':
          $ref: '#/components/responses/SuccessResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    bucketName:
      name: bucket
      in: path
      description: Name of the bucket
      required: true
      schema:
        type: string
  schemas:
    UpdateKVBucketRequest:
      type: object
      properties:
        description:
          type: string
          description: Updated description of the bucket
        max_bytes:
          type: integer
          description: Updated maximum size of the bucket in bytes
          minimum: 1
        max_value_size:
          type: integer
          description: Updated maximum size of individual values in bytes
          minimum: 1
        indexing:
          $ref: '#/components/schemas/IndexRequest'
    IndexRequest:
      type: object
      required:
        - mappings
        - partitions
        - replicas
        - storage_type
      properties:
        mappings:
          type: array
          description: Field mappings for indexing
          items:
            $ref: '#/components/schemas/IndexMapping'
        partitions:
          type: integer
          description: Number of partitions for the index
          minimum: 1
        replicas:
          type: integer
          description: Number of replicas for the index
          minimum: 1
        storage_type:
          $ref: '#/components/schemas/StorageType'
        stream:
          type: string
          description: Optional stream name for the index
    SuccessMessage:
      type: object
      properties:
        message:
          type: string
          example: success
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message
    IndexMapping:
      type: object
      required:
        - field
        - field_type
      properties:
        field:
          type: string
          description: Field name to be indexed
        field_type:
          type: string
          description: Type of the field
          enum:
            - text
            - number
            - date
            - boolean
            - keyword
    StorageType:
      type: string
      enum:
        - file
        - memory
  responses:
    SuccessResponse:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SuccessMessage'
          example:
            message: success
    BadRequestError:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: validation_error
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: unauthorized
    NotFoundError:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: not_found
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: internal_error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key

````