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

# Attach Buyer Identity

> Attach a buyer to the cart. The route accepts either:

  * `Authorization: Bearer cust_…` — the cart is attached to the
    logged-in customer; email/phone are sourced from the body or
    from the customer row.
  * `email` and/or `phone` in the body — anonymous attach.

At least one identity dimension must be present (a token, an
email, or a phone). Phase 2 of the agentic storefront platform.



## OpenAPI

````yaml /api-reference/openapi.json post /api/storefront/cart/{cart_id}/buyer-identity
openapi: 3.1.0
info:
  title: Agentic Commerce API
  description: |2-

        Agentic Commerce API - E-commerce Backend

        ## APIs

        ### Dashboard API (`/api/dashboard`)
        Authenticated endpoints for merchant management:
        - Products, Variants, Options
        - Inventory management
        - Orders and fulfillment
        - Customers
        - Collections

        ### Storefront API (`/api/storefront`)
        Public endpoints for client websites:
        - Product catalog
        - Collections
        - Cart management
        - Checkout

        ### Sync API (`/api/sync`)
        Integration endpoints for zunkiree-search:
        - Product sync
        - Availability checks
        - Order creation from AI widget
        
  version: 1.0.0
servers: []
security: []
paths:
  /api/storefront/cart/{cart_id}/buyer-identity:
    post:
      tags:
        - Storefront
        - Cart
      summary: Attach Buyer Identity
      description: |-
        Attach a buyer to the cart. The route accepts either:

          * `Authorization: Bearer cust_…` — the cart is attached to the
            logged-in customer; email/phone are sourced from the body or
            from the customer row.
          * `email` and/or `phone` in the body — anonymous attach.

        At least one identity dimension must be present (a token, an
        email, or a phone). Phase 2 of the agentic storefront platform.
      operationId: attach_buyer_identity_api_storefront_cart__cart_id__buyer_identity_post
      parameters:
        - name: cart_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Cart Id
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
        - name: X-Site-ID
          in: header
          required: true
          schema:
            type: string
            title: X-Site-Id
        - name: X-Stella-Token
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Stella-Token
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Idempotency-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CartBuyerIdentityRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CartBuyerIdentityResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CartBuyerIdentityRequest:
      properties:
        email:
          anyOf:
            - type: string
              format: email
            - type: 'null'
          title: Email
        phone:
          anyOf:
            - type: string
              maxLength: 50
            - type: 'null'
          title: Phone
      type: object
      title: CartBuyerIdentityRequest
      description: |-
        Attach a buyer to an in-flight cart. At least one of `email`,
        `phone`, or an authenticated customer token must be present —
        enforced in the route, not the schema, since the customer token
        arrives in a header rather than the body.
    CartBuyerIdentityResponse:
      properties:
        cart_id:
          type: string
          format: uuid
          title: Cart Id
        customer_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Customer Id
        email:
          anyOf:
            - type: string
              format: email
            - type: 'null'
          title: Email
        phone:
          anyOf:
            - type: string
            - type: 'null'
          title: Phone
      type: object
      required:
        - cart_id
        - customer_id
        - email
        - phone
      title: CartBuyerIdentityResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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

````