How to use the Passthrough API


November 25, 2024

This guide shows you how to make requests using Unified.to's Passthrough API with practical examples.

Before you begin

You should have:

  • At least one active connection for an integration
  • The connection ID for the integration you want to access

Making Passthrough requests

The following examples demonstrate calls to mock endpoints with the Passthrough API.

Using the REST API directly

// GET request example
const response = await fetch('https://api.unified.to/passthrough/{connection_id}/v2/customers', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
});

// POST request example
const response = await fetch('https://api.unified.to/passthrough/{connection_id}/v2/customers', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'John Doe',
    email: 'john@example.com'
  })
});

Using the Unified.to SDK

// GET request
const response = await unified.passthrough.listPassthroughs({
  connectionId: 'YOUR_CONNECTION_ID',
  path: '/v2/customers'
});

// POST request
const response = await unified.passthrough.createPassthrough({
  connectionId: 'YOUR_CONNECTION_ID',
  path: '/v2/customers',
  data: {
    name: 'John Doe',
    email: 'john@example.com'
  }
});

// With custom headers
const response = await unified.passthrough.listPassthroughs(
  {
    connectionId: 'YOUR_CONNECTION_ID',
    path: '/v2/customers'
  },
  {
    fetchOptions: {
      headers: {
        'x-api-version': '2023-06-01'
      }
    }
  }
);

Real-world examples

Example 1: Fetching HubSpot properties

This example demonstrates how to fetch custom properties for HubSpot contacts.

const response = await unified.passthrough.listPassthroughs({
  connectionId: HUBSPOT_CONNECTION_ID,
  path: '/crm/v3/properties/{objectType}/batch/read'
});

// Response will contain raw HubSpot property definitions
console.log(response.data);

API reference: Hubspot CRM Properties

Example 2: Creating a Slack channel

This example demonstrates creating a channel in Slack.

// Create a private Slack channel
const response = await unified.passthrough.createPassthrough({
  connectionId: SLACK_CONNECTION_ID,
  path: '/conversations.create',
  data: {
    name: 'project-discussion',
    is_private: true
  }
});

// Check the response
if (response.data.ok) {
  console.log('Channel created:', response.data.channel.id);
}

API reference: conversations.create

Example 3: Creating a Salesforce record

This example demonstrates two ways of creating a new Account record in Salesforce using their sObject API.

// Using the SDK
const response = await unified.passthrough.createPassthrough({
  connectionId: SALESFORCE_CONNECTION_ID,
// Note: path starts with 'services/data/v62.0' as required by Salesforce
  path: 'services/data/v62.0/sobjects/Account/',
  data: {
    "Name": "Express Logistics and Transport"
  }
});


const response = await fetch('https://api.unified.to/passthrough/{connection_id}/services/data/v62.0/sobjects/Account/', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_UNIFIED_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "Name": "Express Logistics and Transport"
  })
});

// The response will contain the new record ID if successful:
// {
//   "id": "001D000000IqhSLIAZ",
//   "errors": [],
//   "success": true
// }

API reference: Create a Record

See also

Are we missing anything? Let us know
Was this page helpful?