Skip to main content

API Reference

The Renchi AI API is organized around REST principles. All endpoints are built as Next.js API routes and handle specific functionality for the platform.

Endpoint Categories


Integrations

OAuth-based connections to third-party services. Supported providers: Google Calendar, HubSpot, Salesforce, Microsoft Teams.
EndpointMethodDescription
/api/integrations/[provider]/connectPOST/GETInitiate OAuth flow
/api/integrations/[provider]/callbackGETOAuth callback handler
/api/integrations/[provider]/disconnectPOSTRemove integration
/api/integrations/statusGETGet all integration statuses

Authentication

Requires authenticated user session with team admin/owner role.

Supported Providers

  • google_calendar - Google Calendar sync
  • hubspot - HubSpot CRM integration
  • salesforce - Salesforce CRM integration
  • microsoft_teams - Microsoft Teams notifications

Webhooks

Event handlers for voice call processing. These endpoints receive callbacks from Twilio and ElevenLabs.

Twilio Webhooks

EndpointMethodDescription
/api/webhooks/twilio/voicePOSTIncoming call handler
/api/webhooks/twilio/statusPOSTCall status updates
/api/webhooks/twilio/recordingPOSTRecording completion
Authentication: Twilio signature validation via X-Twilio-Signature header.

ElevenLabs Webhooks

EndpointMethodDescription
/api/webhooks/elevenlabsPOSTMain webhook (transcription, audio, failures)
/api/webhooks/elevenlabs/personalizePOSTReal-time call personalization
Authentication:
  • Main webhook: ElevenLabs-Signature header validation
  • Personalize: x-webhook-secret or Authorization: Bearer token

Event Types (ElevenLabs)

Sent after call completion with full transcript, AI analysis, and metadata.
{
  "type": "post_call_transcription",
  "event_timestamp": 1704067200,
  "data": {
    "agent_id": "agent_xxx",
    "conversation_id": "conv_xxx",
    "transcript": [...],
    "analysis": {...}
  }
}

Cron Jobs

Scheduled background tasks executed by Vercel Cron.
EndpointScheduleDescription
/api/cron/cleanup-recordingsDaily 3:00 AM UTCDelete expired recordings
/api/cron/daily-summaryDaily 6:00 PM UTCSend daily summary emails
/api/cron/weekly-reportMonday 9:00 AM UTCSend weekly performance reports
Authentication: Authorization: Bearer {CRON_SECRET} header.

Admin

Setup and debugging endpoints.
EndpointMethodDescription
/api/setup-super-adminPOSTCreate super admin accounts (one-time setup)
/api/debug/dbGETTest database connectivity
These endpoints should be removed or heavily protected in production.

Error Handling

All endpoints return errors in a consistent format:
{
  "error": "Error message describing what went wrong",
  "code": "ERROR_CODE"
}

Common Error Codes

CodeHTTP StatusDescription
UNAUTHORIZED401Missing or invalid authentication
FORBIDDEN403Insufficient permissions
NOT_FOUND404Resource not found
VALIDATION_ERROR400Invalid request parameters
INTERNAL_ERROR500Server error

Rate Limiting

  • Webhook endpoints: No rate limiting (event-driven)
  • Cron endpoints: Protected by Vercel Cron scheduling
  • Integration endpoints: Standard API rate limits apply

CORS

All API endpoints support CORS for same-origin requests. Cross-origin requests require proper authentication.