> ## 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: >-
    The Gumnut API manages photo and video libraries: upload and organize
    assets, search by content, group detected faces into people, and curate
    albums and stacks.


    Headless clients authenticate by sending either a Gumnut API key
    (`apikey_...`) or an OAuth access token as a Bearer token in the
    `Authorization` header. The Gumnut web and mobile apps sign in with a
    first-party session (Clerk session JWT) instead, which is also the only
    credential that can manage API keys and library sharing.
  contact:
    name: Gumnut
    url: https://www.gumnut.ai/contact
  version: 1.0.0
servers:
  - url: https://api.gumnut.ai
    description: Production
security:
  - apiKeyAuth: []
  - oauthJwtAuth: []
tags:
  - name: assets
    description: >-
      Photos and videos in a library: upload, list and filter, update metadata,
      trash and restore.
  - name: search
    description: >-
      Content-based search over a library's assets, with album, person, date,
      and location filters.
  - name: albums
    description: User-curated collections of assets.
  - name: album-assets
    description: Link records connecting albums to their member assets.
  - name: stacks
    description: >-
      Groups of related shots of the same moment, presented as a single unit
      with a cover asset.
  - name: people
    description: Named people, each built from clustered faces.
  - name: faces
    description: Detected faces and their assignment to people.
  - name: libraries
    description: Top-level containers that own assets, albums, people, and everything else.
  - name: library-invitations
    description: First-party invitation management and admission for photo libraries.
  - name: events
    description: Change-event feed for keeping client state in sync.
  - name: tasks
    description: Status of background processing tasks.
  - name: users
    description: The authenticated user's profile.
  - name: api-keys
    description: >-
      Create and manage Gumnut API keys. Requires a first-party Gumnut app
      session — API keys and OAuth tokens cannot manage credentials.
  - name: oauth
    description: OAuth flow endpoints for obtaining and refreshing access tokens.
  - name: feedback
    description: Reports of friction using Gumnut.
  - name: server
    description: Service health.
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
              live (non-trashed) library; required when they have multiple.
            title: Library Id
          description: >-
            Library to list stacks from. Optional if the user has a single live
            (non-trashed) library; required when they have multiple.
        - 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.
        - name: include
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Opt-in expansion fields. Supported values: `asset_ids` (each
              stack's live member IDs). Accepts multiple `include=` query params
              or a single comma-delimited value. Unknown values return 422.
            title: Include
          description: >-
            Opt-in expansion fields. Supported values: `asset_ids` (each stack's
            live member IDs). Accepts multiple `include=` query params or a
            single comma-delimited value. Unknown values return 422.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedStacksResponse'
        '401':
          description: Missing, invalid, or expired credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            The credentials are valid but not authorized for this operation —
            for example an API key whose action or library scope excludes it, or
            a credential type this operation does not accept.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >-
            Clerk sign-in could not be associated with the existing account.
            Resolve the identity conflict before retrying sign-in; repeated
            requests with unchanged verification and identity state will not
            resolve it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnprocessableEntityResponse'
        '429':
          description: >-
            Rate limit exceeded, or too many of your requests are already in
            progress. Retry after the interval in the `Retry-After` header.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: >-
            Authentication provider temporarily unavailable. Retry sign-in
            later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
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
    ErrorResponse:
      title: ErrorResponse
      type: object
      properties:
        detail:
          title: Detail
          type: string
          description: Human-readable explanation of the error.
      required:
        - detail
    UnprocessableEntityResponse:
      title: UnprocessableEntityResponse
      type: object
      properties:
        detail:
          title: Detail
          description: >-
            A semantic validation message or structured request-validation
            errors.
          oneOf:
            - type: string
              description: Human-readable semantic validation message.
            - type: array
              items:
                $ref: '#/components/schemas/ValidationError'
              description: Structured request-validation errors.
      required:
        - detail
    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'
        asset_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Asset Ids
          description: >-
            IDs of the stack's live members, earliest capture time first — the
            order `list_assets` returns for this `stack_id` with `order=asc`.
            Excludes trashed members, like `asset_count`. Only populated by
            `list_stacks` with `include=asset_ids`; null otherwise.
        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
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        Gumnut API key (`apikey_...`) sent as a Bearer token in the
        `Authorization` header. Create and manage keys in the Gumnut app, or
        with the API key endpoints while signed in to it.
    oauthJwtAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Short-lived JWT obtained from the OAuth token exchange, sent as a Bearer
        token in the `Authorization` header.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.