Skip to content

REST API Proxy - cURL Examples

Base URL: https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy

Authentication

Use either: - X-API-Key: cg_your_api_key (API key from Settings → API Keys) - Authorization: Bearer <supabase_jwt_token> (from user session)


1. CREATE DEAL

curl -X POST \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/deals" \
 -H "Content-Type: application/json" \
 -H "X-API-Key: cg_your_api_key_here" \
 -d '{
 "title": "Enterprise Software Deal",
 "stage": "LEAD",
 "value": 50000,
 "currency": "USD",
 "contact_id": "uuid-of-contact",
 "company_id": "uuid-of-company",
 "expected_close_date": "2025-12-31",
 "probability": 30,
 "priority": "high",
 "source": "referral"
 }'

Response: Returns created deal with auto-generated id, organization_id, timestamps.


2. UPDATE DEAL

# Update deal by ID
curl -X PATCH \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/deals?id=eq.deal-uuid-here" \
 -H "Content-Type: application/json" \
 -H "X-API-Key: cg_your_api_key_here" \
 -d '{
 "stage": "NEGOTIATION",
 "value": 75000,
 "probability": 60,
 "notes": "Advanced to negotiation phase"
 }'

# Update multiple deals by stage
curl -X PATCH \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/deals?stage=eq.LEAD" \
 -H "Content-Type: application/json" \
 -H "X-API-Key: cg_your_api_key_here" \
 -d '{"priority": "low"}'

3. CREATE CONTACT (Customer)

curl -X POST \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/contacts" \
 -H "Content-Type: application/json" \
 -H "X-API-Key: cg_your_api_key_here" \
 -d '{
 "first_name": "John",
 "last_name": "Doe",
 "emails": ["john.doe@example.com", "john@example.com"],
 "phones": ["+1234567890"],
 "company_id": "uuid-of-company",
 "tags": ["lead", "warm"],
 "source": "website",
 "description": "Interested in enterprise package",
 "custom_fields": {
 "job_title": "CTO",
 "linkedin": "linkedin.com/in/johndoe"
 }
 }'

Response: Returns created contact with auto-generated id, organization_id, timestamps.


4. UPDATE CONTACT

# Update contact by ID
curl -X PATCH \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/contacts?id=eq.contact-uuid-here" \
 -H "Content-Type: application/json" \
 -H "X-API-Key: cg_your_api_key_here" \
 -d '{
 "first_name": "Jonathan",
 "tags": ["lead", "warm", "qualified"],
 "emails": ["john.doe@example.org"]
 }'

# Update contacts by tag
curl -X PATCH \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/contacts?tags=cs.{\"cold\"}" \
 -H "Content-Type: application/json" \
 -H "X-API-Key: cg_your_api_key_here" \
 -d '{"source": "cold_call_campaign"}'

Note: organization_id is automatically set on create and filtered on update. Cannot be changed.


5. QUERY / READ

# Get all deals (organization-scoped)
curl -X GET \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/deals?limit=100" \
 -H "X-API-Key: cg_your_api_key_here"

# Get deal by ID
curl -X GET \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/deals?id=eq.deal-uuid" \
 -H "X-API-Key: cg_your_api_key_here"

# Search contacts by name (case-insensitive)
curl -X GET \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/contacts?first_name=ilike.*John*" \
 -H "X-API-Key: cg_your_api_key_here"

# Get deals with stage filter
curl -X GET \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/deals?stage=eq.CLOSED_WON&order=created_at.desc" \
 -H "X-API-Key: cg_your_api_key_here"

6. DELETE

# Delete deal by ID
curl -X DELETE \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/deals?id=eq.deal-uuid" \
 -H "X-API-Key: cg_your_api_key_here"

# Delete contacts by tag (batch)
curl -X DELETE \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/contacts?tags=cs.{\"test\"}" \
 -H "X-API-Key: cg_your_api_key_here"

A DELETE with no filter is refused with 400, because it would remove every row of that resource in your organization and there is no undo. That is almost always an accident — a template variable that resolved to nothing, or a retry that lost its query string. To empty a resource on purpose, ask for it explicitly:

curl -X DELETE \
 "https://txpaxbxhnvnhsjwwaeoy.supabase.co/functions/v1/rest-api-proxy/contacts?confirm_delete_all=true" \
 -H "X-API-Key: cg_your_api_key_here"

Supported Operators

Operator Description Example
eq Equals ?stage=eq.LEAD
neq Not equals ?stage=neq.CLOSED_LOST
gt Greater than ?value=gt.1000
gte Greater or equal ?created_at=gte.2025-01-01
lt Less than ?value=lt.5000
lte Less or equal ?probability=lte.50
like Pattern match ?title=like.*Corp*
ilike Case-insensitive match ?first_name=ilike.*john*
is Is null ?company_id=is.null
in In list ?stage=in.(LEAD,PROSPECT)
cs Contains (arrays) ?tags=cs.{\"warm\"}

Response Format

Success (200):

[
 {
 "id": "uuid",
 "organization_id": "org-uuid",
 "title": "Enterprise Software Deal",...
 }
]

Error (4xx/5xx):

{
 "error": "Error message",
 "hint": "Helpful hint"
}


ConnectGain — omnichannel inbox, CRM & automation for WhatsApp, Messenger, Instagram, Telegram and more. Open the app · Docs home