ConnectGain API - Complete cURL Samples¶
Base URL: https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1
Authentication: All endpoints require X-API-Key header with your API key (prefix cg_).
Table of Contents¶
- Create Single Contact
- Create Bulk Contacts
- Create Single Lead with Deal
- Create Bulk Leads
- Create Single Deal
- Create Bulk Deals
1. Create Single Contact¶
Endpoint: POST /create-lead
Creates a single contact/lead with optional deal creation.
Minimal Request¶
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/create-lead' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com"
}'
Full Request (All Fields)¶
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/create-lead' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com",
"emails": ["john.work@company.com", "john.personal@gmail.com"],
"phone": "+1234567890",
"phones": ["+1987654321", "+1555666777"],
"source": "website_form",
"tags": ["hot-lead", "enterprise", "demo-requested"],
"description": "Interested in enterprise plan. Budget: $50k. Timeline: Q2 2025",
"company_name": "Acme Corporation",
"custom_fields": {
"industry": "Technology",
"company_size": "100-500",
"job_title": "VP of Sales",
"linkedin_url": "https://linkedin.com/in/johndoe",
"referral_source": "Google Ads",
"campaign_id": "spring_2025_campaign",
"lead_score": 85
},
"deal": {
"title": "Acme Corp - Enterprise License",
"value": 50000,
"currency": "USD",
"stage": "qualified",
"pipeline_id": "your-pipeline-uuid"
}
}'
Response¶
{
"success": true,
"message": "Lead created successfully",
"data": {
"contact": {
"id": "uuid-of-contact",
"first_name": "John",
"last_name": "Doe",
"emails": ["john.doe@example.com", "john.work@company.com"],
"phones": ["+1234567890", "+1987654321"],
"source": "website_form",
"tags": ["hot-lead", "enterprise", "demo-requested"],
"created_at": "2025-02-05T12:00:00Z"
},
"deal": {
"id": "uuid-of-deal",
"title": "Acme Corp - Enterprise License",
"value": 50000,
"currency": "USD",
"stage": "qualified"
},
"is_new": true
}
}
2. Create Bulk Contacts¶
Endpoint: POST /import-contacts-bulk
Import up to 500 contacts in a single request with duplicate detection and merge capabilities.
Minimal Request¶
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/import-contacts-bulk' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contacts": [
{
"first_name": "Alice",
"email": "alice@example.com"
},
{
"first_name": "Bob",
"phone": "+1234567890"
}
]
}'
Full Request (All Fields)¶
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/import-contacts-bulk' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contacts": [
{
"first_name": "Alice",
"last_name": "Smith",
"email": "alice@example.com",
"emails": ["alice.work@company.com"],
"phone": "+1234567890",
"phones": ["+1555123456"],
"source": "trade_show",
"tags": ["vip", "decision-maker"],
"description": "Met at Tech Summit 2025. Very interested in AI features.",
"company_id": "uuid-of-existing-company",
"assignee_id": "uuid-of-sales-rep",
"opt_in_status": true,
"custom_fields": {
"job_title": "CTO",
"department": "Engineering",
"budget_range": "$100k-$500k",
"preferred_contact_time": "mornings",
"timezone": "America/New_York"
}
},
{
"first_name": "Bob",
"last_name": "Johnson",
"email": "bob@company.com",
"emails": ["bob.personal@gmail.com"],
"phone": "+1987654321",
"source": "referral",
"tags": ["warm-lead", "sme"],
"description": "Referred by Alice Smith",
"opt_in_status": true,
"custom_fields": {
"job_title": "Director of Operations",
"company_size": "50-100",
"use_case": "Customer support automation"
}
},
{
"first_name": "Carol",
"last_name": "Williams",
"email": "carol@enterprise.com",
"phone": "+1555888999",
"source": "inbound",
"tags": ["enterprise", "high-priority"],
"company_name": "Enterprise Corp",
"custom_fields": {
"job_title": "VP of Customer Success",
"current_solution": "Zendesk",
"pain_points": ["slow response times", "lack of automation"],
"contract_end_date": "2025-06-30"
}
}
],
"skip_duplicates": false,
"default_tags": ["import-feb-2025", "api-import"],
"default_source": "api_bulk_import"
}'
Response¶
{
"success": true,
"summary": {
"total": 3,
"successful": 3,
"failed": 0,
"new_contacts": 2,
"updated_contacts": 1,
"skipped_duplicates": 0
},
"results": [
{
"index": 0,
"success": true,
"contact_id": "uuid-1",
"is_new": true
},
{
"index": 1,
"success": true,
"contact_id": "uuid-2",
"is_new": false
},
{
"index": 2,
"success": true,
"contact_id": "uuid-3",
"is_new": true
}
]
}
3. Create Single Lead with Deal¶
Same as Create Single Contact but with deal creation.
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/create-lead' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "Enterprise",
"last_name": "Client",
"email": "procurement@enterprise.com",
"phone": "+1800555000",
"source": "enterprise_inquiry",
"tags": ["enterprise", "priority", "q1-target"],
"description": "Large enterprise account. Multiple stakeholders involved.",
"custom_fields": {
"company": "Fortune 500 Corp",
"employees": 10000,
"annual_revenue": "$1B+",
"decision_timeline": "60 days"
},
"deal": {
"title": "Fortune 500 Corp - Enterprise Suite",
"value": 250000,
"currency": "USD",
"stage": "discovery",
"pipeline_id": "enterprise-pipeline-uuid"
}
}'
4. Create Bulk Leads¶
Endpoint: POST /create-leads-bulk
Create up to 100 leads with duplicate handling.
Full Request¶
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/create-leads-bulk' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"leads": [
{
"first_name": "Lead",
"last_name": "One",
"email": "lead1@example.com",
"phone": "+1111111111",
"source": "facebook_ads",
"tags": ["facebook", "cold-lead"],
"description": "Downloaded whitepaper on AI automation",
"custom_fields": {
"campaign": "facebook_feb_2025",
"ad_set": "lookalike_audience",
"landing_page": "/whitepaper-ai"
}
},
{
"first_name": "Lead",
"last_name": "Two",
"email": "lead2@example.com",
"phone": "+2222222222",
"source": "google_ads",
"tags": ["google", "warm-lead"],
"description": "Requested pricing information",
"custom_fields": {
"campaign": "google_search_feb_2025",
"keyword": "crm software pricing",
"match_type": "exact"
}
},
{
"first_name": "Lead",
"last_name": "Three",
"email": "lead3@example.com",
"phones": ["+3333333333", "+3333333334"],
"source": "linkedin",
"tags": ["linkedin", "decision-maker"],
"description": "Connected via LinkedIn Sales Navigator",
"custom_fields": {
"linkedin_profile": "https://linkedin.com/in/leadthree",
"mutual_connections": 5,
"engagement_score": "high"
}
}
],
"skip_duplicates": true
}'
Response¶
{
"success": true,
"summary": {
"total": 3,
"successful": 3,
"failed": 0,
"new_contacts": 2,
"updated_contacts": 0,
"skipped_duplicates": 1
},
"results": [
{"index": 0, "success": true, "contact_id": "uuid-1", "is_new": true},
{"index": 1, "success": true, "contact_id": "uuid-2", "is_new": true},
{"index": 2, "success": true, "contact_id": "uuid-3", "is_new": false}
]
}
5. Create Single Deal¶
Use the /create-lead endpoint with the deal parameter.
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/create-lead' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "Sarah",
"last_name": "Connor",
"email": "sarah@skynet.com",
"deal": {
"title": "Skynet - AI Platform License",
"value": 75000,
"currency": "USD",
"stage": "negotiation",
"pipeline_id": "your-pipeline-uuid"
}
}'
6. Create Bulk Deals¶
Endpoint: POST /create-deals-bulk
Create up to 100 deals with automatic contact resolution or creation.
Minimal Request¶
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/create-deals-bulk' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"deals": [
{
"title": "Deal One",
"contact_email": "customer1@example.com",
"value": 5000
},
{
"title": "Deal Two",
"contact_phone": "+1234567890",
"value": 10000
}
]
}'
Full Request (All Fields)¶
curl --location 'https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/create-deals-bulk' \
--header 'X-API-Key: cg_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"deals": [
{
"contact_id": "uuid-of-existing-contact",
"title": "Enterprise Agreement - Q1 2025",
"value": 150000,
"currency": "USD",
"stage": "proposal",
"pipeline_id": "enterprise-pipeline-uuid",
"description": "Multi-year enterprise agreement with volume discounts",
"expected_close_date": "2025-03-31",
"probability": 75,
"source": "enterprise_sales",
"tags": ["enterprise", "multi-year", "priority"],
"owner_id": "uuid-of-sales-rep",
"company_id": "uuid-of-company",
"custom_fields": {
"contract_term": "3 years",
"payment_terms": "net-30",
"discount_percentage": 15,
"stakeholders": ["CEO", "CTO", "CFO"],
"competitor": "Salesforce",
"implementation_timeline": "90 days"
},
"products": [
{
"name": "Enterprise License",
"quantity": 500,
"unit_price": 200
},
{
"name": "Premium Support",
"quantity": 1,
"unit_price": 25000
},
{
"name": "Implementation Services",
"quantity": 1,
"unit_price": 15000
}
]
},
{
"contact_email": "new.customer@startup.com",
"create_contact_if_missing": true,
"contact_first_name": "New",
"contact_last_name": "Customer",
"title": "Startup Growth Plan",
"value": 12000,
"currency": "USD",
"stage": "qualified",
"description": "Growing startup, interested in growth tier",
"expected_close_date": "2025-02-28",
"probability": 60,
"source": "inbound",
"tags": ["startup", "growth-tier", "saas"],
"custom_fields": {
"company_stage": "Series A",
"team_size": 25,
"current_mrr": "$50k",
"use_case": "Sales automation"
},
"products": [
{
"name": "Growth Plan - Annual",
"quantity": 1,
"unit_price": 12000
}
]
},
{
"contact_phone": "+1555999888",
"create_contact_if_missing": true,
"contact_first_name": "Phone",
"contact_last_name": "Lead",
"title": "SMB Standard Package",
"value": 3600,
"currency": "USD",
"stage": "discovery",
"description": "Small business, monthly billing preferred",
"expected_close_date": "2025-03-15",
"probability": 40,
"source": "phone_inquiry",
"tags": ["smb", "monthly-billing"],
"custom_fields": {
"billing_preference": "monthly",
"seats_needed": 10,
"industry": "Retail"
}
}
],
"default_pipeline_id": "main-pipeline-uuid",
"default_stage": "new",
"default_currency": "USD",
"skip_if_exists": false
}'
Response¶
{
"success": true,
"summary": {
"total": 3,
"successful": 3,
"failed": 0,
"new_deals": 3,
"skipped_existing": 0,
"new_contacts_created": 2
},
"results": [
{
"index": 0,
"success": true,
"deal_id": "deal-uuid-1",
"contact_id": "contact-uuid-1",
"is_new_contact": false
},
{
"index": 1,
"success": true,
"deal_id": "deal-uuid-2",
"contact_id": "contact-uuid-2",
"is_new_contact": true
},
{
"index": 2,
"success": true,
"deal_id": "deal-uuid-3",
"contact_id": "contact-uuid-3",
"is_new_contact": true
}
]
}
Field Reference¶
Contact Fields¶
| Field | Type | Required | Description |
|---|---|---|---|
first_name |
string | No* | Contact's first name |
last_name |
string | No* | Contact's last name |
email |
string | No* | Primary email address |
emails |
string[] | No | Additional email addresses |
phone |
string | No* | Primary phone number |
phones |
string[] | No | Additional phone numbers |
source |
string | No | Lead source (e.g., "website", "referral") |
tags |
string[] | No | Tags for categorization |
description |
string | No | Notes about the contact |
company_id |
uuid | No | Link to existing company |
company_name |
string | No | Company name (for reference) |
assignee_id |
uuid | No | Assigned team member |
opt_in_status |
boolean | No | Marketing consent status |
custom_fields |
object | No | Any custom key-value pairs |
*At least one of first_name, last_name, email, or phone is required.
Deal Fields¶
| Field | Type | Required | Description |
|---|---|---|---|
title |
string | Yes | Deal title |
contact_id |
uuid | No* | Existing contact UUID |
contact_email |
string | No* | Find contact by email |
contact_phone |
string | No* | Find contact by phone |
value |
number | No | Deal value (default: 0) |
currency |
string | No | Currency code (default: "USD") |
stage |
string | No | Pipeline stage (default: "new") |
pipeline_id |
uuid | No | Pipeline UUID |
description |
string | No | Deal notes |
expected_close_date |
string | No | ISO date string |
probability |
number | No | Win probability (0-100) |
source |
string | No | Deal source |
tags |
string[] | No | Deal tags |
owner_id |
uuid | No | Deal owner (sales rep) |
company_id |
uuid | No | Associated company |
custom_fields |
object | No | Custom key-value pairs |
products |
array | No | Products/line items |
create_contact_if_missing |
boolean | No | Create contact if not found |
contact_first_name |
string | No | First name for new contact |
contact_last_name |
string | No | Last name for new contact |
*At least one of contact_id, contact_email, or contact_phone is required.
Bulk Options¶
| Field | Type | Default | Description |
|---|---|---|---|
skip_duplicates |
boolean | false | Skip instead of merge duplicates |
default_tags |
string[] | [] | Apply to all contacts |
default_source |
string | "api" | Default source value |
default_pipeline_id |
uuid | null | Default pipeline for deals |
default_stage |
string | "new" | Default stage for deals |
default_currency |
string | "USD" | Default currency for deals |
skip_if_exists |
boolean | false | Skip if deal already exists |
Error Handling¶
All endpoints return consistent error responses:
Common HTTP Status Codes¶
| Code | Description |
|---|---|
| 200 | Success (bulk operations) |
| 201 | Created (single contact/deal) |
| 400 | Bad Request - Invalid input |
| 401 | Unauthorized - Invalid API key |
| 405 | Method Not Allowed - Use POST |
| 500 | Internal Server Error |
Rate Limits¶
- Bulk Contacts: Max 500 per request
- Bulk Leads: Max 100 per request
- Bulk Deals: Max 100 per request
For larger imports, split into multiple requests.