Integration guide

Production-ready integration for LeadHunterOS

Connect your telephony, create workflows, and launch calls from your CRM or from Twilio. This guide uses the actual endpoints that are available in the platform so you can move from setup to production without guesswork.

What you need
  • Keep API keys in a secure backend environment, not in browser code.
  • Use your real workflow ID from the Workspace screen for outbound calls.
  • Use the Twilio webhook URL for inbound calls and make sure it is publicly reachable.
  • Verify health and metrics before rollout and monitor failures closely.

1. Connect your telephony

Use your own Twilio account or another BYOK provider. Add credentials in a secure environment and keep them out of frontend code.

2. Create a workflow

Build the agent logic in Workspace, add prompt nodes, context variables, and any webhook or transfer logic you need.

3. Launch it from API or Twilio

Use the workflow ID with the outbound API for CRM automation, or configure Twilio to call the inbound webhook for incoming calls.

How the integration works

Outbound calls

Use the authenticated endpoint POST /api/agents/start from your own backend or CRM. Send the workflow ID you copied from Workspace, a destination phone number, and optional context variables such as product, price, or lead source.

Inbound calls

Configure your Twilio number to call POST /api/agents/twilio/inbound. This is the public webhook that Twilio hits when a call arrives.

Testing and monitoring

Before going live, run a test call with POST /api/agents/{id}/test-call and review analytics at GET /api/agents/analytics.

Real endpoints you can use

GET /api/users/me/usage

Check plan access, current usage, and API limits

GET /api/users/profile

Fetch profile details and current balance

GET /api/users/transactions

Read billing history and recent top-ups

POST /api/auth/api-keys

Create an API token for backend-to-backend requests

GET /api/agents/analytics

Read call stats, success rate, and recent call logs

POST /api/agents/start

Start an outbound call from your CRM or backend

POST /api/agents/{id}/test-call

Run a test call for a workflow before production launch

POST /api/agents/twilio/inbound

Public webhook for incoming Twilio calls

Example request: start an outbound call

Request

curl -X POST https://leadhunteros.com/api/agents/start   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{
    "agent_id": "11111111-2222-3333-4444-555555555555",
    "phone_number": "+380501112233",
    "first_name": "Alex",
    "contact_id": 42,
    "context": {
      "product": "Enterprise",
      "price": "499",
      "source": "website"
    }
  }'

Replace YOUR_API_KEY with the token you created in the profile section and use a real workflow ID from Workspace. The context object is optional and is injected into the workflow variables.

What each field means

  • agent_id: the workflow ID you copied from the workflow card or workflow editor.
  • phone_number: the destination in E.164 format, for example +380501112233.
  • first_name: optional display name for the contact.
  • contact_id: optional internal ID from your CRM or contact table.
  • context: extra variables for prompt substitution and workflow branching.

Expected response

{
  "status": "success",
  "call_id": "b1a2c3d4-e5f6-4788-a123-4c5d6e7f8a90",
  "reserved_cents": 60
}
Twilio inbound webhook

Set your Twilio phone number webhook to https://leadhunteros.com/api/agents/twilio/inbound. This endpoint is called by Twilio directly when an inbound call arrives. It does not require a bearer token because Twilio is the caller.

When to use it

Use this when you want LeadHunterOS to answer incoming calls on your Twilio number and route them through a workflow automatically.

Auth and security

API keys

Create them in the profile section. Keep the secret in your backend and never expose it in frontend JavaScript.

JWT and tenant safety

Use short-lived auth tokens in production and keep workflow data isolated per tenant and per account.

Monitoring

Watch call logs, errors, and usage from the analytics section so failures are visible before they become customer issues.

FAQ

Do I need a bearer token for inbound Twilio webhooks?

No. Twilio calls the inbound endpoint directly and the platform uses the webhook route itself for the call flow.

Where do I get the workflow ID?

Copy it from the workflow card in Workspace or from the workflow editor header. It is required for outbound calls.

Can I test a workflow before launch?

Yes. Use the dedicated test call endpoint before enabling production traffic.

What should I send in context?

Send any variables you want the workflow to reference, such as product, price, lead source, or campaign name.