Axuz Developers

POST /teams/{teamId}/flowcharts/{id}/ai/

Chat com aplicação de patch (Fase 4).

  • Access: Team member
  • Service: https://api-flow.axuz.net

Accepted authentication

  • sessionCookie — Sessão plena Axuz (cookie de sessão da casa). Sessão restrita é 403 enrollment_required.
  • bearerSession — JWT de acesso da sessão em `Authorization: Bearer`.

503 quando OPENAI_API_KEY não está setado.

Parameters

NameInTypeRequiredDescription
teamIdpathstringyes
idpathstringyes

Request body

application/json · Required

NameTypeRequiredDescription
promptstringyes
documentFlowDocumentyes

Shape enxuta espelhando lib/types.ts:FlowDocument no client. Backend não valida a shape interna (opaco pro storage); os campos abaixo são o mínimo comum consumido pelo editor.

document.nodesarray<FlowNode>yes
document.nodes[].idstringyes
document.nodes[].typestringyes
document.nodes[].positionFlowXYyes
document.nodes[].position.xnumberyes
document.nodes[].position.ynumberyes
document.nodes[].widthinteger | nullno
document.nodes[].heightinteger | nullno
document.nodes[].parentNodestringno
document.nodes[].extentstringno
document.nodes[].dataobjectyes
document.nodes[].styleobjectno
document.edgesarray<FlowEdge>yes
document.edges[].idstringyes
document.edges[].sourcestringyes
document.edges[].targetstringyes
document.edges[].typestringno
document.edges[].dataobjectno
{
  "prompt": "string",
  "document": {
    "nodes": [
      {
        "id": "string",
        "type": "string",
        "position": {},
        "width": 1,
        "height": 1,
        "parentNode": "string",
        "extent": "string",
        "data": {},
        "style": {}
      }
    ],
    "edges": [
      {
        "id": "string",
        "source": "string",
        "target": "string",
        "type": "string",
        "data": {}
      }
    ]
  }
}

Responses

200

Patch + FlowDocument atualizado.

NameTypeRequiredDescription
patcharray<FlowAIPatchOp>yes
patch[].opstringyes

enum: "add", "remove", "replace", "move"

patch[].pathstringyes
patch[].valueanyno
documentFlowDocumentyes

Shape enxuta espelhando lib/types.ts:FlowDocument no client. Backend não valida a shape interna (opaco pro storage); os campos abaixo são o mínimo comum consumido pelo editor.

document.nodesarray<FlowNode>yes
document.nodes[].idstringyes
document.nodes[].typestringyes
document.nodes[].positionFlowXYyes
document.nodes[].position.xnumberyes
document.nodes[].position.ynumberyes
document.nodes[].widthinteger | nullno
document.nodes[].heightinteger | nullno
document.nodes[].parentNodestringno
document.nodes[].extentstringno
document.nodes[].dataobjectyes
document.nodes[].styleobjectno
document.edgesarray<FlowEdge>yes
document.edges[].idstringyes
document.edges[].sourcestringyes
document.edges[].targetstringyes
document.edges[].typestringno
document.edges[].dataobjectno
versionobjectno

Presente quando o patch foi commitado como versão nova.

version.idstring<uuid>yes
version.flowchart_idstring<uuid>yes
version.versionintegeryes
version.created_bystring<uuid>yes
version.created_atstring<date-time>yes
version.sourcestringyes

enum: "autosave", "manual", "ai", "branch", "shared_interact"

version.reasonstring | nullno
version.parent_version_idstring<uuid> | nullno
messagestringyes

400

prompt/document ausente ou inválido (inclui patch inválido devolvido pela LLM).

NameTypeRequiredDescription
errorstringyes

401

JWT ausente/expirado.

NameTypeRequiredDescription
errorstringyes

403

Sem permissao (nao e owner/admin; token sem escopo; token de integracao em rota nao permitida)

NameTypeRequiredDescription
errorstringyes

404

Recurso não encontrado ou fora de escopo.

NameTypeRequiredDescription
errorstringyes

429

Rate limit per-user ou per-team.

NameTypeRequiredDescription
errorstringyes

500

Erro interno. Tente de novo com backoff; reporte o X-Request-Id.

NameTypeRequiredDescription
errorstringyes

502

Erro OpenAI upstream.

NameTypeRequiredDescription
errorstringyes

503

AI não configurado.

NameTypeRequiredDescription
errorstringyes

Examples

"Try it" is turned off in this reference. Use the examples with your test credential.

curl

curl -sS -X POST 'https://api-flow.axuz.net/teams/TEAM_ID/flowcharts/ID/ai/' \
  -H "Authorization: Bearer $AXUZ_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"string","document":{"nodes":[{"id":"string","type":"string","position":{},"width":1,"height":1,"parentNode":"string","extent":"string","data":{},"style":{}}],"edges":[{"id":"string","source":"string","target":"string","type":"string","data":{}}]}}'

Node.js

const res = await fetch("https://api-flow.axuz.net/teams/TEAM_ID/flowcharts/ID/ai/", {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "prompt": "string",
    "document": {
      "nodes": [
        {
          "id": "string",
          "type": "string",
          "position": {},
          "width": 1,
          "height": 1,
          "parentNode": "string",
          "extent": "string",
          "data": {},
          "style": {}
        }
      ],
      "edges": [
        {
          "id": "string",
          "source": "string",
          "target": "string",
          "type": "string",
          "data": {}
        }
      ]
    }
  }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());

Python

import os
import requests

res = requests.request(
    "POST",
    "https://api-flow.axuz.net/teams/TEAM_ID/flowcharts/ID/ai/",
    headers={
        "Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
    },
    json={
        "prompt": "string",
        "document": {
            "nodes": [
                {
                    "id": "string",
                    "type": "string",
                    "position": {},
                    "width": 1,
                    "height": 1,
                    "parentNode": "string",
                    "extent": "string",
                    "data": {},
                    "style": {},
                },
            ],
            "edges": [
                {
                    "id": "string",
                    "source": "string",
                    "target": "string",
                    "type": "string",
                    "data": {},
                },
            ],
        },
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())