Use this file to discover all available pages before exploring further.
Endpoint Alias: You can also use /api/v1/records/bulk instead of /api/v1/leads/bulk. Both endpoints are functionally identical - use whichever naming convention fits your integration.
import csvimport requestsimport timedef import_leads_from_csv(file_path, campaign_id, api_key, mode='standard'): """ Import leads from CSV file in batches Args: file_path: Path to CSV file campaign_id: Campaign ID to import to api_key: Your API key mode: 'standard' (phone required) or 'prefetch' (externalId only) """ batch_size = 500 leads = [] with open(file_path, 'r') as file: reader = csv.DictReader(file) for row in reader: lead = {} # Always include externalId if available if row.get('id') or row.get('external_id'): lead['externalId'] = row.get('id') or row.get('external_id') # Include phone number if available (required for standard mode) if row.get('phone'): lead['phoneNumber'] = row['phone'] # Add metadata lead['metadata'] = { 'name': row.get('name', ''), 'company': row.get('company', '') } if row.get('priority'): lead['priority'] = int(row['priority']) leads.append(lead) # Send batch when we hit the limit if len(leads) >= batch_size: send_batch(leads, campaign_id, api_key) leads = [] time.sleep(6) # Rate limit: 10/min = 1 every 6 sec # Send remaining leads if leads: send_batch(leads, campaign_id, api_key)def send_batch(leads, campaign_id, api_key): """Send a batch of leads to the API""" response = requests.post( 'https://YOUR_DEPLOYMENT.lupitor.com/api/v1/leads/bulk', headers={ 'x-api-key': api_key, 'Content-Type': 'application/json' }, json={ 'campaignId': campaign_id, 'leads': leads } ) result = response.json() if result['success']: print(f"Created: {result['data']['created']}, Skipped: {result['data']['skipped']}") else: print(f"Error: {result['error']}")# Usage - Standard mode (CSV has phone numbers)import_leads_from_csv( 'leads_with_phones.csv', 'YOUR_CAMPAIGN_ID', 'YOUR_API_KEY', mode='standard')# Usage - Prefetch mode (CSV has only external IDs)import_leads_from_csv( 'leads_external_ids.csv', 'YOUR_CAMPAIGN_ID', 'YOUR_API_KEY', mode='prefetch')