The REST Chat API is the synchronous interface to the ERP Financial Agent pipeline. EachDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/yohangr3/agentelanggrafh/llms.txt
Use this file to discover all available pages before exploring further.
POST /chat request runs the full LangGraph pipeline — schema linking, SQL generation, execution, and analysis — and returns a complete structured response. For streaming progress events while the pipeline runs, use the WebSocket API instead.
Authentication
All/chat requests require an Authorization header containing a Bearer JWT token issued by AWS Cognito. The backend validates the token’s signature against your Cognito User Pool’s JWKS endpoint, checks the issuer, and (when configured) validates the audience against COGNITO_CLIENT_ID.
The authenticated user’s identity is derived from the JWT
sub claim. The cognito:groups, custom:tenantId, and custom:data_scope claims drive RBAC and multi-tenant data isolation — ensure your Cognito User Pool attributes are configured accordingly.Rate Limiting
Rate limiting is enforced per authenticated user (keyed onuser_id from the JWT). Unauthenticated requests fall back to IP-based limiting.
| Window | Limit |
|---|---|
| Per minute | 20 requests |
| Per hour | 200 requests |
429 Too Many Requests. The Retry-After header indicates when the window resets.
POST /chat
Process a natural language question through the full agent pipeline and return a structured response with narrative text, generated SQL, optional visualisation config, KPIs, and download links.Request
Bearer JWT token from AWS Cognito.Example:
Bearer eyJraWQ...Optional trace ID propagated through logs and LangSmith. A UUID is generated automatically if omitted.
Natural language question in any language supported by your LLM. Must be between 1 and 2 000 characters.Example:
"¿Cuánto vendimos por región en el primer trimestre?"Session identifier for multi-turn conversation history. Must match the pattern
^[a-zA-Z0-9_-]{1,128}$.Omit (or pass null) to let the server generate a new UUID session. The assigned session ID is always returned in the response so you can pass it back on the next turn.Human-in-the-loop confirmation flag. Defaults to
false.When the pipeline detects an expensive or ambiguous query it returns confirmation_required: true instead of executing. Resend the identical request body with confirmed: true to proceed.Response
Narrative answer in plain text or Markdown. Always present.
Session ID for this conversation. Echo this value in subsequent requests to maintain context.
true when the pipeline has triggered the Human-in-the-Loop gate. When this is true, the other data fields are empty — resend with confirmed: true to execute.The SQL query that was generated and executed against the ERP database.
null for conversational turns that did not require a query.Number of rows returned by the SQL query.
null when no query was executed.Classified top-level intent of the user’s message (e.g.
ventas, costos, general).Sub-intent that controls which result components are populated. One of:
query— data table onlychart— chart + tableanalysis— full experience: KPIs + chart + table + exports
Markdown-formatted executive summary of the analysis. Present when
analysis_intent is analysis.Human-readable explanation of why confirmation is required (e.g. “This query will scan 5 million rows. Do you want to proceed?”). Only present when
confirmation_required is true.Error Responses
| Status | Code | Description |
|---|---|---|
401 Unauthorized | — | Missing, expired, or invalid JWT token. |
422 Unprocessable Entity | — | Request body failed Pydantic validation (e.g. message too long, invalid session_id format). |
429 Too Many Requests | — | Rate limit exceeded. Check the Retry-After header. |
500 Internal Server Error | — | Unhandled error in the agent pipeline. The detail field contains context. |
503 Service Unavailable | — | LangGraph pipeline is still initialising at startup. Retry after a few seconds. |
HITL Confirmation Flow
Some queries trigger a Human-in-the-Loop gate before execution — for example, queries that scan large tables or perform destructive-looking aggregations. The flow is:Receive a confirmation prompt
The response has
confirmation_required: true and a confirmation_message explaining what the agent wants to do. No SQL has been executed yet.Code Examples
POST /api/upload
Upload an Excel (.xlsx, .xls) or CSV file for ad-hoc analysis. The endpoint validates the file, parses it with pandas, and stores the result in Redis keyed by a generated file_id. Pass the returned file_id in a subsequent WebSocket chat message (via the file_id field) to route that turn through the analyze_file pipeline node.
Requires the file.upload permission (granted to finance_lead and above by default).
Request
multipart/form-data with the following fields:
The Excel or CSV file to upload. Accepted extensions:
.xlsx, .xls, .csv. Maximum size is controlled by the MAX_UPLOAD_SIZE_MB environment variable.Active session ID to associate the file with. When omitted, a new UUID session is created. The resolved session ID is always returned in the response.
Response — FileUploadResponse
UUID identifying this upload in Redis. Pass this value as
file_id in the next WebSocket chat message.Session the file was associated with (either the provided value or a newly generated UUID).
Original filename as received from the client.
List of column metadata objects parsed from the file.
Number of data rows in the uploaded file (excluding the header row).
First 5 rows of the file as an array of objects, useful for previewing content in the UI before querying.
Size of the uploaded file in bytes.
Error Responses
| Status | Condition |
|---|---|
400 Bad Request | Unsupported file extension or parse failure. |
401 Unauthorized | Missing or invalid JWT. |
403 Forbidden | Caller lacks the file.upload permission. |
413 Request Entity Too Large | File exceeds the configured MAX_UPLOAD_SIZE_MB limit. |
429 Too Many Requests | Rate limit exceeded (10 req / minute). |
Example
cURL
Response
GET /health
Returns service health status. No authentication required. Suitable for load balancer health checks and uptime monitors.Response
"healthy" when the database is reachable, "degraded" otherwise."connected" or "disconnected" based on a live connectivity check against the MySQL RDS instance.The current deployment environment (e.g.
"production", "staging", "development").true when LangSmith tracing is active. Reflects both LANGSMITH_API_KEY being set and LANGCHAIN_TRACING_V2=true.true when Prometheus metrics collection is enabled.