> ## 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.

# DELETE /v1/ecommerce/products/:id/stock/branch-links/:branch_id

> Stop a branch from selling a product from its source branch's stock.

Unlinks one branch that [sells from another branch's stock](https://docs.keebai.com/dev/endpoints/ecommerce-stock-branch-links.md). From then on it sells this product only from its own stock, which starts at `0`: [transfer](https://docs.keebai.com/dev/endpoints/ecommerce-stock-transfer.md) units to it if it needs them.

## Endpoint

```
DELETE https://api.keebai.com/v1/ecommerce/products/{id}/stock/branch-links/{branch_id}
```

## Required scope

`ecommerce:stock:write`

## Headers

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

## Path parameters

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | `ObjectId` of the product. |
| `branch_id` | `string` | Yes | The linked branch to unlink. |

## Example request

```bash curl theme={"system"}
curl -X DELETE https://api.keebai.com/v1/ecommerce/products/65d3e4f5a6b7c8d9e0f1a2b3/stock/branch-links/br_02 \
  -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```

## Response

### 200 OK

The product's stock after unlinking, in the same shape as [`GET /v1/ecommerce/products/{id}/stock`](https://docs.keebai.com/dev/endpoints/ecommerce-product-stock).

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `ecommerce:stock:write` scope.

### 404 Not Found

No product with that id, or `STOCK_BRANCH_LINK_NOT_FOUND`: the branch was not linked for this product.

### 502 Bad Gateway

`ECOMMERCE_UPSTREAM_ERROR` — the ecommerce service could not answer.


## OpenAPI

````yaml DELETE /v1/ecommerce/products/{id}/stock/branch-links/{branch_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/products/{id}/stock/branch-links/{branch_id}:
    delete:
      tags:
        - ecommerce
      summary: Desvincular una sucursal del stock de otra
      description: >-
        La sucursal deja de vender este producto con el stock de su origen y
        vuelve a su propio stock, que parte en 0. Responde el stock actualizado.
      operationId: PublicEcommerceOperationsController_unlinkStockBranch
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
        - name: branch_id
          required: true
          in: path
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicProductStockDto'
      security:
        - PAT: []
components:
  schemas:
    PublicProductStockDto:
      type: object
      properties:
        product_id:
          type: string
        variants:
          type: array
          items:
            $ref: '#/components/schemas/PublicStockVariantDto'
        links:
          description: Sucursales que venden este producto con el stock de otra sucursal
          type: array
          items:
            $ref: '#/components/schemas/PublicStockBranchLinkDto'
      required:
        - product_id
        - variants
        - links
    PublicStockVariantDto:
      type: object
      properties:
        variant_id:
          type: string
          nullable: true
        name:
          type: string
        total:
          type: number
          description: Stock total
        allocated:
          type: number
          description: Unidades asignadas a sucursales
        warehouse_available:
          type: number
          description: Unidades libres en bodega
        branches:
          type: array
          items:
            $ref: '#/components/schemas/PublicStockBranchDto'
      required:
        - variant_id
        - name
        - total
        - allocated
        - warehouse_available
        - branches
    PublicStockBranchLinkDto:
      type: object
      properties:
        branch_id:
          type: string
          description: Sucursal que vende con el stock de otra
        source_branch_id:
          type: string
          description: Sucursal de origen cuyo stock usa
      required:
        - branch_id
        - source_branch_id
    PublicStockBranchDto:
      type: object
      properties:
        branch_id:
          type: string
        quantity:
          type: number
      required:
        - branch_id
        - quantity
  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.