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

# Retrieve Sessions

> Gets a list of cart sessions for administrative purposes.



## OpenAPI

````yaml api-reference/v2/openapi-v2-stable.yaml get /sessions
openapi: 3.0.3
info:
  title: CoCart - Cart API v2
  version: 4.6.0
  description: >
    CoCart REST API v2 for managing shopping carts, products, and store
    functionality.

    Compared to API v1, this version provides enhanced endpoints for cart
    operations, product management,

    and administrative functions with improved response structures and better
    error handling.
  termsOfService: http://cocartapi.com/terms-of-conditions-polar/
  contact:
    email: support@cocartapi.com
  license:
    name: GNU General Public License v3.0
    url: http://www.gnu.org/licenses/gpl-3.0.html
servers:
  - url: '{protocol}://{host}/wp-json/cocart/v2'
    description: API v2
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      host:
        default: example-store.com
        description: Your store domain
security: []
tags:
  - name: cart
    description: Operations for managing the shopping cart
  - name: cart-items
    description: Operations for managing cart items
  - name: cart-calculate
    description: Operations for calculating cart totals
  - name: products
    description: Operations for browsing and retrieving product information
  - name: product-attributes
    description: Operations for retrieving product attributes and attribute terms
  - name: product-categories
    description: Operations for browsing and filtering product categories
  - name: product-tags
    description: Operations for browsing and filtering product tags
  - name: product-reviews
    description: Operations for retrieving product reviews and ratings
  - name: product-variations
    description: Operations for retrieving variable product variations
  - name: admin-sessions
    description: Administrative operations for managing cart sessions
  - name: authentication
    description: Operations for user authentication
  - name: store
    description: Operations for retrieving store information and configuration
externalDocs:
  description: Find out more about CoCart API
  url: https://docs.cocartapi.com
paths:
  /sessions:
    get:
      tags:
        - admin-sessions
      summary: Get cart sessions
      description: Gets a list of cart sessions for administrative purposes.
      parameters:
        - name: page
          in: query
          description: Current page of the collection.
          schema:
            type: integer
            default: 1
        - name: per_page
          in: query
          description: Maximum number of items to return per page.
          schema:
            type: integer
            default: 10
      responses:
        '200':
          description: Cart sessions retrieved successfully.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CartSession'
              example:
                - session_key: cb7a23af96a3f23af3c28a8b4b8c6d5e
                  cart:
                    d6b3e8e5a1b0c6e4f2a3b1d8c5e6f9a2:
                      key: d6b3e8e5a1b0c6e4f2a3b1d8c5e6f9a2
                      product_id: 145
                      variation_id: 0
                      quantity: 2
                      line_total: 36
                      line_tax: 3.6
                  customer:
                    billing_email: john.doe@example.com
                    billing_first_name: John
                    billing_last_name: Doe
                  session_expiry: '2024-10-15T18:30:00'
                - session_key: f8d9e1a2b3c4d5e6f7a8b9c0d1e2f3a4
                  cart:
                    a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6:
                      key: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
                      product_id: 278
                      variation_id: 289
                      quantity: 1
                      line_total: 80
                      line_tax: 8
                  customer:
                    billing_email: jane.smith@example.com
                    billing_first_name: Jane
                    billing_last_name: Smith
                  session_expiry: '2024-10-16T12:15:00'
        '400':
          description: Bad request - invalid parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: cocart_invalid_parameter
                message: Invalid parameter provided.
                data:
                  status: 400
        '401':
          description: Unauthorized - authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: cocart_unauthorized
                message: Authentication required to access sessions.
                data:
                  status: 401
        '403':
          description: Forbidden - insufficient permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: cocart_forbidden
                message: You do not have permission to access sessions.
                data:
                  status: 403
      security:
        - basicAuth: []
        - bearerAuth: []
components:
  schemas:
    CartSession:
      type: object
      properties:
        session_key:
          type: string
          description: Unique session key.
        cart:
          type: object
          description: Cart data for this session.
        customer:
          type: object
          description: Customer data for this session.
        session_expiry:
          type: string
          format: date-time
          description: Session expiry date.
    ErrorResponse:
      type: object
      description: Standard error response structure.
      properties:
        code:
          type: string
          description: Machine-readable error code.
          example: cocart_invalid_parameter
        message:
          type: string
          description: Human-readable error message.
          example: Invalid parameter provided.
        data:
          type: object
          description: Additional error data.
          properties:
            status:
              type: integer
              description: HTTP status code.
              example: 400
            params:
              type: object
              description: Parameter-specific error details.
              additionalProperties: true
          additionalProperties: true
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: |
        Basic authentication with username and password.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Bearer token authentication (JWT). Optional for cart and products
        endpoints.

        When provided by customers, enables enhanced functionality like
        persistent carts and user-specific data.

        Required only for admin operations like managing cart sessions.

````