Flowent API Gateway Documentation
Overview
The Flowent API Gateway enables external developers to register and manage custom actions that can be used within Flowent’s conversational flows. This allows for extensible, tenant-specific functionality while maintaining security and reliability.Architecture
The API Gateway provides:- Action Registration: Register external webhook-based actions
- Authentication: JWT-based authentication with API tokens
- Security: HMAC signature validation for webhooks
- Management: Admin panel for managing API tokens and HMAC keys
Getting Started
1. Prerequisites
- Flowent instance with API Gateway enabled
- A server to host your action endpoints
- Admin access to the Flowent admin panel
2. Set Up Your Action Server
Your action server must:- Accept POST requests with JSON payloads
- Validate HMAC signatures for security
- Return responses in the expected format
- Handle the test validation request during registration
3. Create API Credentials
- Log into the Flowent admin panel
- Navigate to Gateway Management
- Create an API token for authentication
- Create an HMAC key for webhook signature validation
4. Register Your Actions
Use the API Gateway endpoints to register your actions with their JSON schemas and webhook URLs.Authentication
API Token Exchange
Before making any API calls, you need to exchange your API token for a JWT token:Using JWT Tokens
Include the JWT token in the Authorization header for all subsequent requests:Action Management
Register an Action
List Actions
Get Specific Action
Update Action
Delete Action
Webhook Implementation
Request Format
When Flowent executes your action, it sends a POST request to your webhook URL:signature field contains the HMAC-SHA256 signature calculated on the payload WITHOUT the signature field itself. When validating, you must exclude the signature field from your HMAC calculation.
Response Format
Your webhook must return a JSON response:result: String description of the action resulterror: Error message if the action failed (empty string if successful)
Signature Validation
Validate the HMAC signature to ensure request authenticity. CRITICAL: The signature is calculated on the payload WITHOUT the signature field itself.- The signature is calculated BEFORE the signature field is added to the request
- You must reconstruct the original payload by excluding the signature field
- The JSON serialization format must match exactly (use
separators=(',', ':')in Python) - Always use constant-time comparison (
hmac.compare_digestorhmac.Equal) to prevent timing attacks
Test Validation
During action registration, Flowent sends a test request to validate your endpoint:Security Considerations
- Always validate HMAC signatures before processing requests
- Use HTTPS for all webhook URLs
- Implement proper error handling and logging
- Rate limit your endpoints to prevent abuse
- Validate input parameters against your expected schema
- Store HMAC keys securely and never expose them in logs or error messages
Error Handling
Common Error Responses
Invalid Token (401)Best Practices
- Use descriptive action names (lowercase, underscores, no spaces)
- Provide clear descriptions for your actions and parameters
- Define comprehensive JSON schemas with proper types and descriptions
- Implement proper timeout handling (Flowent times out after 30 seconds)
- Log all requests and responses for debugging
- Version your webhook URLs to support updates
- Test your actions thoroughly before deploying to production
Limits and Quotas
- Maximum 100 actions per tenant
- Maximum 30-second timeout for webhook calls
- Maximum 1MB payload size
- API token valid for 24 hours
- Rate limit: 1000 requests per hour per tenant
Troubleshooting
Action Registration Fails
- Verify your webhook URL is accessible
- Check that your endpoint returns 2xx for test requests
- Ensure your JSON schema is valid
- Verify your JWT token is not expired
Webhook Not Receiving Calls
- Check action is properly registered
- Verify webhook URL is correct and accessible
- Ensure your server accepts POST requests
- Check server logs for incoming requests
Signature Validation Fails
- Most Common Issue: Verify you’re calculating the HMAC on the payload WITHOUT the signature field
- The signature field should NOT be included in the HMAC calculation
- Create a copy of the request data excluding the signature field before calculating HMAC
- Verify you’re using the correct HMAC key from the admin panel
- Ensure your JSON serialization matches Flowent’s format (
separators=(',', ':')in Python) - Check for any request body modifications by middleware or reverse proxies
- Use logging to compare your calculated signature with the received signature
- Ensure you’re using constant-time comparison functions (
hmac.compare_digestorhmac.Equal)