Futwork AI Platform API

Lead Integration Guide - Push leads to the Futwork AI Platform and receive post-call data through webhooks.

Introduction

This document explains how clients can push leads to the Futwork AI Platform and how post-call data will be sent back to their system through a webhook.

Integration Flow

The integration consists of two main parts:

  1. Lead Submission (Client → Futwork): Clients push leads to the Futwork AI Platform
  2. Post-Call Response (Futwork → Client Webhook): After the call finishes, the platform sends post-call data to the client's webhook URL
Flow Diagram: Client System → Futwork AI Platform → Client Webhook

Base URL

All API requests should be made to the following base URL:

https://platform.futwork.ai/api

Data Format

All requests and responses use JSON format. Content-Type headers should be set to application/json.

Authentication

Secure your API requests using the x-api-key header provided by Futwork.

API Key Authentication

Futwork will provide you with an API key that must be included in the x-api-key header for all API requests.

Using API Keys

Include your API key in the x-api-key header of every request:

curl --location 'https://platform.futwork.ai/api/campaigns/{campaignId}/leads' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json'
const fetch = require('node-fetch');

const response = await fetch(
  'https://platform.futwork.ai/api/campaigns/{campaignId}/leads',
  {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    }
  }
);
import requests

headers = {
    'x-api-key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
}

response = requests.post(
    'https://platform.futwork.ai/api/campaigns/{campaignId}/leads',
    headers=headers
)
Security: Never commit API keys to version control. Use environment variables or secure secret management tools. Keep your keys secure and never expose them in client-side code or public repositories.

Token Handling

Futwork will provide the API key required for authentication. The client simply needs to include it in the x-api-key header.

Lead Submission

Submit leads to the Futwork AI Platform using the lead submission endpoint.

Endpoint

POST
/api/campaigns/{campaignId}/leads
Note: Replace {campaignId} in the URL with the actual campaign ID from the AI platform you have created.

Headers

Header Value Required
Content-Type application/json Yes
x-api-key Your API key (provided by Futwork) Yes

Request Body

Field Type Required Description
recipientPhoneNumber string Yes 10-digit phone number (e.g., "9999789877")
recipientData object Yes Additional lead data (custom fields based on LeadSchema)

Request Example

curl --location 'https://platform.futwork.ai/api/campaigns/{campaignId}/leads' \
--header 'x-api-key: 123jkkn43oo42551345gfqrg' \
--header 'Content-Type: application/json' \
--data '{
  "recipientPhoneNumber": "9999789877",
  "recipientData": {
    "customer_name": "abcd xyz",
    "place": "ABC"
  }
}'
const fetch = require('node-fetch');

const response = await fetch(
  'https://platform.futwork.ai/api/campaigns/{campaignId}/leads',
  {
    method: 'POST',
    headers: {
      'x-api-key': '123jkkn43oo42551345gfqrg',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      recipientPhoneNumber: '9999789877',
      recipientData: {
        customer_name: 'abcd xyz',
        place: 'ABC'
      }
    })
  }
);

const data = await response.json();
import requests

headers = {
    'x-api-key': '123jkkn43oo42551345gfqrg',
    'Content-Type': 'application/json'
}

payload = {
    'recipientPhoneNumber': '9999789877',
    'recipientData': {
        'customer_name': 'abcd xyz',
        'place': 'ABC'
    }
}

response = requests.post(
    'https://platform.futwork.ai/api/campaigns/{campaignId}/leads',
    headers=headers,
    json=payload
)

data = response.json()
Important: The phone number must be a 10-digit number without country code prefix.

Post Call Events

After the call finishes, the Futwork platform will push the post-call updates to the client's webhook URL.

Webhook Requirements

Your webhook endpoint must:

  • Accept POST requests
  • Process the JSON format provided below
  • Respond with HTTP 200 OK

Webhook Payload Structure

The webhook payload contains the following fields:

Field Type Description
callSid string Unique call identifier
leadId string Lead identifier
campaignId string Campaign identifier
agentId string Agent identifier
status string Call status (e.g., "call-disconnected")
telephonyData object Telephony information (direction, duration, numbers, etc.)
contextDetails object Context information including recipient data
transcript string Full call transcript
disposition string Call disposition
extractedData object Extracted data from the call (can be null)

Sample Webhook Payload

{
  "callSid": "3f19eab8-c425-495f-a343-268c44d5631a",
  "leadId": "68ecc93cd9fbecbe9431a2a1",
  "campaignId": "68ecc86fd9fbecbe9431a18e",
  "agentId": "68ecc7a3d9fbecbe9431a0a7",
  "status": "call-disconnected",
  "telephonyData": {
    "direction": "outbound",
    "duration": "0.0",
    "toNumber": "+918076405599",
    "fromNumber": "+918035735856",
    "recordingUrl": "",
    "hostedTelephony": true,
    "providerCallId": "7f209cdb-be57-4314-b6ba-3c00eb4bb650",
    "provider": "exotel",
    "hangupBy": null,
    "hangupReason": null,
    "hangupProviderCode": null
  },
  "contextDetails": {
    "recipientPhoneNumber": "+918076405599",
    "recipientData": {
      "customer_name": "abcd xyz",
      "place": "ABC"
    },
    "leadId": "68ecc93cd9fbecbe9431a2a1",
    "agentId": "68ecc7a3d9fbecbe9431a0a7",
    "campaignId": "68ecc86fd9fbecbe9431a18e"
  },
  "transcript": "assistant: Hello bani bani is testing the call \nThank you very much\nuser: hello\nassistant: Hello! How can I assist you today?\nuser: thank you thank you\nassistant: You're very welcome! If you need any further assistance, feel free to ask. Have a great day!\n",
  "disposition": "",
  "extractedData": null
}

Telephony Data Fields

Field Type Description
direction string Call direction (e.g., "outbound")
duration string Call duration in seconds
toNumber string Recipient phone number
fromNumber string Caller phone number
recordingUrl string URL to call recording (if available)
hostedTelephony boolean Whether telephony is hosted
providerCallId string Provider-specific call identifier
provider string Telephony provider (e.g., "exotel")