REST API Integration
Connect to REST APIs using CONNECTOR steps for powerful integrations.
Time
Level
Prerequisites
25 minutes
Intermediate
Basic understanding of HTTP and JSON
What You'll Build
An automation that:
- Receives customer data via webhook
- Uses CONNECTOR to enrich data from an external API
- Uses CONNECTOR to create a record in another system
- Returns a response
Step 1: Create API Connector
First, create a connector from an OpenAPI spec or configure manually.
Option A: Import OpenAPI Spec
- Go to Setup → Connectors
- Click + New Connector
- Upload or paste your OpenAPI spec
- Flow auto-generates operations
Option B: Configure Manually
- Go to Setup → Connectors
- Click + New Custom Connector
- Configure:
Add Operations
Define available API operations:
Operation: lookupPerson
Method: GET
Path: /people/find
Parameters:
- name: email
type: query
required: true
Step 2: Create Connection
- Go to Connections
- Click + New Connection
- Select your new connector
- Configure authentication:
Step 3: Create the Automation
- Go to Automations
- Click + New Automation
- Name:
Customer Enrichment API - Click Create
Step 4: Add Webhook Trigger
Configure Webhook
- Click Add Trigger
- Select Webhook
- Note your webhook URL
Expected Payload
{
"email": "jane@acme.com",
"source": "signup_form"
}
Step 5: Add CONNECTOR Step for API Call
Lookup Customer Data
- Click + below the trigger
- Select CONNECTOR from the step palette
- Name:
lookupCustomer
Configure CONNECTOR
Set Parameters
Step 6: Add CONDITION for Error Handling
Check API Response
- Click + after the CONNECTOR
- Select CONDITION from the step palette
- Name:
checkSuccess
Condition Expression
{{ steps.lookupCustomer.output != null }}
Step 7: Success Path - Create Record
In the True branch:
Add CONNECTOR for CRM
- Select CONNECTOR step
- Name:
createContact - Configure:
Map Fields
Step 8: Add SUCCESS Step
End the workflow successfully:
- Click + after createContact
- Select SUCCESS step
- Configure output:
{
"success": true,
"contact_id": "{{ steps.createContact.output.id }}",
"enriched": true
}
Step 9: Error Path
In the False branch of the CONDITION:
Add ERROR Step
- Select ERROR step
- Configure:
Complete Workflow
┌───────────────────────┐
│ Webhook Trigger │
│ (Receive customer) │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ CONNECTOR │
│ lookupCustomer │
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ CONDITION │
│ checkSuccess │
├───────────┬───────────┤
│ True │ False │
└─────┬─────┴─────┬─────┘
│ │
▼ ▼
┌───────────┐ ┌─────────┐
│ CONNECTOR │ │ ERROR │
│ createCRM │ │ │
└─────┬─────┘ └─────────┘
│
▼
┌───────────┐
│ SUCCESS │
└───────────┘
Working with LOOP for Batch Operations
Process Multiple Items
For batch API calls, use LOOP:
- Add LOOP step
- Configure:
Inside the loop, add CONNECTOR:
LOOP EACH customer IN input.customers
│
├── CONNECTOR: lookupCustomer
│ email: {{ customer.email }}
│
├── CONNECTOR: createContact
│ ...
│
└── Continue to next
Using FUNCTION for Complex Logic
Transform API Response
Add a FUNCTION step after the API call:
// Access the API response
const lookup = context.step.lookupCustomer.output;
// Transform the data
const contact = {
fullName: `${lookup.name.givenName} ${lookup.name.familyName}`,
company: lookup.employment?.name || 'Unknown',
title: lookup.employment?.title || 'Unknown',
linkedin: lookup.linkedin?.handle,
location: `${lookup.geo?.city}, ${lookup.geo?.country}`
};
// Add scoring
contact.score = lookup.employment?.domain ? 'high' : 'low';
return contact;
Authentication Patterns
API Key in Header
Configure in connection:
Header: X-API-Key: {{ secrets.api_key }}
Bearer Token
Configure in connection:
Header: Authorization: Bearer {{ secrets.access_token }}
OAuth 2.0
- Create OAuth connection for the service
- Select connection in CONNECTOR step
- Tokens refresh automatically
Best Practices
Do
- Store API keys in Secrets
- Use connections for authentication
- Handle errors with CONDITION
- Log important data for debugging
- Use FUNCTION for complex transformations
Avoid
- Hardcoding credentials in steps
- Ignoring API errors
- Making unnecessary API calls
- Skipping error handling branches
Next Steps
- Slack Notifications → — Send results to Slack
- Scheduled Reports → — Run integrations on schedule