ConnectGain API Authentication Guide¶
This guide covers every authentication method supported by the ConnectGain API, and how to obtain and use a user JWT (JSON Web Token). The examples reference the Postman collection at ../07-api/connectgain.postman_collection.json — see the Postman guide for import instructions.
On this page:
- Authentication Methods
- Getting a JWT Token — Step by Step
- Authentication Endpoints
- Collection Variables
- Complete Testing Workflow
- Which Method to Use
Authentication Methods¶
ConnectGain supports 3 authentication methods for different use cases:
1. External API Authentication (X-API-Key)¶
Best for: External systems, third-party integrations, automation
2. Supabase REST API Authentication (Anon Key)¶
Best for: Direct database operations, CRUD operations
apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
3. User JWT Authentication (Login Required)¶
Best for: User-specific operations, subscriptions, organizations
Getting a JWT Token — Step by Step¶
Method 1: Using the Postman Login Endpoint (Recommended)¶
Step 1: Use the Login Endpoint¶
POST {{url}}/auth/v1/token?grant_type=password
apikey: {{anon_key}}
Content-Type: application/json
{
"email": "your_email@example.com",
"password": "your_password"
}
Step 2: Automatic Token Extraction¶
The login endpoint includes a test script that automatically:
- Extracts
access_tokenfrom the response - Saves it as the
user_jwt_tokenvariable - Logs a success message
Step 3: Use the Token in Other Endpoints¶
Now you can use {{user_jwt_token}} in endpoints that require user authentication.
Method 2: Using Browser Dev Tools¶
Step 1: Log in to the ConnectGain Web App¶
- Go to dashboard.connectgain.cloud
- Log in with your credentials
- Wait for successful login
Step 2: Extract the Token from the Browser¶
- Open Developer Tools (F12)
- Go to the Application tab
- Navigate to Local Storage → your domain
- Find the Supabase session data
- Copy the JWT token value
Step 3: Set It in Postman¶
- Go to the collection Variables tab
- Set the
user_jwt_tokenvalue - Save the collection
Authentication Endpoints¶
1. Login (Sign In)¶
POST {{url}}/auth/v1/token?grant_type=password
apikey: {{anon_key}}
Content-Type: application/json
{
"email": "user@example.com",
"password": "your_password"
}
Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"expires_in": 3600,
"expires_at": 1737123456,
"refresh_token": "abc123def456...",
"user": {
"id": "user-uuid",
"email": "user@example.com",
"email_confirmed_at": "2025-01-17T10:30:00Z"
}
}
Features:
- Auto-extracts the JWT token and saves it to the
user_jwt_tokenvariable - Returns user info including verification status
- Provides a refresh token for token renewal
2. Sign Up (Register)¶
POST {{url}}/auth/v1/signup
apikey: {{anon_key}}
Content-Type: application/json
{
"email": "newuser@example.com",
"password": "secure_password",
"data": {
"first_name": "John",
"last_name": "Doe"
}
}
3. Refresh Token¶
POST {{url}}/auth/v1/token?grant_type=refresh_token
apikey: {{anon_key}}
Content-Type: application/json
{
"refresh_token": "{{refresh_token}}"
}
4. Get User Info¶
5. Logout (Sign Out)¶
POST {{url}}/auth/v1/logout
apikey: {{anon_key}}
Authorization: Bearer {{user_jwt_token}}
Content-Type: application/json
{}
Collection Variables¶
Add these variables to your collection:
// Authentication variables
user_jwt_token = (auto-populated by login endpoint)
refresh_token = (auto-populated by login endpoint)
// Base variables
url = https://txpaxbxhnvnhsjwwaeoy.supabase.co
anon_key = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
api_key = cg_your_api_key_here
organization_id = 40e9bb4c-3b1c-4e5b-8c7d-2f5a9b8e1c3d
Complete Testing Workflow¶
Phase 1: Authentication Setup¶
- Login — get a JWT token
- Get User Info — verify the token works
- List Organizations — test a user-specific endpoint
Phase 2: API Testing¶
- Search Contacts — test X-API-Key auth
- List Contacts — test REST API auth
- Create Contact — test with a JWT token
- Check Subscription — test the subscription endpoint
Phase 3: Full Workflow¶
- Create resources (contacts, companies, deals)
- Send messages via multiple channels
- Import data via CSV
- Manage subscriptions
Which Method to Use¶
| Endpoint | Auth method |
|---|---|
| List Organizations | User JWT token from login |
| Check Subscription | User JWT token from login |
| Create Contact | User JWT token from login |
| Search Contacts / Companies, Insert Message | X-API-Key |
| Direct table CRUD and queries with relations | Supabase REST (anon key + JWT) |
Note: a 401 response for an invalid API key is the expected, correct behavior.
Quick Start¶
- Import the collection into Postman
- Set the base variables (
url,anon_key,api_key,organization_id) - Run the Login endpoint with your credentials
- The JWT token is auto-saved to the
user_jwt_tokenvariable - Test any endpoint — all authentication methods are now available
For External Systems¶
Use X-API-Key endpoints:
- Search Contacts
- Search Companies
- Insert Message
For Internal Operations¶
Use JWT token endpoints:
- List Organizations
- Check Subscription
- User-specific operations
For Database Operations¶
Use REST API endpoints:
- All CRUD operations
- Complex queries with relations
See also¶
- Postman collection guide
- API key authentication
- Complete API reference
- Password reset
- Profile management
ConnectGain — omnichannel inbox, CRM & automation for WhatsApp, Messenger, Instagram, Telegram and more. Open the app · Docs home