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

# Add assets to a stack

> Adds one or more existing assets to the stack. An asset already in another stack is reconciled exactly as `create_stack` does. Ids already in this stack are silently skipped.

An add that changes membership marks the stack user-owned (`origin = user`), which freezes it against burst re-detection; a request that changes nothing leaves `origin` unchanged.

If a concurrent stack change invalidates the request mid-flight, it returns 409 and nothing is changed; retry the request unchanged, except where the 409 reports the target stack itself is gone, which is terminal.



## OpenAPI

````yaml https://api.gumnut.ai/openapi.json post /api/stacks/{stack_id}/assets
openapi: 3.1.0
info:
  title: Gumnut API
  description: API for using Gumnut to manage photos and videos
  version: 0.1.0
servers: []
security: []
paths:
  /api/stacks/{stack_id}/assets:
    post:
      tags:
        - stacks
      summary: Add assets to a stack
      description: >-
        Adds one or more existing assets to the stack. An asset already in
        another stack is reconciled exactly as `create_stack` does. Ids already
        in this stack are silently skipped.


        An add that changes membership marks the stack user-owned (`origin =
        user`), which freezes it against burst re-detection; a request that
        changes nothing leaves `origin` unchanged.


        If a concurrent stack change invalidates the request mid-flight, it
        returns 409 and nothing is changed; retry the request unchanged, except
        where the 409 reports the target stack itself is gone, which is
        terminal.
      operationId: add_assets_to_stack
      parameters:
        - name: stack_id
          in: path
          required: true
          schema:
            type: string
            description: >-
              Stack ID (with `asset_stack_` prefix) of the stack to add the
              assets to.
            title: Stack Id
          description: >-
            Stack ID (with `asset_stack_` prefix) of the stack to add the assets
            to.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StackAssetAddition'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StackResponse'
        '404':
          description: Not found
        '409':
          description: A concurrent stack change invalidated the request
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    StackAssetAddition:
      properties:
        asset_ids:
          items:
            type: string
          type: array
          maxItems: 200
          minItems: 1
          title: Asset Ids
          description: >-
            Asset IDs (with `asset_` prefix) to add to the stack — all in the
            stack's library.
      type: object
      required:
        - asset_ids
      title: StackAssetAddition
    StackResponse:
      properties:
        id:
          type: string
          title: Id
          description: Unique stack identifier with 'asset_stack_' prefix
        primary_asset_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Primary Asset Id
          description: >-
            ID of the asset the user pinned as the stack's cover, or null if
            none is pinned. Null for an auto-detected burst unless a user has
            since pinned a cover — there is no server-selected default, so a
            client showing a stack with no pinned cover picks its own. A pinned
            cover that has been trashed keeps its ID here; it is cleared only
            once the asset is permanently deleted.
        asset_count:
          type: integer
          title: Asset Count
          description: >-
            Number of live assets in this stack. Excludes trashed members, so it
            can drop below the number of frames originally grouped.
        origin:
          $ref: '#/components/schemas/StackOrigin'
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When this stack was created
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: When this stack was last updated
      type: object
      required:
        - id
        - asset_count
        - origin
        - created_at
        - updated_at
      title: StackResponse
      description: Represents a group of assets displayed as a single tile.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    StackOrigin:
      type: string
      enum:
        - auto_burst
        - user
      title: StackOrigin
      description: >-
        How a stack came to exist.


        `auto_burst` marks a stack the burst detector created from the time +

        EXIF-camera signal; `user` marks a stack a user created or edited
        (manual

        create, set-cover, add/remove, unstack). The distinction is what keeps

        re-detection from stomping a user's correction — the detection pass
        skips

        `user` stacks.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````