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

# List stacks in a library

> Returns a paginated list of stacks — assets grouped for collapsed display, whether detected automatically or grouped by the user — ordered by `id`: stable, but arbitrary rather than chronological.

`list_stacks` returns stack metadata only; it does not return the assets inside a stack. To get a stack's frames, use `list_assets` with `stack_id`.

**Pagination** is cursor-based: when `has_more` is true, pass the `id` of the last stack in `data` as `starting_after_id` to fetch the next page.



## OpenAPI

````yaml https://api.gumnut.ai/openapi.json get /api/stacks
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:
    get:
      tags:
        - stacks
      summary: List stacks in a library
      description: >-
        Returns a paginated list of stacks — assets grouped for collapsed
        display, whether detected automatically or grouped by the user — ordered
        by `id`: stable, but arbitrary rather than chronological.


        `list_stacks` returns stack metadata only; it does not return the assets
        inside a stack. To get a stack's frames, use `list_assets` with
        `stack_id`.


        **Pagination** is cursor-based: when `has_more` is true, pass the `id`
        of the last stack in `data` as `starting_after_id` to fetch the next
        page.
      operationId: list_stacks
      parameters:
        - name: library_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Library to list stacks from. Optional if the user has a single
              library; required when they have multiple. Use `list_libraries` to
              enumerate.
            title: Library Id
          description: >-
            Library to list stacks from. Optional if the user has a single
            library; required when they have multiple. Use `list_libraries` to
            enumerate.
        - name: origin
          in: query
          required: false
          schema:
            anyOf:
              - $ref: '#/components/schemas/StackOrigin'
              - type: 'null'
            description: Return only stacks with this provenance.
            title: Origin
          description: Return only stacks with this provenance.
        - name: primary_asset_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Return only the stack that pins this asset (with `asset_` prefix)
              as its cover.
            title: Primary Asset Id
          description: >-
            Return only the stack that pins this asset (with `asset_` prefix) as
            its cover.
        - name: ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Look up specific stacks by ID (max 200; each ID has the
              `asset_stack_` prefix). Accepts multiple `ids=` query params or a
              single comma-delimited value (e.g.,
              `ids=asset_stack_1,asset_stack_2`).
            title: Ids
          description: >-
            Look up specific stacks by ID (max 200; each ID has the
            `asset_stack_` prefix). Accepts multiple `ids=` query params or a
            single comma-delimited value (e.g.,
            `ids=asset_stack_1,asset_stack_2`).
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 200
            minimum: 1
            description: >-
              Maximum number of stacks to return per page (1–200). Defaults to
              20.
            default: 20
            title: Limit
          description: Maximum number of stacks to return per page (1–200). Defaults to 20.
        - name: starting_after_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Cursor for pagination. Pass the `id` of the last stack in the
              previous response's `data` to fetch the next page. Omit for the
              first page.
            title: Starting After Id
          description: >-
            Cursor for pagination. Pass the `id` of the last stack in the
            previous response's `data` to fetch the next page. Omit for the
            first page.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedStacksResponse'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    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.
    PaginatedStacksResponse:
      properties:
        data:
          items:
            $ref: '#/components/schemas/StackResponse'
          type: array
          title: Data
          description: List of stacks
        has_more:
          type: boolean
          title: Has More
          description: >-
            True if there are more stacks after this page. Pass the last stack's
            `id` as `starting_after_id` to fetch the next page.
      type: object
      required:
        - data
        - has_more
      title: PaginatedStacksResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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.
    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

````