Skip to main content

Gateway products API

This page lists the product routes of the client-facing gateway (apps/gateway), their access requirements, and how each one behaves in catalog mode.

Router: apps/gateway/src/routes/products.ts. Controller: ProductController from @ims/inventory (modules/inventory/src/products/infrastructure/controllers/Product.ts).

Authentication​

ItemValue
HeaderAuthorization: Bearer <token> (apps/gateway/src/middleware/authJWT.ts)
Token sourcePOST /org/token with an organization code (oc3.…)
Access typestandard or extended, carried in the token (req.auth.accessType)
Organizationorganization_id claim (req.auth.orgId)
Missing or invalid token401

Routes​

Method and pathController methodAccessCatalog mode
GET /productsgetAllApiany token—
GET /products/:idgetByIdany token—
POST /productscreateManyextendedApplied (see below)
PUT /products/:idupdateApiany token; fields depend on access typeNever applied
DELETE /products/:iddeleteextended—

extended is enforced by requireExtendedAccess (apps/gateway/src/middleware/requireExtendedAccess.ts):

StatusBody
403{ "error": "This endpoint requires extended access" }

GET /products​

QueryDefaultRange
page1≥ 1
limit501–1000

PUT /products/:id​

Access typeFields savedMissing SKU
standardsku only; every other body key is ignored400 { "error": "Sin acceso extendido solo se puede actualizar el SKU" }
extendedEvery field in the bodyAllowed
RuleValue
Catalog modeNot resolved. UpdateProductUseCase receives catalogMode: false
NameSaved as sent; never generated
Required catalog fieldsNot validated
SKU format400-class error when it contains / (InvalidSkuFormatError)
SKU takenSkuConflictError when the SKU changes to one already in use; 409 on Prisma P2002
Product not found404 (NotFoundError)
Success200 with the updated product

"SKU missing" means sku is absent, not a string, or blank after trimming.

POST /products​

Body: non-empty array of products. Handled by createMany → CreateProductsManyUseCase.

CheckResponse
Body not a non-empty array400 El cuerpo de la solicitud debe ser un arreglo no vacío de productos.
Duplicate first barcode in the batch400 La lista de productos contiene códigos de barras duplicados.
Barcode already used409 Los siguientes códigos de barras ya están asociados a otros productos: <values>.
SKU contains /400
Duplicate SKUs in the batch, or SKUs in useError from DuplicateSkuError
Success201 with the created products

Catalog mode on POST /products​

Catalog mode is resolved for the token organization (with partner inheritance for vendors).

Product typeCatalog ON
STOCK (or no type)presentation, content (≥ 1), unit, categoryId, model are required; the name is always generated
KITName generated only when name is empty

Missing fields on any STOCK row fail the whole batch with 422 and a bulk MissingCatalogFieldsError message. See Product name generation.

DELETE /products/:id​

StatusBody
200empty

Build dependency​

The gateway imports @ims/inventory through its package entry point (modules/inventory/package.json: "main": "dist/index.js"). The gateway runs the compiled dist output of the module, not its TypeScript sources.