Skip to main content
PUT
Sincronizar sucursales de un producto
Links branches to a source branch for one product: the branches in branch_ids sell it from the source’s stock. Use it when two or more branches in Keebai are one physical store, such as a barbershop and a salon under the same roof. Links are per product, so the same company can have independent pairs: a source with its linked branches in one store, and another source with its own in a second store.

Endpoint

Required scope

ecommerce:stock:write
The scope comes from your role. Minting a token with ecommerce:stock:write requires the permission to adjust and transfer stock in your Keebai role, unless you are the company owner or a superuser. See scopes.

Headers

Path parameters

Body

What linking does

  • The linked branch’s stock moves to the source. Whatever the branch held of this product goes to the source branch, with a transfer entry in the stock movements. The total does not change.
  • Sales from a linked branch take from the source. The sale’s movement keeps the branch that sold, and the units come off the source’s stock. Connected stores are updated from the source branch.
  • A linked branch has no stock of its own. It takes no transfers or adjustments; make them on the source.
  • No chains. A linked branch cannot be a source, and a source cannot be linked to another branch.

Example request

Response

200 OK

The product’s stock after linking, in the same shape as GET /v1/ecommerce/products/{id}/stock, with the links in links.

400 Bad Request

The body does not match the schema, or one of these:

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 it belongs to a different company.

502 Bad Gateway

ECOMMERCE_UPSTREAM_ERROR — the ecommerce service could not answer.

Operational notes

  • Sending the same set again changes nothing. The call replaces the branches of that source, so a retry is safe.
  • To unlink one branch, use DELETE .../stock/branch-links/{branch_id}, or send the source again without it.

Authorizations

Authorization
string
header
required

Personal Access Token con prefijo kbai_pk_. Generar desde el portal con permiso developer.manage_tokens.

Path Parameters

id
string
required

Body

application/json
source_branch_id
string
required

Sucursal de origen cuyo stock se comparte

branch_ids
string[]
required

Sucursales que venden con el stock del origen. Reemplaza las que tenía ese origen; vacío las desvincula todas

Response

200 - application/json
product_id
string
required
variants
object[]
required

Sucursales que venden este producto con el stock de otra sucursal