โ† Back to Documentation

API Reference

RESTful endpoints for integrating with Ringback. All API routes require authentication unless noted.

Base URL:https://your-domain.com/api

๐Ÿ” Authentication

Most endpoints use Supabase Auth session cookies (browser) or Bearer tokens (server-to-server).

Bearer

Supabase Auth session cookie (browser) or Bearer token (API). Set Authorization: Bearer <token>

Public

No authentication required (onboarding, webhooks with signature verification)

Twilio Signature

Validated via X-Twilio-Signature header. Configure webhook URL in Twilio Console.

Stripe Signature

Validated via Stripe-Signature header. Configure in Stripe Dashboard.

Cron Secret

Internal cron jobs. Requires CRON_SECRET header matching env var.

Authentication

POST
/api/auth/register

Register new user account

Public

Onboarding

POST
/api/onboarding/send-verification

Send SMS verification code to phone number

Public
POST
/api/onboarding/verify-code

Verify 6-digit code, create phone number record

Public
POST
/api/onboarding/resend-verification

Resend verification code

Public

Leads

GET
/api/leads

List leads with filters (status, search, pagination)

Bearer
POST
/api/leads

Create manual lead

Bearer
GET
/api/leads/[id]

Get lead detail with timeline & messages

Bearer
PATCH
/api/leads/[id]

Update lead (name, status, notes)

Bearer
POST
/api/leads/[id]/send

Manually trigger next sequence step

Bearer
POST
/api/leads/[id]/close

Close lead (stop sequence)

Bearer
POST
/api/leads/[id]/mark-won

Mark lead as won

Bearer
POST
/api/leads/[id]/mark-lost

Mark lead as lost

Bearer

Phone Numbers

GET
/api/phone-numbers

List user's phone numbers

Bearer
POST
/api/phone-numbers

Add new phone number (starts verification)

Bearer
DELETE
/api/phone-numbers/[id]

Delete phone number

Bearer
PATCH
/api/phone-numbers/[id]

Update friendly name, forwarding status

Bearer

Sequences

GET
/api/sequences?phoneNumberId=

Get sequence steps for a phone number

Bearer
PATCH
/api/sequences

Update sequence step (channel, delay, template)

Bearer
POST
/api/sequences

Add new step to sequence

Bearer
DELETE
/api/sequences/[id]

Delete sequence step

Bearer

Settings

GET
/api/settings/crm

Get CRM configuration

Bearer
PATCH
/api/settings/crm

Update CRM config (provider, fields, credentials)

Bearer
POST
/api/settings/crm/test

Test CRM connection with sample payload

Bearer
GET
/api/settings/billing

Get subscription & usage

Bearer
POST
/api/billing/checkout

Create Stripe Checkout session

Bearer
POST
/api/billing/portal

Create Stripe Billing Portal session

Bearer

Webhooks (Inbound)

POST
/api/webhooks/twilio/sms

Twilio SMS webhook (inbound replies, delivery status)

Twilio Signature
POST
/api/webhooks/twilio/voice

Twilio Voice webhook (missed calls, AI voice)

Twilio Signature
POST
/api/webhooks/stripe

Stripe events (subscription, payment, invoice)

Stripe Signature
POST
/api/webhooks/hubspot

HubSpot webhook (contact/deal updates)

HubSpot Signature

Cron Jobs (Internal)

POST
/api/cron/process-sequences

Process due sequence steps (runs every minute)

Cron Secret
POST
/api/cron/send-messages

Send queued messages (runs every 30s)

Cron Secret
POST
/api/cron/process-sequences-batch

Batch process for high volume

Cron Secret

๐Ÿ“„ Response Examples

GET /api/leads/[id]

{
  "id": "uuid",
  "phone_number_id": "uuid",
  "name": "Marcus T.",
  "phone_e164": "+12145550132",
  "status": "active",
  "source": "missed_call",
  "metadata": {
    "caller_id_name": "Marcus T.",
    "forwarded_from": "+12145550199"
  },
  "created_at": "2026-01-12T14:14:00Z",
  "updated_at": "2026-01-12T14:14:00Z"
}

GET /api/sequences?phoneNumberId=

[
  {
    "id": "uuid",
    "phone_number_id": "uuid",
    "step_order": 1,
    "channel": "sms",
    "delay_minutes": 0,
    "template_sms": "Hi {{lead_name}}, this is {{business_name}}...",
    "template_email_subject": null,
    "template_email_html": null,
    "template_email_text": null,
    "is_active": true,
    "created_at": "2026-01-12T14:14:00Z",
    "updated_at": "2026-01-12T14:14:00Z"
  }
]

Lead Messages (included in lead detail)

[
  {
    "id": "uuid",
    "lead_id": "uuid",
    "direction": "outbound",
    "channel": "sms",
    "content": "Hi Marcus, this is Torres Plumbing...",
    "status": "delivered",
    "twilio_sid": "SMxxxxxxxxxxxx",
    "step_order": 1,
    "scheduled_at": "2026-01-12T14:14:05Z",
    "sent_at": "2026-01-12T14:14:06Z",
    "delivered_at": "2026-01-12T14:14:08Z",
    "created_at": "2026-01-12T14:14:05Z"
  }
]

๐Ÿ”” Webhook Payloads (Inbound)

Configure these URLs in your provider dashboards. All webhooks verified via signature headers.

Twilio SMS Inbound (Lead Reply)

{
  "MessageSid": "SMxxxxxxxxxxxx",
  "From": "+12145550132",
  "To": "+12145550199",
  "Body": "Yes, I need a plumber tomorrow",
  "MessageStatus": "received"
}

Twilio Voice (Missed Call)

{
  "CallSid": "CAxxxxxxxxxxxx",
  "From": "+12145550132",
  "To": "+12145550199",
  "CallStatus": "no-answer",
  "Direction": "inbound",
  "CallerName": "Marcus T."
}

Stripe Subscription Created

{
  "id": "evt_xxxxxxxxxxxx",
  "type": "customer.subscription.created",
  "data": {
    "object": {
      "id": "sub_xxxxxxxxxxxx",
      "customer": "cus_xxxxxxxxxxxx",
      "status": "active",
      "items": {
        "data": [
          {
            "price": {
              "id": "price_growth_monthly"
            }
          }
        ]
      }
    }
  }
}

โฑ๏ธ Rate Limits

  • API endpoints: 120 requests/minute per user
  • SMS sending: Per Twilio account limits (typically 1 msg/sec per number)
  • Email sending: Per SendGrid/Mailgun limits
  • Webhook retries: Exponential backoff (1m, 5m, 15m, 1h, 6h)

Rate limit headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset

โŒ Error Responses

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Phone number must be in E.164 format",
    "details": { "field": "phone_number" }
  }
}
400Bad Request (validation)
401Unauthorized (session expired)
403Forbidden (not owner of resource)
404Not Found
429Rate Limited
500Internal Server Error