Raya Voice AI best practices
Follow these best practices to get the most out of Raya Voice AI Agents API.
Call Management
Poll for Call Status
Check call status every 2 minutes until completion:
Handle Rate Limits
Implement exponential backoff for rate limit errors:
Batch Operations
Use Batches for Scale
For multiple calls, always use batch operations instead of individual calls:
Configure Appropriate Schedules
Set calling hours based on time zones and business hours:
Set Reasonable Concurrency
Don’t set concurrency too high:
- Start with 1-2 concurrent calls
- Gradually increase based on account limits
- Monitor for rate limit errors
Configure Retry Logic
Set appropriate retry settings:
- Max retries: 2-3 for most use cases
- Retry after hours: 3-24 hours depending on use case
- Selected statuses: Usually just
["Pending"]for new contacts
Agent Configuration
Voice, language, and tools (API)
When setting language_id or voice_id on create/update:
- Use Language Options and Voice Options for valid UUIDs. Your account may only support a subset.
- Do not guess UUIDs — invalid or disabled values return a
400validation error. - The language model is configured automatically on create; you cannot set or change it via the API.
For tools, send the full { "llm_tools": [...] } payload you want stored. On PATCH, the tools key replaces the entire tool list — GET the agent first, merge changes, then PATCH.
For voicemail_msg and call_duration_exceed_message, use an empty string to clear a previously saved message.
Write Clear Instructions
Provide detailed, specific instructions for agents:
- Be explicit about behavior
- Include examples
- Specify tone and style
- Define conversation flow
Define Output Fields
Clearly specify what data to extract:
- Use descriptive field names
- Include format requirements
- Specify required vs optional fields
Test Agents Thoroughly
Before deploying, test agents with:
- Various conversation scenarios
- Different user responses
- Edge cases
- Error handling
Error Handling
Validate Input
Always validate before making API calls:
Handle All Error Cases
Check for all possible error scenarios:
- Validation errors (400)
- Authentication errors (401)
- Not found errors (404)
- Rate limit errors (429)
- Server errors (500)
Security
Store API Keys Securely
Never commit API keys to version control:
Use Environment Variables
Store sensitive data in environment variables:
Monitoring
Track Call Status
Monitor call outcomes:
- Success rates
- Failure reasons
- Average call duration
- Response times
Log Important Events
Log key events for debugging:
- Call initiation
- Status changes
- Errors
- Webhook events
Set Up Alerts
Configure alerts for:
- High failure rates
- Rate limit errors
- System errors
- Batch completion
Performance Optimization
Use Pagination
For large lists, use pagination:
Cache Agent Lists
Cache agent information to reduce API calls:
Webhook Best Practices
The payload your webhook receives is described in Core Concepts — Webhooks. Webhooks are sent for both completed and failed calls; use the outcome field ("Completed" or "Failure") to distinguish. The payload includes call metadata, transcript, recording URL, agent_args (object), and extracted call_output (populated mainly on completed calls).
Verify Webhook Signatures
Always verify webhook authenticity:
Handle Webhook Failures
Implement retry logic for webhook delivery:
- Queue failed webhooks
- Retry with exponential backoff
- Log failures for manual review
Testing
Test in Staging
Always test in staging environment first:
- Test agent behavior
- Verify call flows
- Check error handling
- Validate data extraction
Use Test Phone Numbers
Use test phone numbers for development:
- Avoid calling real customers during testing
- Use dedicated test numbers
- Verify behavior before production

