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:

  1. Receives customer data via webhook
  2. Uses CONNECTOR to enrich data from an external API
  3. Uses CONNECTOR to create a record in another system
  4. Returns a response

Step 1: Create API Connector

First, create a connector from an OpenAPI spec or configure manually.

Option A: Import OpenAPI Spec

  1. Go to Setup → Connectors
  2. Click + New Connector
  3. Upload or paste your OpenAPI spec
  4. Flow auto-generates operations

Option B: Configure Manually

  1. Go to Setup → Connectors
  2. Click + New Custom Connector
  3. Configure:
Field Value
Name Clearbit Enrichment
Base URL https://api.clearbit.com/v2
Category API

Add Operations

Define available API operations:

Operation: lookupPerson
Method: GET
Path: /people/find
Parameters:
  - name: email
    type: query
    required: true

Step 2: Create Connection

  1. Go to Connections
  2. Click + New Connection
  3. Select your new connector
  4. Configure authentication:
Auth Type Configuration
API Key Header: Authorization: Bearer {{ secrets.clearbit_key }}
Basic Auth Username/password
OAuth 2.0 Follow OAuth flow

Step 3: Create the Automation

  1. Go to Automations
  2. Click + New Automation
  3. Name: Customer Enrichment API
  4. Click Create

Step 4: Add Webhook Trigger

Configure Webhook

  1. Click Add Trigger
  2. Select Webhook
  3. Note your webhook URL

Expected Payload

{
  "email": "jane@acme.com",
  "source": "signup_form"
}

Step 5: Add CONNECTOR Step for API Call

Lookup Customer Data

  1. Click + below the trigger
  2. Select CONNECTOR from the step palette
  3. Name: lookupCustomer

Configure CONNECTOR

Field Value
Connector Clearbit Enrichment
Connection Your Clearbit connection
Operation lookupPerson

Set Parameters

Parameter Value
email {{ input.email }}

Step 6: Add CONDITION for Error Handling

Check API Response

  1. Click + after the CONNECTOR
  2. Select CONDITION from the step palette
  3. Name: checkSuccess

Condition Expression

{{ steps.lookupCustomer.output != null }}

Step 7: Success Path - Create Record

In the True branch:

Add CONNECTOR for CRM

  1. Select CONNECTOR step
  2. Name: createContact
  3. Configure:
Field Value
Connector HubSpot
Connection Your HubSpot connection
Operation createContact

Map Fields

Parameter Value
email {{ input.email }}
firstName {{ steps.lookupCustomer.output.name.givenName }}
lastName {{ steps.lookupCustomer.output.name.familyName }}
company {{ steps.lookupCustomer.output.employment.name }}
title {{ steps.lookupCustomer.output.employment.title }}

Step 8: Add SUCCESS Step

End the workflow successfully:

  1. Click + after createContact
  2. Select SUCCESS step
  3. 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

  1. Select ERROR step
  2. Configure:
Field Value
Message Customer enrichment failed for {{ input.email }}
Code ENRICHMENT_FAILED

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:

  1. Add LOOP step
  2. Configure:
Field Value
Iterate Over {{ input.customers }}
Item Variable customer

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

  1. Create OAuth connection for the service
  2. Select connection in CONNECTOR step
  3. Tokens refresh automatically

Best Practices


Next Steps