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

# Create anonymous session

> Creates an anonymous user session with a persistent `user_id` for analytics and cart tracking. Returns an `AnonymousUser` object with `access_token` and `refresh_token`. Call this before any other authenticated endpoint for guest users.



## OpenAPI

````yaml post /auth/anonymous
openapi: 3.1.0
info:
  version: '1.0'
  title: CE Storefront APIs
  summary: Customer-facing e-commerce API for building exceptional shopping experiences
  description: >-
    Public-facing API for Commerce Engine storefronts, enabling seamless
    shopping experiences with product browsing, cart management, checkout
    processing, user accounts, and order tracking. Perfect for building web,
    mobile, and headless commerce applications.
  contact:
    name: Support
    email: support@commercengine.io
    url: https://www.commercengine.io/contact-us
  license:
    url: https://www.commercengine.io/contact-us
    name: All Rights Reserved
servers:
  - url: https://staging.api.commercengine.io/api/v1/{store_id}/storefront
    description: Staging Server
    variables:
      store_id:
        description: Store ID
        default: store_id
    x-speakeasy-server-id: staging
  - url: https://prod.api.commercengine.io/api/v1/{store_id}/storefront
    description: Prod Server
    variables:
      store_id:
        description: Store ID
        default: store_id
    x-speakeasy-server-id: prod
security: []
tags:
  - name: Analytics
    description: Analytics
  - name: Auth
    description: auth
  - name: Campaigns
    description: Campaigns
  - name: Carts
    description: Carts
  - name: Catalog
    description: Catalog
  - name: Common
    description: Common
  - name: Coupons & promotions
    description: Coupons & promotions
  - name: Customers
    description: Customers
  - name: Juspay
    description: Juspay Payments
  - name: KYC
    description: KYC
  - name: Marketplace
    description: Marketplace
  - name: Orders
    description: Orders
  - name: Others
    description: Others
  - name: Payments
    description: Payments
  - name: PayU
    description: PayU Payments
  - name: POS
    description: POS
  - name: Shipping
    description: Shipping
  - name: Store
    description: Store
  - name: Subscriptions
    description: Subscriptions
externalDocs:
  url: https://llm-docs.commercengine.io
  description: Commerce Engine API Reference Documentation
paths:
  /auth/anonymous:
    post:
      tags:
        - Auth
      summary: Create anonymous session
      description: >-
        Creates an anonymous user session with a persistent `user_id` for
        analytics and cart tracking. Returns an `AnonymousUser` object with
        `access_token` and `refresh_token`. Call this before any other
        authenticated endpoint for guest users.
      operationId: get-anonymous-token
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                required:
                  - message
                  - success
                  - content
                properties:
                  message:
                    description: >-
                      A string containing a descriptive message related to the
                      success or failure of the anonymous user creation or
                      authentication.
                    type: string
                  success:
                    description: >-
                      A boolean value indicates the success or failure of the
                      anonymous user operation.`true` for success `false` for
                      failure.
                    type: boolean
                  content:
                    description: An object containing the response content.
                    properties:
                      user:
                        $ref: '#/components/schemas/AnonymousUser'
                        description: >-
                          Information about the user, including their name,
                          email, profile image, etc.
                      access_token:
                        description: >-
                          It is a string-based token utilized for authentication
                          and authorization.
                        type: string
                      refresh_token:
                        description: >-
                          It is a string-based token designed for refreshing the
                          user's access token. 
                        type: string
                    required:
                      - user
                      - access_token
                      - refresh_token
                    type: object
          links:
            GetUserCart:
              operationId: get-user-cart
              parameters:
                user_id: $response.body#/content/user/user_id
              description: Retrieve the cart for this anonymous user.
            GetUserDetail:
              operationId: get-user-detail
              parameters:
                id: $response.body#/content/user/user_id
              description: Retrieve the detail of this anonymous user.
            RefreshAnonymousToken:
              operationId: refresh-token
              requestBody:
                refresh_token: $response.body#/content/refresh_token
              description: Refresh the access token using the refresh token.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - X-Api-Key: []
      externalDocs:
        url: >-
          https://llm-docs.commercengine.io/storefront/operations/get-anonymous-token
        description: API reference for the get-anonymous-token operation
components:
  schemas:
    AnonymousUser:
      title: AnonymousUser
      type: object
      externalDocs:
        url: https://llm-docs.commercengine.io/storefront/schemas/AnonymousUser
        description: API reference for the AnonymousUser schema
      required:
        - id
        - is_anonymous
        - is_logged_in
        - first_name
        - last_name
        - phone
        - email
        - is_email_verified
        - is_phone_verified
        - profile_image_url
      properties:
        id:
          description: The unique ID of the user.
          type: string
          readOnly: true
        is_anonymous:
          description: Indicates whether the user is anonymous.
          type: boolean
          readOnly: true
        is_logged_in:
          description: Indicates whether the user is currently logged in.
          type: boolean
          readOnly: true
        first_name:
          description: User’s first name.
          type:
            - string
            - 'null'
        last_name:
          description: User’s last name.
          type:
            - string
            - 'null'
        phone:
          description: 10 digit phone number without country code.
          type:
            - string
            - 'null'
        email:
          description: User’s email I’d.
          type:
            - string
            - 'null'
        is_email_verified:
          description: Boolean indicating whether the email is verified.
          type: boolean
          default: false
          readOnly: true
        is_phone_verified:
          description: Boolean indicating whether the phone is verified.
          type: boolean
          default: false
          readOnly: true
        profile_image_url:
          description: URL to the user's profile image.
          type:
            - string
            - 'null'
        created_at:
          description: Timestamps indicate when the user's account was created.
          type: string
          format: datetime
          readOnly: true
        modified_at:
          description: Timestamps indicating when the user account was last modified.
          type: string
          format: datetime
          readOnly: true
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            required:
              - message
              - success
              - code
            properties:
              message:
                type: string
                x-speakeasy-error-message: true
              success:
                type: boolean
              code:
                type: string
              error:
                type: object
    Unauthorized:
      description: Not authorized for given operation on the Resource
      content:
        application/json:
          schema:
            type: object
            required:
              - message
              - success
              - code
            properties:
              message:
                type: string
                examples:
                  - Not authorized for given operation on the Resource.
                x-speakeasy-error-message: true
              success:
                type: boolean
                default: false
              code:
                type: string
                examples:
                  - unauthorized
  securitySchemes:
    X-Api-Key:
      type: apiKey
      description: API key for your store
      name: X-Api-Key
      in: header

````