Skip to main content

Introduction

This guide covers all possible response codes, error formats, and best practices for handling errors when integrating with the Lovi API.

📊 HTTP Status Codes

Successful Responses

200 OK - Request Successful

Notification Processed:
Templates Retrieved:
Template Created:

Client Error Responses (4xx)

400 Bad Request - Invalid Parameters

Missing Required Field:
Invalid Parameter Format:
Invalid Phone Number:
Past Scheduled Time:

401 Unauthorized - Authentication Failed

Invalid Access Key:
Missing Access Key:

403 Forbidden - Access Denied

Insufficient Permissions:
Company Access Denied:

404 Not Found - Resource Not Found

Template Not Found:
Agent Not Found:

422 Unprocessable Entity - Business Logic Error

Template Not Approved:
Variable Mismatch:

429 Too Many Requests - Rate Limit Exceeded

Rate Limit Hit:
Daily Quota Exceeded:

Server Error Responses (5xx)

500 Internal Server Error

General Server Error:

502 Bad Gateway

Upstream Service Error:

503 Service Unavailable

Maintenance Mode:

🔄 Retry Strategies

Implementation Example


📝 Best Practices

Error Logging

Always log these fields:

Error Handling Checklist

Pre-request Validation
  • Validate phone number format
  • Check required fields
  • Validate datetime format
  • Verify template exists
Request Monitoring
  • Log all API requests
  • Include request_id in logs
  • Monitor response times
  • Track error rates
Error Recovery
  • Implement appropriate retry logic
  • Cache authentication tokens
  • Handle rate limits gracefully
  • Provide meaningful error messages to users
User Experience
  • Show user-friendly error messages
  • Provide actionable feedback
  • Don’t expose internal error details
  • Offer alternatives when possible

Monitoring & Alerting

Key Metrics to Monitor:
  • Error rate per endpoint
  • Average response time
  • Rate limit hits
  • Authentication failures
  • Template not found errors
Alert Thresholds:
  • Error rate > 5%
  • Response time > 2 seconds
  • Rate limit hits > 10/hour
  • Authentication failures > 20/hour

🛠️ Development Tools

Error Testing

Test different error scenarios:

Error Response Parser


🚨 Common Issues & Solutions

Authentication Issues

Problem: Invalid or expired access key Solution:
  1. Check if access_key is in URL parameters
  2. Verify the key hasn’t been revoked
  3. Ensure you’re using the correct company key

Template Issues

Problem: Template not found Solutions:
  1. Verify template name spelling
  2. Check template language matches
  3. Ensure template is approved
  4. Use GET /templates to list available templates

Rate Limiting

Problem: Too many requests Solutions:
  1. Implement exponential backoff
  2. Respect retry_after headers
  3. Batch requests when possible
  4. Monitor usage patterns

Data Validation

Problem: Validation failed Solutions:
  1. Validate data before sending
  2. Use proper phone number format
  3. Check datetime format
  4. Verify required fields are present
Remember to always include the request_id when contacting support for faster resolution of issues.