> ## 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/products/find

> Find a product or variant by exact SKU or barcode, falling back to a text search.

Resolves what a cashier scans or types into the product and variant it belongs to. An exact SKU or barcode returns those matches; anything else runs a text search over the catalog.

This is the lookup to run before [adjusting stock](https://docs.keebai.com/dev/endpoints/ecommerce-stock-adjust.md) or [creating a sale](https://docs.keebai.com/dev/endpoints/ecommerce-sales-create.md), since both take a `product_id` and, on products with variants, a `variant_id`.

## Endpoint

```
GET https://api.keebai.com/v1/ecommerce/products/find
```

## Required scope

`ecommerce:products:read`

## Headers

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

## Query parameters

| Field | Type | Required | Description |
| - | - | - | - |
| `query` | `string` | Yes | SKU, barcode, or free text. |
| `limit` | `integer` | No | Maximum number of items, `1`–`50`. Defaults to 10. |

## Example request

```bash curl theme={"system"}
curl -G https://api.keebai.com/v1/ecommerce/products/find \
  -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  --data-urlencode "query=7801234567890"
```

```js JavaScript theme={"system"}
const params = new URLSearchParams({ query: "7801234567890" });

const response = await fetch(
  `https://api.keebai.com/v1/ecommerce/products/find?${params}`,
  { headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` } },
);
const { match, items } = await response.json();
```

```python Python theme={"system"}
import os, requests

resp = requests.get(
    "https://api.keebai.com/v1/ecommerce/products/find",
    headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
    params={"query": "7801234567890"},
    timeout=10,
)
resp.raise_for_status()
result = resp.json()
```

## Response

### 200 OK

```json theme={"system"}
{
  "match": "exact",
  "items": [
    {
      "product_id": "65d3e4f5a6b7c8d9e0f1a2b3",
      "variant_id": "65d3e4f5a6b7c8d9e0f1a2c1",
      "name": "Zapatilla Runner Pro",
      "variant_name": "42 / Negro",
      "sku": "RUN-PRO-42-NEG",
      "barcode": "7801234567890",
      "price": 59990,
      "stock_total": 12
    }
  ]
}
```

| Field | Type | Description |
| - | - | - |
| `match` | `string` | `exact` when `query` matched a SKU or barcode exactly; `search` when the result comes from a text search. |
| `items[].product_id` | `string` | `ObjectId` of the product. |
| `items[].variant_id` | `string` | `ObjectId` of the variant, when the match is a variant. |
| `items[].name` | `string` | Product name. |
| `items[].variant_name` | `string` | Variant name, when the match is a variant. |
| `items[].sku` | `string` | SKU. |
| `items[].barcode` | `string \| null` | Barcode of the variant. `null` on a product-level item, since barcodes live on variants. |
| `items[].price` | `number` | Price. |
| `items[].stock_total` | `number` | Master stock. See [`GET /v1/ecommerce/products/{id}/stock`](https://docs.keebai.com/dev/endpoints/ecommerce-product-stock) for the split by branch. |

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

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

### 502 Bad Gateway

`ECOMMERCE_UPSTREAM_ERROR` — the ecommerce service could not answer.

## Operational notes

* **SKU and barcode match loosely.** Case and spaces are ignored, so `run-pro-42-neg` finds `RUN-PRO-42-NEG`.
* **Branch on `match`.** With `exact` you can act on the item directly. With `search`, the items are candidates: show them to a person, or pick one only when there is a single clear result.


## OpenAPI

````yaml GET /v1/ecommerce/products/find
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/products/find:
    get:
      tags:
        - ecommerce
      summary: Buscar un producto por SKU, código de barras o texto
      description: >-
        Si `query` coincide exacto con el SKU o el código de barras de un
        producto o variante, devuelve solo esas coincidencias con `match:
        "exact"`. Si no, devuelve los resultados de la búsqueda con `match:
        "search"`.
      operationId: PublicEcommerceOperationsController_findProduct
      parameters:
        - name: query
          required: true
          in: query
          description: >-
            Texto a buscar. Si coincide exacto con el SKU o el código de barras
            de un producto o variante, se devuelven solo esas coincidencias
          schema:
            example: '7801234567890'
            type: string
        - name: limit
          required: false
          in: query
          schema:
            minimum: 1
            maximum: 50
            default: 10
            type: number
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicProductFindResponseDto'
      security:
        - PAT: []
components:
  schemas:
    PublicProductFindResponseDto:
      type: object
      properties:
        match:
          type: string
          enum:
            - exact
            - search
        items:
          type: array
          items:
            $ref: '#/components/schemas/PublicProductFindItemDto'
      required:
        - match
        - items
    PublicProductFindItemDto:
      type: object
      properties:
        product_id:
          type: string
        variant_id:
          type: string
          nullable: true
        name:
          type: string
        variant_name:
          type: string
          nullable: true
        sku:
          type: string
          nullable: true
        barcode:
          type: string
          nullable: true
        price:
          type: number
        stock_total:
          type: number
          description: Stock total del producto o de la variante
      required:
        - product_id
        - variant_id
        - name
        - variant_name
        - sku
        - barcode
        - price
        - stock_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`.

````

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