Quase tudo o que você faz dentro da StockAI também pode ser feito pela API: enviar vendas, treinar e ler a previsão, ler o semáforo, registrar pedidos, gerenciar fornecedores e depósitos. Assim você a conecta ao seu ERP, ao seu POS ou a qualquer sistema próprio.
Cada chamada leva uma chave de API no cabeçalho Authorization. As chaves são criadas no aplicativo, em Automação → API Keys, e mostradas uma única vez: a StockAI guarda somente um hash.
Uma chave age como ela mesma, não como a pessoa que a criou: continua funcionando se essa pessoa deixar a empresa.
Chaves de leitura e de escrita
Ao criar uma chave, você escolhe o que ela pode fazer. Cada endpoint da referência diz que tipo de chave ele exige.
Leitura
Lê tudo o que um usuário leitor vê: semáforo, previsões, fornecedores, pedidos, relatórios.
Leitura e escrita
Além disso, cria e altera, como um analista: envia arquivos, treina, registra pedidos, edita estoque e fornecedores.
Uma chave de leitura que tenta escrever recebe 403 com error_code api_key_scope_insufficient, e nada muda.
O que uma chave nunca pode fazer
Algumas ações são de pessoas, não de sistemas. Com uma chave de API, elas respondem 403 api_key_route_not_exposed:
Entrar, renovar tokens ou recuperar senhas.
Criar, convidar ou alterar usuários e suas permissões.
Criar, listar ou revogar chaves de API: uma chave não pode criar outra.
Configurar a instalação ou os canais da conta.
Exportar ou excluir a conta.
O que pertence a uma pessoa: sua caixa de mensagens, suas conversas com o assistente, suas preferências.
O que só um administrador pode fazer (por exemplo, trocar a moeda ou o período ativo).
Enviar um pedido ou um alerta por e-mail ou WhatsApp com uma chave de escrita exige que a conta tenha pelo menos um administrador com o e-mail verificado (caso contrário: 403 api_key_tenant_unverified).
Limites
Autenticação
/ min
120 chamadas por minuto por chave.
API
A API, o servidor MCP e o bot do WhatsApp vêm com os planos Pro, Max e Corporativo; o plano Grátis não os inclui.
Ao ultrapassar o limite, você recebe 429 com o cabeçalho Retry-After (em segundos). O mesmo 429 serve para o limite por minuto e para o teto diário, e o corpo dele não traz error_code.
Não há cabeçalhos X-RateLimit-*: o único sinal é o 429 com Retry-After. Conte as suas chamadas ou espere o 429.
Medição e compra
A API vem com os planos Pro (2.000 chamadas por dia por chave), Max (20.000) e Corporativo (sem teto diário). Contamos cada chamada feita com uma chave de API que chegou a um endpoint, por dia (UTC) e por chave; as recusadas (chave inválida, sem permissão ou acima do limite) não contam. Um administrador vê o consumo do mês no aplicativo, na tela API.
Quase todo erro traz um error_code estável e, quando aplicável, error_params com os valores: ramifique pelo código, não pelo texto de detail, que é uma dica em inglês e pode mudar. As respostas do próprio framework (cabeçalho ausente, rota inexistente, método incorreto) e o 429 trazem apenas detail.
api_key_invalid
401 a chave não existe, foi revogada ou venceu.
api_key_route_not_exposed
403 esse endpoint não pode ser usado com uma chave de API.
api_key_scope_insufficient
403 a chave é de leitura e o endpoint escreve.
api_key_tenant_unverified
403 enviar algo para fora da StockAI exige um administrador verificado.
validation_error
422 o corpo ou os parâmetros são inválidos; detail é uma lista com um objeto por campo.
PLAN_LIMIT_REACHED
403 você atingiu um teto de uso; detail é um objeto e error_params diz qual.
server_busy
503 o servidor está saturado; tente de novo após Retry-After.
(sem error_code)
401 o cabeçalho Authorization falta ou não é “Bearer sk_live_…”: detail é “Not authenticated”.
(sem error_code)
429 limite por minuto ou teto diário: aguarde Retry-After segundos.
(sem error_code)
404 / 405 rota inexistente ou método não permitido.
A forma de detail
texto
A maioria dos erros: uma frase em inglês.
lista
422 validation_error: [{ type, loc, msg, input }], um por campo inválido; loc diz onde (por exemplo ["body", "name"]).
objeto
PLAN_LIMIT_REACHED: { code, limit, current, max, tier }, o mesmo conteúdo de error_params.
403 Exemplo: chave de leitura que escreve
{"detail":"This endpoint writes and the API key is read-only. Use a write key.","error_code":"api_key_scope_insufficient","error_params":{"required_scope":"write","key_scope":"read"}}
O formato da resposta
Toda resposta JSON vem envolvida: { "success": true, "data": …, "meta": { "timestamp": … } }. O conteúdo útil está em data, que, conforme o endpoint, é um objeto ou uma lista; as listas paginadas trazem a lista em data.items.
Os endpoints que devolvem um arquivo (Excel, PDF, CSV) respondem o próprio arquivo, sem envoltório.
O endpoint MCP (POST /mcp) fala JSON-RPC 2.0 e não usa esse envoltório.
Tipos e formatos
Datas
As datas são YYYY-MM-DD; os instantes, ISO 8601 em UTC, por exemplo 2026-10-01T08:00:00+00:00.
Números
Quantidades e valores são números JSON, não textos. Os valores ficam na moeda da conta (GET /tenant/currency).
Sem valor
Um campo sem valor geralmente chega como null em vez de ser omitido.
Identificadores
Textos opacos com prefixo (sess_…, ds_…, sup_…): guarde-os como estão.
Sinais
O semáforo usa PEDIR_YA, PEDIR_PRONTO, OK e SOBRESTOCK: valores fixos que não se traduzem.
Paginação
Há três formas, e cada endpoint declara a sua nos parâmetros:
skip e limit
Execuções, resumo das execuções, fontes de dados e datasets. A resposta traz items, total, skip e limit.
limit e offset
A atividade de alertas (/alerts/activity). A resposta traz items, total, limit e offset.
somente limit
Os mais recentes primeiro, até limit: alertas, histórico de pedidos, lacunas de configuração, perdas de estoque e histórico de retreinamentos.
sem paginação
Os demais devolvem o conjunto completo e são restringidos pelos seus filtros, por exemplo signal ou supplier em /inventory/status.
Idempotência
POST /inventory/log-po e POST /inventory/po aceitam o cabeçalho Idempotency-Key: um valor único (um UUID) por pedido que você quer fazer. Se repetir a requisição com a mesma chave, você recebe o pedido que já foi criado (200 com replayed: true) em vez de um segundo; a mesma chave com outras linhas responde 409 po_idempotency_key_reused. Os demais endpoints de escrita não são idempotentes: antes de repetir uma escrita cujo resultado você não viu, consulte se ela já foi aplicada.
A mesma chave abre um servidor MCP em POST /mcp com cinco ferramentas somente de leitura, para que um assistente de IA consulte o seu semáforo. Por design, ele não escreve nada. GET /mcp responde 405: o servidor não abre um fluxo para o cliente.
Referência de endpoints
Gerada a partir do próprio serviço: se um endpoint está aqui, ele pode ser chamado com uma chave de API. As respostas de exemplo são chamadas reais a uma conta de teste. As descrições estão em inglês, como o código.
POSTExplain a SKU's recommendation
Narrativas com IA
Explain a SKU's recommendation
POST/api/v1/ai/narrative/forecast-explanation
Chave de leituraResponde 200 · application/json
Explains a specific SKU's inventory signal and recommendation in plain language.
Requisição
Cabeçalhos
AuthorizationBearer sk_live_…obrigatório
Sua chave de API. Sempre obrigatória.
Content-Typeapplication/jsonobrigatório
Corpo
application/jsonO corpo é obrigatório.
objectUm objeto.
skustringobrigatório
session_idstringobrigatório
profilestringopcionalpadrão "distributor"
languagestringopcionalpadrão "es"
Respostas
200 Se der certo
Para este endpoint não foi capturada uma resposta de exemplo. Toda resposta JSON traz este envoltório; o que vem em data depende do endpoint.
Erros possíveis
Além dos erros de cada endpoint, toda chamada feita com uma chave pode responder:
401Authorization header missing, or API key invalid, revoked or expired.
403Key may not call this endpoint, is read-only on a write, or a permission check refused it.
429Per-minute limit or daily ceiling reached; honour Retry-After.
Return hyperparameter schemas for all available models.
Configuração da execução
Dataset profile (alias)
GET/api/v1/sessions/{session_id}/profile
Chave de leituraResponde 200 · application/json
Alias of GET /sessions/{session_id}/inspect.
Configuração da execução
Upload and attach a dataset
POST/api/v1/sessions/{session_id}/upload
Chave de escritaResponde 201 · application/json
Uploads a file (multipart) and attaches it to the session in one call.
Moeda
Read the currency
GET/api/v1/tenant/currency
Chave de leituraResponde 200 · application/json
Readable by every role: it is needed to render any figure on any screen.
Fontes de dados
List data sources
GET/api/v1/data-sources
Chave de leituraResponde 200 · application/json
The tenant's file and SQL data sources. Paginated with skip and limit.
Fontes de dados
Create a file data source
POST/api/v1/data-sources/file
Chave de escritaResponde 200 · application/json
Uploads a CSV/Excel file (multipart) as a new data source.
Fontes de dados
Create a SQL data source
POST/api/v1/data-sources/sql
Chave de escritaResponde 200 · application/json
Registers a database connection as a data source. Fields may come from a pasted `connection_string` (URL, JDBC, ADO.NET or libpq form); typed fields win. `ssl_mode` is disable, prefer, require, verify-ca or verify-full; `ssl_ca` is the server's CA certificate (PEM), stored encrypted like the password. Private and link-local hosts are refused unless the installation allows them (`data_source_host_not_allowed`).
Fontes de dados
Parse a connection string
POST/api/v1/data-sources/sql/parse
Chave de escritaResponde 200 · application/json
Reads a connection string into engine, host, port, database, user and TLS mode. The password is never returned, only `has_password`.
Fontes de dados
Delete a data source
DEL/api/v1/data-sources/{source_id}
Chave de escritaResponde 200 · application/json
Removes the data source.
Fontes de dados
Get a data source
GET/api/v1/data-sources/{source_id}
Chave de leituraResponde 200 · application/json
One data source's metadata.
Fontes de dados
Rename a data source
PATCH/api/v1/data-sources/{source_id}
Chave de escritaResponde 200 · application/json
Changes the data source's name and description.
Fontes de dados
Analyze a data source
GET/api/v1/data-sources/{source_id}/analyze
Chave de leituraResponde 200 · application/json
Demand statistics over the source: totals, seasonality and per-SKU summaries, optionally within a date range.
Executes ONE read statement (SELECT or WITH ... SELECT) on the customer's database, inside a read-only transaction that is always rolled back, and returns up to `limit` rows starting at `offset`, with `has_more`. Needs a `write`-scope key: it runs caller-written SQL on the customer's database. Anything else is refused with `sql_multiple_statements`, `sql_not_a_select`, `sql_forbidden_keyword`, `sql_forbidden_function` or `sql_unsupported_syntax`.
Fontes de dados
Export a SQL query as Excel or CSV
POST/api/v1/data-sources/{source_id}/export-query
Chave de escritaResponde 200 · application/json
Runs the query (same read-only rules as execute-query) and returns the FULL result as an .xlsx (default) or .csv file, refusing rather than truncating past the row ceiling. Needs a `write`-scope key.
Fontes de dados
Replace a data source's file
POST/api/v1/data-sources/{source_id}/file
Chave de escritaResponde 200 · application/json
Uploads a new file (multipart) IN PLACE: the source keeps its id and column mapping, so the next training run needs no reconfiguration. The nightly-export endpoint.
Fontes de dados
Materialize a SQL query as a dataset
POST/api/v1/data-sources/{source_id}/materialize
Chave de escritaResponde 200 · application/json
Runs the query and stores the result as a dataset that sessions can train on.
Fontes de dados
Preview a data source
GET/api/v1/data-sources/{source_id}/preview
Chave de leituraResponde 200 · application/json
The first rows of the source (and of a given sheet, for Excel).
Fontes de dados
Save a SQL source's query
PATCH/api/v1/data-sources/{source_id}/query
Chave de escritaResponde 200 · application/json
Stores the query the SQL source materializes.
Fontes de dados
Save an edited table as a new source
POST/api/v1/data-sources/{source_id}/save-as-new
Chave de escritaResponde 200 · application/json
Creates a new data source from edited columns and rows.
Fontes de dados
List a SQL source's tables
GET/api/v1/data-sources/{source_id}/schema
Chave de escritaResponde 200 · application/json
Tables and views the connection can read, with row estimates and a safely quoted preview statement for each. Cached for a few minutes; `refresh=true` re-reads.
Column names, types and nullability of one table of a SQL source.
Fontes de dados
Update a SQL source's connection
PATCH/api/v1/data-sources/{source_id}/sql-config
Chave de escritaResponde 200 · application/json
Changes any connection field of a SQL source. Omitted fields keep their stored value, the password included, except when the engine, host or port changes: then the password must be sent again (`data_source_password_required`).
Runs a staged test (dns, tcp, tls, auth, privileges, select, tables) and reports each stage as ok, warning, failed or skipped with a code. Warns when the login can write, with the least-privilege GRANT statements.
Datasets
List datasets
GET/api/v1/datasets
Chave de leituraResponde 200 · application/json
Uploaded datasets. Paginated with skip and limit.
Datasets
Upload a dataset
POST/api/v1/datasets
Chave de escritaResponde 201 · application/json
Uploads a sales-history file (multipart) and profiles it.
Datasets
Get a dataset
GET/api/v1/datasets/{dataset_id}
Chave de leituraResponde 200 · application/json
One dataset's metadata and profile.
Documentos
List documents
GET/api/v1/documents
Chave de leituraResponde 200 · application/json
Documents uploaded for the analyst to read.
Documentos
Upload a document
POST/api/v1/documents
Chave de escritaResponde 200 · application/json
Upload a document (PDF, DOCX, TXT up to 50 MB). File is saved to storage and indexed asynchronously. Returns doc metadata with status=PENDING immediately.
Documentos
Delete a document
DEL/api/v1/documents/{doc_id}
Chave de escritaResponde 200 · application/json
Removes the document and its index.
Documentos
Get a document
GET/api/v1/documents/{doc_id}
Chave de leituraResponde 200 · application/json
One document's metadata.
Documentos
Download a document
GET/api/v1/documents/{doc_id}/content
Chave de leituraResponde 200 · application/json
Serve the raw file for in-browser viewing or download.
Documentos
Document indexing status
GET/api/v1/documents/{doc_id}/status
Chave de leituraResponde 200 · application/json
Whether the document has been processed and indexed.
Limites de uso
Read plan and limits
GET/api/v1/entitlements
Chave de leituraResponde 200 · application/json
This tenant's tier, its ceilings, and how close it is to them.
Previsões
Configuration schema
GET/api/v1/config/schema
Chave de leituraResponde 200 · application/json
The JSON schema of every configuration block, independent of a session.
Previsões
Available forecasting models
GET/api/v1/models/available
Chave de leituraResponde 200 · application/json
The forecasting models this deployment can train.
Previsões
Forecast accuracy
GET/api/v1/sessions/{session_id}/accuracy
Chave de leituraResponde 200 · application/json
Accuracy of the session's forecasts against baselines, per SKU and overall.
The latest automatic reading of how this forecast is doing against the sales uploaded after it was made, next to its accuracy at training time.
Previsões
Models available to a session
GET/api/v1/sessions/{session_id}/available-models
Chave de leituraResponde 200 · application/json
The models that can be trained on this session's data.
Previsões
Start Backtest
POST/api/v1/sessions/{session_id}/backtest
Chave de escritaResponde 202 · application/json
Train a back-test of a completed session: the same configuration on a copy of its dataset with the last `holdout_periods` periods held out. Its forecast then covers those periods and can be graded against the full dataset with `forecast-vs-actual`. The source session and dataset are not modified; the run counts against the plan's saved-forecast ceiling and is refused (nothing deleted) when that is full.
Previsões
Session configuration schema
GET/api/v1/sessions/{session_id}/config-schema
Chave de leituraResponde 200 · application/json
The configuration schema with this session's current values.
History and forecast (with quantiles) for one SKU, optionally for a given model.
Previsões
Get Forecast Total
GET/api/v1/sessions/{session_id}/forecast-total
Chave de leituraResponde 200 · application/json
The whole catalogue as one series: every SKU's champion forecast and history summed per date. Feeds the session-comparison chart's "all SKUs" option, where two sessions are only comparable as totals.
What this session predicted vs. what the tenant's LATER sales uploads say actually happened: per-SKU and pooled WAPE / MAPE / bias, the predicted-vs- actual series, and a verdict code the frontend renders in words.
Previsões
Session inventory recommendations
GET/api/v1/sessions/{session_id}/inventory
Chave de leituraResponde 200 · application/json
Per-SKU inventory recommendations computed from this session's forecast.
Previsões
Training metrics
GET/api/v1/sessions/{session_id}/metrics
Chave de leituraResponde 200 · application/json
Validation metrics per model and SKU.
Previsões
List forecast overrides
GET/api/v1/sessions/{session_id}/overrides
Chave de leituraResponde 200 · application/json
Manual adjustments made to the session's forecast.
Previsões
Save forecast overrides
PATCH/api/v1/sessions/{session_id}/overrides
Chave de escritaResponde 200 · application/json
Upserts manual forecast values per SKU and date, with a reason. The body is a list.
Previsões
Predict on demand
POST/api/v1/sessions/{session_id}/predict
Chave de leituraResponde 200 · application/json
Runs the trained model for one SKU with the given inputs and horizon.
Previsões
Data quality
GET/api/v1/sessions/{session_id}/quality
Chave de leituraResponde 200 · application/json
Data-quality findings for the session's dataset.
Previsões
Reconcile actual values
POST/api/v1/sessions/{session_id}/reconcile
Chave de leituraResponde 200 · application/json
Upload a CSV of actual values to compare against the stored forecast.
Previsões
Session report (alias)
GET/api/v1/sessions/{session_id}/report
Chave de leituraResponde 200 · application/json
The session's results summarized as one report document.
Previsões
Training results
GET/api/v1/sessions/{session_id}/results
Chave de leituraResponde 200 · application/json
Forecasts and per-model results of a completed session, at SKU or aggregate level.
Previsões
Model routing
GET/api/v1/sessions/{session_id}/routing
Chave de leituraResponde 200 · application/json
Which model was routed to each SKU and why.
Previsões
Model routing plan (alias)
GET/api/v1/sessions/{session_id}/routing-plan
Chave de leituraResponde 200 · application/json
The routing decisions as a plan, per SKU segment.
Previsões
Read a SKU's feature importances
GET/api/v1/sessions/{session_id}/shap/{sku}
Chave de leituraResponde 200 · application/json
Return SHAP feature importances for the best model for the given SKU.
Everything known about one SKU in the session: series, model, drivers and recommendation.
Previsões
List run warnings
GET/api/v1/sessions/{session_id}/warnings
Chave de leituraResponde 200 · application/json
Data problems the validation layers found while training this session.
Atualidade dos dados
Read data freshness
GET/api/v1/data-freshness
Chave de leituraResponde 200 · application/json
Age of the sales history and of the stock table, plus whether the semáforo may still claim a colour.
Estoque, compras e fornecedores
Send the daily alert now
POST/api/v1/inventory/alerts/send-now
Chave de escritaResponde 202 · application/json
Fire the daily inventory alert immediately for this tenant — email to the admins, WhatsApp to the ones who opted in. Lets the user verify their channels without waiting for the 8:00 UTC scheduler run.
Estoque, compras e fornecedores
List where a component is used
GET/api/v1/inventory/bom/{child_sku}/used-in
Chave de leituraResponde 200 · application/json
Returns all finished goods that use this component.
Estoque, compras e fornecedores
Read a bill of materials
GET/api/v1/inventory/bom/{parent_sku}
Chave de leituraResponde 200 · application/json
Returns BOM (Bill of Materials) for a finished good.
Estoque, compras e fornecedores
Remove a bill-of-materials line
DEL/api/v1/inventory/bom/{parent_sku}/{child_sku}
Chave de escritaResponde 204 · application/json
Removes a component from a parent SKU's bill of materials.
Estoque, compras e fornecedores
Set a bill-of-materials line
PUT/api/v1/inventory/bom/{parent_sku}/{child_sku}
Chave de escritaResponde 200 · application/json
Creates or updates how much of a component one unit of the parent SKU uses.
Estoque, compras e fornecedores
Import stock from a file
POST/api/v1/inventory/bulk
Chave de escritaResponde 200 · application/json
Import stock from a CSV or Excel file.
Estoque, compras e fornecedores
Preview a stock import
POST/api/v1/inventory/bulk/preview
Chave de escritaResponde 200 · application/json
Dry run of POST /bulk: what we detected in the file and what we would write, without touching a single row. This is what makes the mapping wizard possible — the user corrects our column guesses BEFORE importing, the same way the sales upload works.
Estoque, compras e fornecedores
Read the cash calendar
GET/api/v1/inventory/cash-calendar
Chave de leituraResponde 200 · application/json
Invoices falling due from POs already sent, dated by each supplier's credit terms. Read-only, so viewers may call it.
Estoque, compras e fornecedores
Fit a purchase into a budget
POST/api/v1/inventory/cash-calendar/fit
Chave de leituraResponde 200 · application/json
"Does the recommended purchase fit in the cash I have?"
Estoque, compras e fornecedores
Read the dashboard summary
GET/api/v1/inventory/dashboard-summary
Chave de leituraResponde 200 · application/json
Lightweight endpoint for the dashboard widget. Returns only the summary counts without the full item list.
Estoque, compras e fornecedores
List dead capital
GET/api/v1/inventory/dead-capital
Chave de leituraResponde 200 · application/json
Every SKU on hand whose stock level has not fallen in at least `window_days`, ranked worst first by money, with the tenant's total at the top. Needs no session — it reads real stock-level history, not a forecast.
Estoque, compras e fornecedores
List demand events
GET/api/v1/inventory/events
Chave de leituraResponde 200 · application/json
Promotions and seasonal events that multiply expected demand.
Estoque, compras e fornecedores
Create a demand event
POST/api/v1/inventory/events
Chave de escritaResponde 201 · application/json
Adds an event with a date range and a demand multiplier.
Estoque, compras e fornecedores
Read the event catalog
GET/api/v1/inventory/events/catalog
Chave de leituraResponde 200 · application/json
Which commercial events StockAI knows for a country, and whether this tenant has them seeded / switched on. Read-only.
Estoque, compras e fornecedores
Seed the event catalog
POST/api/v1/inventory/events/catalog/seed
Chave de escritaResponde 200 · application/json
Preload the LatAm commercial calendar into this tenant's events.
Drop the override: the product falls back to the event multiplier.
Estoque, compras e fornecedores
Project revenue, cost and margin
GET/api/v1/inventory/forecast-money
Chave de leituraResponde 200 · application/json
Projected revenue, cost and gross margin over the active session's forecast horizon, per SKU and in total, ranked so the top contributors are visible — "your next N days: X in sales, Y in margin, and these products carry it."
Estoque, compras e fornecedores
Record a purchase order
POST/api/v1/inventory/log-po
Chave de escritaResponde 201 · application/json
Records that an order was placed, with its lines. Reception tracking and supplier lead-time learning read it. A body without `items` records every actionable SKU of the session.
Estoque, compras e fornecedores
List margin erosion
GET/api/v1/inventory/margin-erosion
Chave de leituraResponde 200 · application/json
SKUs whose margin eroded because their cost rose while the product's sale_price is the only price StockAI has ever stored. `price_history_available: false` in the response is load-bearing: the "before" margin is today's price against a past cost, not a historical fact — see `cost_alerts.get_margin_erosion`'s docstring.
Estoque, compras e fornecedores
Read the morning briefing
GET/api/v1/inventory/morning-briefing
Chave de leituraResponde 200 · application/json
Daily operations briefing: risks, recommendations, demand changes, KPIs. Designed to be the first thing a manager opens every morning. Reflects the tenant's ACTIVE planning period — coverage and the signal in that unit — so /hoy agrees with /inventory (a weekly session must be read as weekly).
Estoque, compras e fornecedores
Optimize purchases and transfers
GET/api/v1/inventory/optimize
Chave de leituraResponde 200 · application/json
Runs the MILP purchasing/transfers optimizer for this session and returns suggested purchase quantities per SKU x warehouse, plus recommended inter-warehouse transfers, collapsed to one total per line over the full horizon.
Estoque, compras e fornecedores
Create a manual purchase order
POST/api/v1/inventory/po
Chave de escritaResponde 201 · application/json
A purchase order the buyer writes from scratch — supplier chosen explicitly, lines typed in, no forecast session behind it. Persisted with source='manual' so adoption metrics stay clean. `Idempotency-Key`: same contract as /log-po.
Estoque, compras e fornecedores
List recent purchase orders
GET/api/v1/inventory/po-history
Chave de leituraResponde 200 · application/json
Returns recent PO generation events for the history panel.
Estoque, compras e fornecedores
Po History Page
GET/api/v1/inventory/po-history/page
Chave de leituraResponde 200 · application/json
The PO history, filtered and paged on the server. `total` counts the filtered set; `awaiting_reception` counts every open order of the tenant.
Estoque, compras e fornecedores
Import purchase orders from a file
POST/api/v1/inventory/po/import
Chave de escritaResponde 200 · application/json
Create purchase orders from a CSV / Excel file, one order per (order reference, supplier, destination warehouse).
Estoque, compras e fornecedores
Preview a purchase-order import
POST/api/v1/inventory/po/import/preview
Chave de escritaResponde 200 · application/json
Dry run of POST /po/import: the orders the file would create, and every row whose supplier / product / warehouse did not resolve. Writes nothing.
Estoque, compras e fornecedores
Download the purchase-order import template
GET/api/v1/inventory/po/import/template
Chave de leituraResponde 200 · application/json
Purchase-order import template: header row plus example lines (two orders, the first with two lines).
Estoque, compras e fornecedores
List overdue purchase orders
GET/api/v1/inventory/po/overdue
Chave de leituraResponde 200 · application/json
POs still pending/partial whose expected arrival — order date plus the supplier's already-learned lead time — has passed with no reception recorded. Powers the /hoy 'did it arrive?' nudge.
Estoque, compras e fornecedores
List a purchase order's lines
GET/api/v1/inventory/po/{po_log_id}/items
Chave de leituraResponde 200 · application/json
Lines of a PO with ordered vs received quantities (reception form).
Estoque, compras e fornecedores
Receive a purchase order
POST/api/v1/inventory/po/{po_log_id}/receive
Chave de escritaResponde 200 · application/json
Record that a PO arrived (fully, partially, or not at all). Side effects: current_stock increases by the received units, and StockAI logs the supplier's REAL lead time (order date → reception date).
Estoque, compras e fornecedores
Send a purchase order to suppliers
POST/api/v1/inventory/po/{po_log_id}/send
Chave de escritaResponde 200 · application/json
Sends a PO's PDF to each of its suppliers by email and WhatsApp, grouping the PO's lines by supplier name (a PO can span more than one supplier). Lines with no supplier name, or whose supplier has no saved contact info, are skipped and reported back — never a 500.
Estoque, compras e fornecedores
List price breaks
GET/api/v1/inventory/price-breaks
Chave de leituraResponde 200 · application/json
Supplier quantity scales, optionally filtered by supplier and/or SKU.
Estoque, compras e fornecedores
Evaluate price breaks for a cart
POST/api/v1/inventory/price-breaks/evaluate
Chave de leituraResponde 200 · application/json
Given the cart the buyer currently has on screen, which lines are one step away from a better unit price AND would still be a good idea to step up to.
The valid product types, as the English keys the frontend translates.
Estoque, compras e fornecedores
Explode demand into components
GET/api/v1/inventory/production-requirements
Chave de leituraResponde 200 · application/json
MRP Level 1 explosion: given forecast demand + BOM, returns required quantities of each component and raw material, flagging shortages and purchase requirements.
Estoque, compras e fornecedores
Download the inventory PDF
GET/api/v1/inventory/report/pdf
Chave de leituraResponde 200 · application/json
Generates and streams a one-page executive PDF inventory summary.
Estoque, compras e fornecedores
Read accumulated ROI
GET/api/v1/inventory/roi
Chave de leituraResponde 200 · application/json
Returns accumulated ROI metrics across all time.
Estoque, compras e fornecedores
Read one month's ROI report
GET/api/v1/inventory/roi/month-report
Chave de leituraResponde 200 · application/json
Recap of a single calendar month (feature 3.2). Defaults to the month that just closed — the same period the monthly recap email covers.
Estoque, compras e fornecedores
List monthly ROI
GET/api/v1/inventory/roi/monthly
Chave de leituraResponde 200 · application/json
Last N months: orders, stockout risks handled, adoption, capital freed from overstock.
Estoque, compras e fornecedores
List SKUs missing setup
GET/api/v1/inventory/setup-gaps
Chave de leituraResponde 200 · application/json
Unconfigured SKUs ordered by the money they move, with the running cumulative share of projected spend.
Estoque, compras e fornecedores
List shrinkage
GET/api/v1/inventory/shrinkage
Chave de leituraResponde 200 · application/json
Recent history of recorded shrinkage (input to the future monthly summary).
Estoque, compras e fornecedores
Record shrinkage
POST/api/v1/inventory/shrinkage
Chave de escritaResponde 201 · application/json
Record a stock-out that is NOT a sale — breakage, expiry, self-consumption or a gift/sample. Decrements the SKU's theoretical stock through the same path PO reception uses (so the signal stays accurate) and accumulates the cost (quantity x unit cost) for a future monthly shrinkage summary.
Estoque, compras e fornecedores
List shrinkage reasons
GET/api/v1/inventory/shrinkage/reasons
Chave de leituraResponde 200 · application/json
Returns the valid shrinkage reason codes (labels are handled client-side via i18n).
Estoque, compras e fornecedores
Read the inventory traffic light
GET/api/v1/inventory/status
Chave de leituraResponde 200 · application/json
Returns per-SKU inventory status in the tenant's ACTIVE planning period:
- coverage (in the active period's units — see `coverage_unit`)
- traffic-light signal (PEDIR_YA / PEDIR_PRONTO / OK / SOBRESTOCK / SIN_DATOS)
- recommended order quantity
- inventory value
Estoque, compras e fornecedores
Export the purchase order as CSV
GET/api/v1/inventory/status/export-po
Chave de leituraResponde 200 · application/json
Export purchase order as CSV, filtered to actionable SKUs.
Estoque, compras e fornecedores
List stock
GET/api/v1/inventory/stock
Chave de leituraResponde 200 · application/json
Every SKU's stock record: on hand, minimum, lead time, cost, supplier and catalogue fields.
Estoque, compras e fornecedores
List Counts
GET/api/v1/inventory/stock-counts
Chave de leituraResponde 200 · application/json
List stock counts, newest first, with how many products each holds.
Estoque, compras e fornecedores
Create Count
POST/api/v1/inventory/stock-counts
Chave de escritaResponde 201 · application/json
Open a count session for one warehouse, optionally scoped to a category or supplier.
Estoque, compras e fornecedores
Get Count
GET/api/v1/inventory/stock-counts/{count_id}
Chave de leituraResponde 200 · application/json
One count with every line (counted quantity next to the system quantity at the first scan).
Write the differences into stock, exactly once, and record each adjustment with reason 'physical_count'. Omit skus to apply every line; a list applies only those. All or nothing.
Sets the supplier's cost, MOQ, lead time and primary flag for the SKU.
Estoque, compras e fornecedores
List supplier cost inflation
GET/api/v1/inventory/supplier-cost-inflation
Chave de leituraResponde 200 · application/json
Suppliers who raised a SKU's cost at least once in the window, worst first, with the products each one hit hardest. Built only from POs that were actually received — a quoted or rejected order proves nothing was paid.
Estoque, compras e fornecedores
List suppliers
GET/api/v1/inventory/suppliers
Chave de leituraResponde 200 · application/json
The tenant's suppliers with contact details, lead times and payment terms.
Estoque, compras e fornecedores
Create a supplier
POST/api/v1/inventory/suppliers
Chave de escritaResponde 201 · application/json
Adds a supplier with contact details, lead time and payment terms.
Estoque, compras e fornecedores
Check supplier contact details
GET/api/v1/inventory/suppliers/contact-health
Chave de leituraResponde 200 · application/json
Suppliers that POST /po/{id}/send would silently skip — no email and no WhatsApp on file, or a supplier name on PO lines with no record at all (feature 2.5).
Estoque, compras e fornecedores
Import suppliers from a file
POST/api/v1/inventory/suppliers/import
Chave de escritaResponde 200 · application/json
Create suppliers from a CSV / Excel file.
Estoque, compras e fornecedores
Preview a suppliers import
POST/api/v1/inventory/suppliers/import/preview
Chave de escritaResponde 200 · application/json
Dry run of POST /suppliers/import: what was detected and what would be written. Touches no row.
Estoque, compras e fornecedores
Download the suppliers import template
GET/api/v1/inventory/suppliers/import/template
Chave de leituraResponde 200 · application/json
Suppliers import template: the header row plus two example rows.
Estoque, compras e fornecedores
List supplier lead-time alerts
GET/api/v1/inventory/suppliers/lead-time-alerts
Chave de leituraResponde 200 · application/json
Suppliers whose recent lead time is significantly slower than their own history — "Acme is taking 12 days, not 7" (feature 3.3).
Estoque, compras e fornecedores
List Suppliers Page
GET/api/v1/inventory/suppliers/page
Chave de leituraResponde 200 · application/json
Active suppliers, searched and paged on the server (the plain list stays whole for the dropdowns that need every supplier).
Estoque, compras e fornecedores
Read the supplier scorecard
GET/api/v1/inventory/suppliers/scorecard
Chave de leituraResponde 200 · application/json
Per-supplier performance: real lead time range, on-time rate, fill rate.
Estoque, compras e fornecedores
Deactivate a supplier
DEL/api/v1/inventory/suppliers/{supplier_id}
Chave de escritaResponde 204 · application/json
Deactivates the supplier (see the reactivate endpoint).
Estoque, compras e fornecedores
Update a supplier
PATCH/api/v1/inventory/suppliers/{supplier_id}
Chave de escritaResponde 200 · application/json
Changes a supplier's contact details, lead time, review period or payment terms.
Records the quantities that arrived at the destination warehouse.
Estoque, compras e fornecedores
List warehouses
GET/api/v1/inventory/warehouses
Chave de leituraResponde 200 · application/json
The tenant's warehouses.
Estoque, compras e fornecedores
Create a warehouse
POST/api/v1/inventory/warehouses
Chave de escritaResponde 201 · application/json
Adds a warehouse, optionally as the default.
Estoque, compras e fornecedores
Delete a transfer lane
DEL/api/v1/inventory/warehouses/lanes
Chave de escritaResponde 204 · application/json
Names travel as query params, not path segments: a warehouse name may contain a slash and would break path matching once encoded.
Estoque, compras e fornecedores
List transfer lanes
GET/api/v1/inventory/warehouses/lanes
Chave de leituraResponde 200 · application/json
Configured lanes only. A pair with no row falls back to the documented default (lead_time_days=1, cost_per_unit=0, fixed_cost=0) everywhere it is consumed — see backend/inventory/transfer_lane_service.py.
Estoque, compras e fornecedores
Set a transfer lane
PUT/api/v1/inventory/warehouses/lanes
Chave de escritaResponde 200 · application/json
Creates or updates the lead time and costs of moving stock between two warehouses.
Estoque, compras e fornecedores
Update a warehouse
PATCH/api/v1/inventory/warehouses/{name}
Chave de escritaResponde 200 · application/json
Set or clear the manual demand share for one warehouse (feature 5.4).
Every SKU that carried an ordering signal (PEDIR_YA/PEDIR_PRONTO) in the window: whether a purchase order followed, and — only where it did not and stock was later observed at or below zero — the estimated unserved units and their value. See `recommendation_reports.cost_of_ignoring` for the conservatism rules (no PO + no observed stockout => no loss claimed; no sale price => units reported, value null).
The SKU's latest recorded recommendation against the previous recorded one, decomposed into avg daily demand, lead time, stock on hand and safety stock — each tagged with whether it came from a new training session (a model opinion) or the tenant's own operational data. Returns `available: false` with a `reason` when there is not yet a previous row to compare against.
Estornos de pedidos
Undo a purchase-order reception
POST/api/v1/inventory/po/{po_log_id}/unreceive
Chave de escritaResponde 200 · application/json
Undo a reception: take the received units back out of stock, reset the PO line's `received_qty` and the order's `reception_status`, and remove the lead-time observation(s) that reception taught the supplier scorecard. Refuses (409, with the offending SKU/warehouse named) rather than go negative if some of the received units are no longer in stock. See `reception_service.unreceive_po` for the full reasoning.
Estornos de pedidos
Undo marking a purchase order as sent
POST/api/v1/inventory/po/{po_log_id}/unsend
Chave de escritaResponde 200 · application/json
Undo `mark_po_sent`: clear `sent_at` so the order stops counting as incoming stock and drops off the cash-payables calendar. Does NOT recall the email/WhatsApp message a prior `/send` may have delivered — that left the system and nothing can pull it back. Refuses once a reception exists against this PO (undo that first). See `reception_service.unsend_po`.
inventory-sync
Draft Doctor
POST/api/v1/inventory-sync/doctor
Chave de escritaResponde 200 · application/json
The connection doctor for an unsaved configuration.
inventory-sync
Dry Run Unsaved
POST/api/v1/inventory-sync/dry-run
Chave de escritaResponde 200 · application/json
Preview a configuration that is not saved yet. Writes nothing.
inventory-sync
List Presets
GET/api/v1/inventory-sync/presets
Chave de escritaResponde 200 · application/json
ERP recipe presets (SAP, Oracle EBS, Dynamics, Business Central, JD Edwards, Infor M3, Odoo, Magento, WooCommerce, generic SCD2 / UNION ledgers): parameters, stock model, the gotchas each one guards against, and whether it was verified against a live system. Also the systems read another way (push, or a warehouse through an existing engine).
The profile body a preset produces for one engine and its parameters (client, company, organisations...). Nothing is saved: the body goes through the wizard's dry run like any other.
inventory-sync
Create Profile
POST/api/v1/inventory-sync/profiles
Chave de escritaResponde 201 · application/json
Create a profile (off until previewed and enabled). Send `Idempotency-Key` to make a retried POST create it once.
inventory-sync
Apply Document
POST/api/v1/inventory-sync/profiles/apply
Chave de escritaResponde 200 · application/json
Apply a profile document (JSON or YAML): created, or updated by its `slug` — idempotent, so CI can re-apply the file on every deploy and the second time answers `action: unchanged`. Errors name the exact path (`mapping.current_stock.cast: 'int' is not one of ...`). `dry_run=true` validates and previews without saving.
inventory-sync
Validate Document
POST/api/v1/inventory-sync/profiles/validate
Chave de escritaResponde 200 · application/json
Validate a profile document without touching anything: every problem with its path.
inventory-sync
Delete Profile
DEL/api/v1/inventory-sync/profiles/{profile_id}
Chave de escritaResponde 200 · application/json
Delete a profile with its run log. The stock it synced stays as it is.
inventory-sync
Update Profile
PATCH/api/v1/inventory-sync/profiles/{profile_id}
Chave de escritaResponde 200 · application/json
Change a profile. Changing what it writes turns it off until previewed again (`disabled_by_edit: true`).
The connection doctor for a saved profile: source, connection (dns, tcp, tls, auth, privileges, select, tables), object, columns, sample read, row estimate, index on the incremental column (with the CREATE INDEX to run), supported change capture. `first_failure` names the stage and code; `diagnostic` is a secret-free bundle to paste to a DBA.
'Sync now'. Answers at once with the run row (status `running`); poll `GET .../runs/{run_id}` for the outcome. `override_brake` runs once past the safety brake (audited). With `Idempotency-Key`, a retry does not start a second run.
inventory-sync
Recipes
GET/api/v1/inventory-sync/recipes
Chave de escritaResponde 200 · application/json
Copy-paste material: least-privilege read-only GRANTs per engine (or for one data source), StockAI's egress IPs, example queries for common ERP schemas, a `stockai_inventory` view template and push forwarders.
inventory-sync
Refresh
POST/api/v1/inventory-sync/refresh
Chave de escritaResponde 200 · application/json
'Refresh now': make the displayed stock current. Coalesces (a refresh that finds a run in flight joins it), honours a per-profile cooldown (`status: cooldown`, `retry_after_s`), refreshes only `skus` when given, and waits at most `wait_seconds` before answering `status: running` with the `data_as_of` of the last success — the stock shown is never blanked. Paused or blocked profiles answer with their reason instead of running.
The CREATE VIEW stockai_inventory statement (or MongoDB view pipeline) for this source and mapping: hand it to the DBA, then map the view at confidence 1.0. StockAI never runs it.
inventory-sync
Transform Test
POST/api/v1/inventory-sync/transform-test
Chave de escritaResponde 200 · application/json
Try a field's transforms on one sample value: the output, or the rejection code a run would report.
inventory-sync-status
Get Fields
GET/api/v1/inventory-sync/fields
Chave de leituraResponde 200 · application/json
The canonical fields, transforms, policies and limits the editor offers.
inventory-sync-status
Get Freshness
GET/api/v1/inventory-sync/freshness
Chave de leituraResponde 200 · application/json
How current the stock is: `state` is `fresh`, `stale` (a profile has not succeeded within its expected window), `blocked` (a profile is paused or blocked and needs someone) or `none` (no sync). `data_as_of` is the oldest last success among live profiles: the stock is at least that fresh. Each profile lists its own state and the reason code when not fresh.
inventory-sync-status
Tenant Health
GET/api/v1/inventory-sync/health
Chave de leituraResponde 200 · application/json
Every profile's health in one call; `status` is the worst of them.
inventory-sync-status
Overview
GET/api/v1/inventory-sync/overview
Chave de leituraResponde 200 · application/json
The sync screen's one answer: is the stock current, and what is waiting for a person. `state` is none / waiting / fresh / attention / blocked; `attention` lists what only a person can settle (a stock file held for a decision, a sync the safety brake paused, a source that refuses us, a sync that is late, rows a run refused), worst first, each with the ids the action needs; `sources` is every database, file-drop and push source with its freshness and last run. Unlike `/health` it never answers 503: it is for reading, not for an uptime checker.
inventory-sync-status
Get Ownership
GET/api/v1/inventory-sync/ownership
Chave de leituraResponde 200 · application/json
Which stock fields of which (sku, warehouse) a live sync will overwrite at its next run, and which sync: the editors warn before a person saves a value the source will replace (the source wins; the replacement is counted and audit-logged). `items[].fields` are the fields the owning profile writes; `profiles[]` carries its name and `next_sync_at` (null for a push sync or an on-demand one: nobody can tell when it will write).
inventory-sync-status
List Profiles
GET/api/v1/inventory-sync/profiles
Chave de leituraResponde 200 · application/json
Every inventory sync profile with its status: enabled, last success and its age, `stale` (no success within twice the interval), `braked` (the safety brake stopped the last run), the last error code and the fields the source owns.
inventory-sync-status
Get Profile
GET/api/v1/inventory-sync/profiles/{profile_id}
Chave de leituraResponde 200 · application/json
One inventory sync profile with the same status fields as the list.
Machine-readable health for monitoring: `status` ok / stale / degraded / paused / blocked, `http_status` 200 or 503, the reason code with its category and whether it retries on its own, the last-success age and the next run. `strict=true` answers with that HTTP status itself (a 503 for an uptime checker), the same body either way.
The run log of a profile, newest first: rows read, created, updated, unchanged and rejected, the outcome (success / failed / braked), the error code and the watermark each run started from and reached.
The run's rejected rows as CSV (row, sku, code, params): bounded to the sample the run kept.
inventory-sync-status
Profile Schema
GET/api/v1/inventory-sync/schema/profile.json
Chave de leituraResponde 200 · application/json
The JSON Schema (draft 2020-12) of a profile document, `stockai.inventory-sync/v1`. The importer validates against the same spec.
MCP (clientes de IA)
Call the MCP server (JSON-RPC)
POST/api/v1/mcp
Chave de leituraResponde 200 · application/json
Model Context Protocol endpoint, for an AI client the customer runs.
Planejamento
Planning context
GET/api/v1/planning
Chave de leituraResponde 200 · application/json
The active planning period and `active_session_id` — the session the app's own screens show.
purchase-orders-erp
Export Feed
GET/api/v1/purchase-orders/export
Chave de leituraResponde 200 · application/json
Approved orders changed after `since`, oldest change first, with a cursor to resume from. A cancelled order comes back with `state = "cancelled"`. An order still waiting for approval is not here until it is approved.
purchase-orders-erp
Export File
GET/api/v1/purchase-orders/export/file
Chave de leituraResponde 200 · application/json
The chosen orders as the file the ERP imports. One document per supplier.
purchase-orders-erp
Export Formats
GET/api/v1/purchase-orders/export/formats
Chave de leituraResponde 200 · application/json
The ERP file layouts, and which of them have been run against a real system.
purchase-orders-erp
Unacknowledged
GET/api/v1/purchase-orders/unacknowledged
Chave de leituraResponde 200 · application/json
Open approved orders whose ERP document number nobody has written back.
Run a saved scenario and return the BASE vs SCENARIO comparison.
Retreinamento programado
List retraining schedules
GET/api/v1/schedules
Chave de leituraResponde 200 · application/json
Every schedule this tenant has, with the session's name.
Retreinamento programado
List scheduler history
GET/api/v1/schedules/history
Chave de leituraResponde 200 · application/json
What the scheduler has actually done, newest first.
Retreinamento programado
Delete a retraining schedule
DEL/api/v1/sessions/{session_id}/schedule
Chave de escritaResponde 200 · application/json
Stops the session's scheduled retraining.
Retreinamento programado
Get a retraining schedule
GET/api/v1/sessions/{session_id}/schedule
Chave de leituraResponde 200 · application/json
The session's cron schedule for automatic retraining.
Retreinamento programado
Save a retraining schedule
POST/api/v1/sessions/{session_id}/schedule
Chave de escritaResponde 200 · application/json
Sets a cron expression for automatic retraining, and whether it is enabled.
Execuções
List sessions
GET/api/v1/sessions
Chave de leituraResponde 200 · application/json
Forecast sessions with their state. Paginated with skip and limit.
Execuções
Create a session
POST/api/v1/sessions
Chave de escritaResponde 201 · application/json
Creates a forecast session in DRAFT.
Execuções
List session summaries
GET/api/v1/sessions/summary
Chave de leituraResponde 200 · application/json
The sessions library: every session of the tenant, enriched (dataset name, horizon, SKU count, granularity, headline accuracy, models), searchable, filterable, sortable and paginated. `total` counts the rows matching the filters, so a pager can be drawn.
Execuções
Delete a session
DEL/api/v1/sessions/{session_id}
Chave de escritaResponde 204 · application/json
Deletes the session and its results.
Execuções
Get a session
GET/api/v1/sessions/{session_id}
Chave de leituraResponde 200 · application/json
One session's metadata and state.
Execuções
Update a session
PATCH/api/v1/sessions/{session_id}
Chave de escritaResponde 200 · application/json
Changes a session's name, description or tags.
Execuções
Get Manifest
GET/api/v1/sessions/{session_id}/manifest
Chave de leituraResponde 200 · application/json
How this forecast was produced: who or what started the run, the dataset's content hash and size, the full configuration, engine and library versions, per-model outcomes, stage timings and a hash of the forecast. Written once when the run ends and never changed. 404 `manifest_not_available` for a session that has not finished a run since manifests were introduced.
Execuções
Restore Session
POST/api/v1/sessions/{session_id}/restore
Chave de escritaResponde 200 · application/json
Bring an archived session back into the working list. Counts against the plan's saved-forecast ceiling like a new one: at the ceiling it is refused with the same message, and the session stays archived and intact.
Execuções
Get Run Durations
GET/api/v1/training/run-durations
Chave de leituraResponde 200 · application/json
Median and p95 training duration over the tenant's last `limit` runs, by catalogue-size bucket and by granularity, read from the lineage manifests (no new storage). For choosing a retrain cadence from evidence.
Fuso horário
Read the time zone
GET/api/v1/tenant/timezone
Chave de leituraResponde 200 · application/json
Readable by every role: any screen showing a scheduled time needs it.
Treinamento
List active jobs
GET/api/v1/jobs/active
Chave de leituraResponde 200 · application/json
Training runs of this tenant that are queued or running right now.
Treinamento
Cancel a job
DEL/api/v1/jobs/{job_id}
Chave de escritaResponde 200 · application/json
Cancels a queued or running training job.
Treinamento
Get a job
GET/api/v1/jobs/{job_id}
Chave de leituraResponde 200 · application/json
A training job's state and progress.
Treinamento
Job logs
GET/api/v1/jobs/{job_id}/logs
Chave de leituraResponde 200 · application/json
The last `tail` log lines of a training job.
Treinamento
List a session's jobs
GET/api/v1/sessions/{session_id}/jobs
Chave de leituraResponde 200 · application/json
Training jobs run for the session.
Treinamento
Start Reforecast
POST/api/v1/sessions/{session_id}/reforecast
Chave de escritaResponde 202 · application/json
Create a NEW session that forecasts from this session's stored models over newer sales, without retraining. The source session is never modified. Counts against the plan's saved-forecast ceiling; runs on the job queue.
Whether a re-forecast with newer sales is on offer for this session: stored models present, newer data than the forecast used, and the refit age of the models. `reason` is a stable code when it is not.
Treinamento
Start training
POST/api/v1/sessions/{session_id}/train
Chave de escritaResponde 202 · application/json
Queues a training run for a configured session. Poll /sessions/{session_id}/train/status.
Treinamento
Read training status
GET/api/v1/sessions/{session_id}/train/status
Chave de leituraResponde 200 · application/json
Returns the latest job status for this session. Alias used by the Frontend — maps to GET /jobs/{job_id} for the most recent job.
Webhooks
List webhooks
GET/api/v1/webhooks
Chave de leituraResponde 200 · application/json
Outgoing webhooks and the events they subscribe to.
Webhooks
Create a webhook
POST/api/v1/webhooks
Chave de escritaResponde 200 · application/json
Subscribes an https URL to business events (purchase orders, stockouts, commitments, jobs). The signing secret is returned once.
Webhooks
List webhook events
GET/api/v1/webhooks/events
Chave de leituraResponde 200 · application/json
The events a webhook can subscribe to and the data keys each carries.
Webhooks
Delete a webhook
DEL/api/v1/webhooks/{webhook_id}
Chave de escritaResponde 200 · application/json
Removes the webhook and its delivery log.
Webhooks
List webhook deliveries
GET/api/v1/webhooks/{webhook_id}/deliveries
Chave de leituraResponde 200 · application/json
The delivery log: status, attempts, last status code, last error and next retry.
Webhooks
Re-enable a webhook
POST/api/v1/webhooks/{webhook_id}/enable
Chave de escritaResponde 200 · application/json
Switches a webhook back on after it was disabled for repeated failures.
Webhooks
Rotate a webhook secret
POST/api/v1/webhooks/{webhook_id}/rotate-secret
Chave de escritaResponde 200 · application/json
Issues a new signing secret, returned once. The old one stops verifying at once.
Webhooks
Send a test event
POST/api/v1/webhooks/{webhook_id}/test
Chave de escritaResponde 200 · application/json
Queues a signed webhook.test delivery to the webhook.
Requisição
curl-X POST "$STOCKAI/ai/narrative/forecast-explanation"\-H"Authorization: Bearer $STOCKAI_KEY"\-H"Content-Type: application/json"\-d'{"sku":"SKU-001","session_id":"<session_id>","profile":"distributor","language":"es"}'