Overview
The Run Flow endpoint allows you to execute deployed flows by sending queries and receiving processed results. Each flow represents a complete RAG pipeline that can include document retrieval, LLM processing, and custom logic.- Method:
POST
- URL:
https://{flow_name}.flows.graphorlm.com
- Authentication: Required (API Token)
Authentication
All requests must include a valid API token in the Authorization header:Learn how to generate API tokens in the API Tokens guide.
Request Format
Headers
Header | Value | Required |
---|---|---|
Authorization | Bearer YOUR_API_TOKEN | Yes |
Content-Type | application/json | Yes |
Request Body
The request body should be a JSON object with the following optional fields:Field | Type | Required | Description |
---|---|---|---|
query | string | No | The query or question to process through the flow |
page | integer | No | Page number for paginated results (default: 1) |
page_size | integer | No | Number of items per page for results |
Example Request
Response Format
Success Response (200 OK)
The response contains processed results from your flow execution with pagination information:Response Fields
Field | Type | Description |
---|---|---|
items | array | Array of result documents with content and metadata |
total | integer | Total number of results found |
page | integer | Current page number |
page_size | integer | Number of items per page |
total_pages | integer | Total number of pages available |
Document Object Structure
Each item in theitems
array contains:
Field | Type | Description |
---|---|---|
page_content | string | The main content or answer from the document |
metadata | object | Additional information about the document |
source
: Source file or document namepage
: Page number in the original documentchunk_id
: Unique identifier for the text chunkrelevance_score
: Relevance score for the query (if available)
Code Examples
JavaScript/Node.js
Python
cURL
PHP
Error Responses
Common Error Codes
Status Code | Description | Example Response |
---|---|---|
400 | Bad Request - Invalid query parameters | {"detail": "Invalid request format"} |
401 | Unauthorized - Invalid or missing API token | {"detail": "Invalid authentication credentials"} |
404 | Not Found - Flow not found or not deployed | {"detail": "Flow not found"} |
500 | Internal Server Error - Flow execution failed | {"detail": "Error running flow: execution failed"} |
Error Response Format
Example Error Responses
Invalid API Token
Flow Not Found
Flow Not Deployed
Flow Execution Error
Flow Requirements
Before you can execute a flow, ensure:- Flow is Deployed: The flow must have a deployed revision
- Valid Configuration: All flow components must be properly configured
- Source Documents: Required documents must be uploaded and processed
- API Access: Your API token must have access to the project
Use the Deploy Flow endpoint to deploy your flow before execution.
Pagination
The Run Flow endpoint supports pagination for large result sets:Request Pagination Parameters
Response Pagination Information
Pagination Best Practices
- Use reasonable page sizes (10-50 items)
- Handle empty result sets gracefully
- Implement proper navigation between pages
- Cache results when appropriate
Integration Examples
Complete RAG Query System
Batch Query Processing
Best Practices
Query Optimization
- Be Specific: More specific queries yield better results
- Use Context: Include relevant context in your queries
- Test Different Phrasings: Try variations of your questions
Performance
- Use Pagination: Don’t request all results at once
- Cache Results: Cache responses for repeated queries
- Batch Processing: Use async/parallel processing for multiple queries
Error Handling
- Implement Retries: Add retry logic for transient failures
- Validate Responses: Check response structure before processing
- Log Errors: Keep detailed logs for debugging
Security
- Protect API Tokens: Never expose tokens in client-side code
- Use HTTPS: Always use secure connections
- Rate Limiting: Implement client-side rate limiting
Troubleshooting
Flow Not Found Error
Flow Not Found Error
Solution: Verify that:
- The flow name in the URL is correct
- The flow exists in your project
- Your API token has access to the correct project
No Deployed Revision Error
No Deployed Revision Error
Solution: Deploy your flow before execution:
- Use the Deploy Flow endpoint
- Ensure all flow components are properly configured
- Check that deployment completed successfully
Flow Execution Timeout
Flow Execution Timeout
Solution: For slow-performing flows:
- Optimize your flow configuration
- Reduce the complexity of queries
- Consider breaking complex flows into smaller components
- Contact support if timeouts persist
Empty Results
Empty Results
Solution: If no results are returned:
- Verify that documents are uploaded and processed
- Check query relevance to your document content
- Review flow configuration and component settings
- Try simpler or more general queries
Network Connection Issues
Network Connection Issues
Solution: For connectivity problems:
- Check your internet connection
- Verify the flow URL is accessible
- Ensure your firewall allows HTTPS traffic
- Try accessing the endpoint from a different network