Skip to content

Custom Integrations

Add any REST API as a custom integration.

Configuration

In config.json

json
{
  "customIntegrations": [
    {
      "name": "myapi",
      "baseUrl": "https://api.example.com",
      "auth": {
        "type": "bearer",
        "token": "{{env.MY_API_KEY}}"
      },
      "actions": {
        "getData": {
          "method": "GET",
          "path": "/data"
        },
        "postData": {
          "method": "POST",
          "path": "/data",
          "body": "{{params}}"
        }
      }
    }
  ]
}

In integrations/ directory

Create integrations/myapi.json:

json
{
  "name": "myapi",
  "baseUrl": "https://api.example.com",
  "auth": {
    "type": "bearer",
    "token": "{{env.MY_API_KEY}}"
  },
  "actions": {
    "getUser": {
      "method": "GET",
      "path": "/users/{{params.userId}}"
    },
    "createUser": {
      "method": "POST",
      "path": "/users",
      "body": {
        "name": "{{params.name}}",
        "email": "{{params.email}}"
      }
    }
  }
}

Authentication Types

Bearer Token

json
{
  "auth": {
    "type": "bearer",
    "token": "{{env.API_KEY}}"
  }
}

Basic Auth

json
{
  "auth": {
    "type": "basic",
    "username": "{{env.API_USER}}",
    "password": "{{env.API_PASS}}"
  }
}

API Key Header

json
{
  "auth": {
    "type": "header",
    "name": "X-API-Key",
    "value": "{{env.API_KEY}}"
  }
}

Query Parameter

json
{
  "auth": {
    "type": "query",
    "name": "api_key",
    "value": "{{env.API_KEY}}"
  }
}

Action Definition

json
{
  "actions": {
    "actionName": {
      "method": "GET|POST|PUT|PATCH|DELETE",
      "path": "/endpoint/{{params.id}}",
      "headers": {
        "Custom-Header": "value"
      },
      "body": {
        "field": "{{params.field}}"
      },
      "query": {
        "filter": "{{params.filter}}"
      }
    }
  }
}

Using in Routes

json
{
  "path": "/my-endpoint",
  "method": "post",
  "integrations": [{
    "type": "myapi",
    "action": "createUser",
    "params": {
      "name": "{{body.name}}",
      "email": "{{body.email}}"
    }
  }]
}

Using in Workflows

json
{
  "id": "sync-user",
  "steps": [
    {
      "id": "create",
      "type": "integration",
      "integration": "myapi",
      "action": "createUser",
      "params": {
        "name": "{{input.name}}",
        "email": "{{input.email}}"
      }
    }
  ]
}

Full Example

json
{
  "name": "weather",
  "baseUrl": "https://api.weather.com",
  "auth": {
    "type": "query",
    "name": "appid",
    "value": "{{env.WEATHER_API_KEY}}"
  },
  "defaultHeaders": {
    "Accept": "application/json"
  },
  "actions": {
    "getCurrent": {
      "method": "GET",
      "path": "/current",
      "query": {
        "city": "{{params.city}}",
        "units": "metric"
      }
    },
    "getForecast": {
      "method": "GET",
      "path": "/forecast",
      "query": {
        "city": "{{params.city}}",
        "days": "{{params.days}}"
      }
    }
  }
}

Response Handling

Integration responses are available in:

  • Routes: Returned as response
  • Workflows: {{steps.stepId.result}}
json
{
  "id": "get-weather",
  "type": "integration",
  "integration": "weather",
  "action": "getCurrent",
  "params": { "city": "London" }
}

Access result:

json
{
  "id": "format",
  "type": "transform",
  "input": "{{steps.get-weather.result.temperature}}"
}

Released under the ISC License.