API overview

No stability promise

Tienda has no finished public API yet. What follows is the API the Tienda back office and shop use. Endpoints, fields and error texts can change between releases. Only the pages that say "contract" describe something kept stable on purpose, and only as far as they say.

Base URL and format

All paths start with /api/v1 on your Tienda address: https://<your Tienda>/api/v1/.... Requests and answers are JSON. Send Content-Type: application/json with a body. Most list and show answers follow the JSON:API shape (data with id, type, attributes); some endpoints answer with plain JSON. Each page says which.

Other paths are not under /api/v1: GET /version answers the release (1.1.0) as JSON, and GET /up answers 200 when the application runs. The MCP endpoint is POST /mcp (see MCP overview), and the OAuth metadata, consent, token and registration endpoints that MCP clients use sit at /.well-known/oauth-* and /oauth/* on the same address.

Signing in (staff)

Staff sign in with an e-mailed code. There are no passwords.

  1. POST /api/v1/auth/request_code with {"email": "..."} sends a six-digit code.
  2. POST /api/v1/auth/login with {"email": "...", "code": "123456"} returns token, user and application. Add "application_id" to choose a shop when the person belongs to several. Without it, a person with exactly one shop gets that shop; a person with several gets a token without a shop and then picks one with GET /api/v1/auth/shops and POST /api/v1/auth/shops/:id/session.

A code is valid for ten minutes, works once, and is destroyed after five wrong guesses. Send the token on every request: Authorization: Bearer <token>.

A token lasts 24 hours. POST /api/v1/auth/refresh returns a new token; a refresh does not extend the original sign-in, so a shop that sets a maximum session length still ends the session at that limit. A suspended shop answers 403 tenant_suspended on sign-in; an archived shop answers 403 tenant_archived.

Signing in with the Shiloh account is described in Sign in with the Shiloh account.

A script that only needs to read the product feed does not sign in as a person. It uses an API key.

Tenant scoping

A token names one shop. Every request is limited to that shop's data: the controllers start from the shop's own records, and an id that belongs to another shop is refused (not found, or 422 when the id is a reference inside a body). There is no way to read two shops with one token.

Modules and errors

Each endpoint belongs to a module (see Modules). If the module is disabled for the shop the answer is 403 with:

{"error": "module_disabled", "module": "books"}

A module that is read only answers writes with {"error": "module_read_only", "module": "..."}.

Other errors:

StatusBodyMeaning
401{"error": "Unauthorized"}No token, a bad token, or an expired one.
403{"error": "Forbidden"}The role may not do this (viewers cannot write; many endpoints need a shop admin).
403{"error": "Forbidden: missing permission ..."} or missing_permissionA profile limits the user. See Roles and permissions.
404{"error": "<Thing> not found"}No such record in this shop.
422{"errors": ["..."], "details": {"field": ["..."]}}The record was refused.

A person with a driver membership reaches only the driver endpoints; all others answer 403 with "reason": "driver_role".