Fluxos: criar, alterar, apagar
Cria um fluxo em rascunho, substitui o desenho de um fluxo e apaga um fluxo.
Estas rotas exigem manage_ops_flows. Um fluxo novo nasce em rascunho e não executa nada até ser ativado (Ativar, pausar e testar). Criar e alterar não validam o desenho: um desenho incompleto é aceito e só é recusado ao ativar.
Criar
/api/v1/admin/ops-flowsAdminCriar um fluxo
Corpo da requisição
namestringobrigatórioNome do fluxo. Obrigatório.
trigger_typestringobrigatórioorder.createdorder.statusChangedorder.paymentStatusChangedorder.chargebackproduct.stockChangedproduct.pending_moderationreturn.statusChangeduser.registeredO evento que dispara o fluxo.
trigger_configobjectpadrão: {}Configuração do gatilho. Hoje não é lida: use
{}.graphobjectO desenho do fluxo.
nodesarrayEtapas.
idstringobrigatórioIdentificador da etapa, único no fluxo.
typestringobrigatóriotriggerconditionactionexitTipo da etapa.
configobjectConfiguração.
trigger: {}. condition: field, op, value/str. action: kind e params. exit: {}.positionobjectPosição no editor visual:
x e y. Só serve para desenhar.edgesarrayLigações entre etapas.
idstringobrigatórioIdentificador da ligação.
fromstringobrigatórioId da etapa de origem.
tostringobrigatórioId da etapa de destino.
branchstring|nullyes ou no quando a origem é uma condição; null nas demais.Exemplo de requisição (criar)
bash
curl -X POST "$BASE_URL/api/v1/admin/ops-flows" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Avisar pedido grande", "trigger_type": "order.created", "trigger_config": {}, "graph": {"nodes": [{"id": "n_trigger", "type": "trigger", "config": {}, "position": {"x": 240, "y": 40}}, {"id": "n_cond", "type": "condition", "config": {"field": "order.total", "op": "gte", "value": 100000}, "position": {"x": 240, "y": 180}}, {"id": "n_action", "type": "action", "config": {"kind": "notify_inbox", "params": {"title": "Pedido grande", "body": "Pedido acima de R$ 1.000"}}, "position": {"x": 120, "y": 320}}, {"id": "n_exit", "type": "exit", "config": {}, "position": {"x": 240, "y": 440}}], "edges": [{"id": "e1", "from": "n_trigger", "to": "n_cond", "branch": null}, {"id": "e2", "from": "n_cond", "to": "n_action", "branch": "yes"}, {"id": "e3", "from": "n_cond", "to": "n_exit", "branch": "no"}, {"id": "e4", "from": "n_action", "to": "n_exit", "branch": null}]}}'Resposta (criar)
201Fluxo criado em rascunho
json
{
"id": "7f89112b-4bef-46fb-ac55-4e66baf978c4",
"name": "Avisar pedido grande",
"status": "draft",
"trigger_type": "order.created",
"trigger_config": {},
"graph": {
"nodes": [
{ "id": "n_trigger", "type": "trigger", "config": {}, "position": { "x": 240, "y": 40 } },
{ "id": "n_cond", "type": "condition", "config": { "field": "order.total", "op": "gte", "value": 100000 }, "position": { "x": 240, "y": 180 } },
{ "id": "n_action", "type": "action", "config": { "kind": "notify_inbox", "params": { "title": "Pedido grande", "body": "Pedido acima de R$ 1.000" } }, "position": { "x": 120, "y": 320 } },
{ "id": "n_exit", "type": "exit", "config": {}, "position": { "x": 240, "y": 440 } }
],
"edges": [
{ "id": "e1", "from": "n_trigger", "to": "n_cond", "branch": null },
{ "id": "e2", "from": "n_cond", "to": "n_action", "branch": "yes" },
{ "id": "e3", "from": "n_cond", "to": "n_exit", "branch": "no" },
{ "id": "e4", "from": "n_action", "to": "n_exit", "branch": null }
]
},
"runs_7d": 0,
"failed_7d": 0,
"created_at": "2026-10-11T21:19:34.256049Z",
"updated_at": "2026-10-11T21:19:34.256049Z"
}Campos da resposta
iduuidId do fluxo.
namestringNome.
statusstringdraftactivepauseddraft rascunho, active ligado, paused pausado.trigger_typestringGatilho.
trigger_configobjectConfiguração do gatilho.
graphobjectO desenho (
nodes e edges).vendor_iduuidSó em fluxos criados por um seller (lojista). Ausente nos fluxos da loja.
runs_7dintegerExecuções nos últimos 7 dias. Só vem calculado na listagem; na consulta e nas escritas é
0.failed_7dintegerExecuções com falha nos últimos 7 dias. Mesma regra.
created_atstringCriação, RFC 3339.
updated_atstringÚltima alteração, RFC 3339.
Erros (criar)
| Status | Quando | Corpo |
|---|---|---|
| 401 | Sem token, token inválido ou expirado. | {"error":"missing authorization header"} |
| 403 | O usuário não tem manage_ops_flows. | {"error":"insufficient privileges","privilege_required_any":["manage_ops_flows"]} |
| 400 | Corpo que não é JSON válido. | {"error":"invalid body","detail":"unexpected EOF"} |
| 422 | Falta name ou trigger_type, ou falha ao gravar. | {"error":"failed","detail":"name and trigger_type required"} |
Alterar
/api/v1/admin/ops-flows/{id}AdminSubstituir a definição de um fluxo
Parâmetros de caminho
iduuidobrigatórioId do fluxo (UUID).
Corpo da requisição
namestringobrigatórioNome do fluxo. Obrigatório.
trigger_typestringobrigatórioorder.createdorder.statusChangedorder.paymentStatusChangedorder.chargebackproduct.stockChangedproduct.pending_moderationreturn.statusChangeduser.registeredO evento que dispara o fluxo.
trigger_configobjectpadrão: {}Configuração do gatilho. Hoje não é lida: use
{}.graphobjectO desenho do fluxo.
nodesarrayEtapas.
idstringobrigatórioIdentificador da etapa, único no fluxo.
typestringobrigatóriotriggerconditionactionexitTipo da etapa.
configobjectConfiguração.
trigger: {}. condition: field, op, value/str. action: kind e params. exit: {}.positionobjectPosição no editor visual:
x e y. Só serve para desenhar.edgesarrayLigações entre etapas.
idstringobrigatórioIdentificador da ligação.
fromstringobrigatórioId da etapa de origem.
tostringobrigatórioId da etapa de destino.
branchstring|nullyes ou no quando a origem é uma condição; null nas demais.Exemplo de requisição (alterar)
bash
curl -X PUT "$BASE_URL/api/v1/admin/ops-flows/7f89112b-4bef-46fb-ac55-4e66baf978c4" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Avisar pedido grande (v2)", "trigger_type": "order.created", "trigger_config": {}, "graph": {"nodes": [{"id": "n_trigger", "type": "trigger", "config": {}, "position": {"x": 240, "y": 40}}, {"id": "n_cond", "type": "condition", "config": {"field": "order.total", "op": "gte", "value": 100000}, "position": {"x": 240, "y": 180}}, {"id": "n_action", "type": "action", "config": {"kind": "notify_inbox", "params": {"title": "Pedido grande", "body": "Pedido acima de R$ 1.000"}}, "position": {"x": 120, "y": 320}}, {"id": "n_exit", "type": "exit", "config": {}, "position": {"x": 240, "y": 440}}], "edges": [{"id": "e1", "from": "n_trigger", "to": "n_cond", "branch": null}, {"id": "e2", "from": "n_cond", "to": "n_action", "branch": "yes"}, {"id": "e3", "from": "n_cond", "to": "n_exit", "branch": "no"}, {"id": "e4", "from": "n_action", "to": "n_exit", "branch": null}]}}'Resposta (alterar)
200Fluxo alterado
json
{
"id": "7f89112b-4bef-46fb-ac55-4e66baf978c4",
"name": "Avisar pedido grande (v2)",
"status": "draft",
"trigger_type": "order.created",
"trigger_config": {},
"graph": {
"nodes": [
{ "id": "n_trigger", "type": "trigger", "config": {}, "position": { "x": 240, "y": 40 } },
{ "id": "n_cond", "type": "condition", "config": { "field": "order.total", "op": "gte", "value": 100000 }, "position": { "x": 240, "y": 180 } },
{ "id": "n_action", "type": "action", "config": { "kind": "notify_inbox", "params": { "title": "Pedido grande", "body": "Pedido acima de R$ 1.000" } }, "position": { "x": 120, "y": 320 } },
{ "id": "n_exit", "type": "exit", "config": {}, "position": { "x": 240, "y": 440 } }
],
"edges": [
{ "id": "e1", "from": "n_trigger", "to": "n_cond", "branch": null },
{ "id": "e2", "from": "n_cond", "to": "n_action", "branch": "yes" },
{ "id": "e3", "from": "n_cond", "to": "n_exit", "branch": "no" },
{ "id": "e4", "from": "n_action", "to": "n_exit", "branch": null }
]
},
"runs_7d": 0,
"failed_7d": 0,
"created_at": "2026-10-11T21:19:34.256049Z",
"updated_at": "2026-10-11T21:19:34.256049Z"
}Campos da resposta
(objeto)objectO fluxo depois da alteração. O PUT substitui nome, gatilho e desenho inteiros: reenvie tudo. O
status não muda.Erros (alterar)
| Status | Quando | Corpo |
|---|---|---|
| 401 | Sem token, token inválido ou expirado. | {"error":"missing authorization header"} |
| 403 | O usuário não tem manage_ops_flows. | {"error":"insufficient privileges","privilege_required_any":["manage_ops_flows"]} |
| 400 | Corpo que não é JSON válido. | {"error":"invalid body","detail":"unexpected EOF"} |
| 422 | Falha ao gravar. | {"error":"failed","detail":"..."} |
Apagar
/api/v1/admin/ops-flows/{id}AdminApagar um fluxo
Parâmetros de caminho
iduuidobrigatórioId do fluxo (UUID).
Exemplo de requisição (apagar)
bash
curl -X DELETE "$BASE_URL/api/v1/admin/ops-flows/7f89112b-4bef-46fb-ac55-4e66baf978c4" \
-H "Authorization: Bearer $TOKEN"Resposta (apagar)
200Fluxo apagado
json
{
"status": "deleted"
}Campos da resposta
statusstringSempre
deleted.Erros (apagar)
| Status | Quando | Corpo |
|---|---|---|
| 401 | Sem token, token inválido ou expirado. | {"error":"missing authorization header"} |
| 403 | O usuário não tem manage_ops_flows. | {"error":"insufficient privileges","privilege_required_any":["manage_ops_flows"]} |
| 500 | Falha ao consultar ou gravar. | {"error":"failed","detail":"..."} |