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

# GET /v1/ecommerce/sales/:id

> Read a single sale with its customer, line items, amounts, and payment state.

Returns one sale by id. Use [`GET /v1/ecommerce/sales`](/dev/endpoints/ecommerce-sales-list) to find the id, or take it from an [`ecommerce.sale.*` webhook](/dev/webhooks/events#ecommerce).

## Endpoint

```
GET https://api.keebai.com/v1/ecommerce/sales/{id}
```

## Required scope

`ecommerce:sales:read`

## Headers

| Header          | Required | Value                    |
| --------------- | -------- | ------------------------ |
| `Authorization` | Yes      | `Bearer kbai_pk_<token>` |

## Path parameters

| Field | Type     | Required | Description                                    |
| ----- | -------- | -------- | ---------------------------------------------- |
| `id`  | `string` | Yes      | `ObjectId` of the sale. Not the `sale_number`. |

## Example request

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.keebai.com/v1/ecommerce/sales/65e4f5a6b7c8d9e0f1a2b3c4 \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ```

  ```js JavaScript theme={null}
  const response = await fetch(
    `https://api.keebai.com/v1/ecommerce/sales/${saleId}`,
    { headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` } },
  );
  const { sale } = await response.json();
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.get(
      f"https://api.keebai.com/v1/ecommerce/sales/{sale_id}",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      timeout=10,
  )
  resp.raise_for_status()
  sale = resp.json()["sale"]
  ```
</CodeGroup>

## Response

### 200 OK

```json theme={null}
{
  "sale": {
    "_id": "65e4f5a6b7c8d9e0f1a2b3c4",
    "sale_number": 1042,
    "status": "completed",
    "payment_status": "partially_paid",
    "currency": "CLP",
    "customer": {
      "name": "Juan Pérez",
      "email": "juan@example.com",
      "phone": "+56912345678",
      "chat_user_id": "65a1f2b3c4d5e6f7a8b9c0d1",
      "customer_id": "65f5a6b7c8d9e0f1a2b3c4d5"
    },
    "items": [
      {
        "kind": "product",
        "name": "Zapatilla Runner Pro",
        "quantity": 1,
        "unit_price": 5990000,
        "subtotal": 5990000
      },
      {
        "kind": "service",
        "name": "Ajuste de plantilla",
        "quantity": 1,
        "unit_price": 1000000,
        "subtotal": 1000000
      }
    ],
    "amounts": {
      "service_subtotal": 1000000,
      "products_subtotal": 5990000,
      "custom_subtotal": 0,
      "net_subtotal": 6990000,
      "tax_amount": 0,
      "tip": 0,
      "total": 6990000
    },
    "payment_method": "card",
    "branch_id": "br_01",
    "professional_id": "pr_12",
    "notes": "Entrega en sucursal",
    "paid_at": "2026-05-02T14:31:07.221Z",
    "created_at": "2026-05-02T14:31:07.221Z",
    "updated_at": "2026-05-02T16:10:44.300Z"
  }
}
```

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `ecommerce:sales:read` scope.

### 404 Not Found

No sale with that id, or it belongs to a different company.

### 502 Bad Gateway

The ecommerce service could not answer.

## Operational notes

* **The id is the `ObjectId`, not the `sale_number`.** Passing `1042` returns `400`.
* **A sale mixes item kinds.** `product`, `service`, and `custom` line items live in the same `items` array, and the `amounts` block breaks the subtotals out by kind so you can split revenue without re-adding them yourself.
* **`payment_status: "partially_paid"` means money is still owed.** `paid_at` is the timestamp of the *first* payment, not of settlement — compare `amounts.total` against your own ledger if you need the outstanding balance.
* **`customer_id` is the [CRM customer](/dev/endpoints/crm-customer-get); `chat_user_id` is the [contact](/dev/endpoints/contacts-get).** They are different records and either can be absent.


## OpenAPI

````yaml GET /v1/ecommerce/sales/{id}
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/ecommerce/sales/{id}:
    get:
      tags:
        - ecommerce
      summary: Obtener detalle de una venta
      operationId: PublicEcommerceController_getSale
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicSaleEnvelopeDto'
      security:
        - PAT: []
components:
  schemas:
    PublicSaleEnvelopeDto:
      type: object
      properties:
        sale:
          $ref: '#/components/schemas/PublicSaleResponseDto'
      required:
        - sale
    PublicSaleResponseDto:
      type: object
      properties:
        _id:
          type: string
          description: ObjectId de la venta
        sale_number:
          type: number
          description: Correlativo legible de la venta
        status:
          type: string
          enum:
            - completed
            - cancelled
            - refunded
        payment_status:
          type: string
          enum:
            - pending
            - paid
            - partially_paid
            - refunded
        currency:
          type: string
        customer:
          $ref: '#/components/schemas/PublicSaleCustomerDto'
        items:
          type: array
          items:
            $ref: '#/components/schemas/PublicSaleItemDto'
        amounts:
          $ref: '#/components/schemas/PublicSaleAmountsDto'
        payment_method:
          type: string
        branch_id:
          type: string
          description: Sucursal asociada
        professional_id:
          type: string
          description: Profesional asociado
        notes:
          type: string
        paid_at:
          type: string
          format: date-time
        cancelled_at:
          type: string
          format: date-time
        refunded_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - _id
        - sale_number
        - status
        - payment_status
        - currency
        - customer
        - items
        - amounts
        - created_at
        - updated_at
    PublicSaleCustomerDto:
      type: object
      properties:
        name:
          type: string
        email:
          type: string
        phone:
          type: string
        chat_user_id:
          type: string
          description: ObjectId del contacto
        customer_id:
          type: string
          description: ObjectId del cliente de CRM
      required:
        - name
    PublicSaleItemDto:
      type: object
      properties:
        kind:
          type: string
          description: product | service | custom
        name:
          type: string
        quantity:
          type: number
        unit_price:
          type: number
        subtotal:
          type: number
      required:
        - kind
    PublicSaleAmountsDto:
      type: object
      properties:
        service_subtotal:
          type: number
        products_subtotal:
          type: number
        custom_subtotal:
          type: number
        net_subtotal:
          type: number
        tax_amount:
          type: number
        tip:
          type: number
        total:
          type: number
      required:
        - service_subtotal
        - products_subtotal
        - custom_subtotal
        - net_subtotal
        - tax_amount
        - tip
        - total
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````