Articles in this section

JavaScript API overview

In integrator.io, JavaScript APIs are custom HTTP endpoints that external applications can invoke to trigger flows, exports, or imports. Unlike standard integrator.io flows — where integrator.io initiates a transfer between applications — JavaScript APIs let an external application send a request to integrator.io and receive a response. Use JavaScript APIs when a third-party application needs to push data into integrator.io on demand, rather than waiting for a scheduled or event-driven flow. This article covers key concepts, how JavaScript APIs process requests, and when to use them instead of standard flows.

Key concepts

JavaScript API

A JavaScript API is a custom HTTP endpoint configured in integrator.io that accepts inbound requests from external applications and executes a script in response. Each JavaScript API has a unique endpoint URI, an associated script, and a designated entry-point function. JavaScript APIs are created and managed under Resources > APIs > JavaScript. Only account owners and administrators can create, modify, or delete JavaScript APIs.

Script

A script is the JavaScript code that runs when a request is received by the JavaScript API. The script contains at least one entry-point function, handles errors, and defines the logic for invoking exports, imports, or flows. Scripts are managed separately under Resources > Scripts and can be shared across multiple JavaScript API objects — modifying a script in one location modifies it everywhere it is used.

Entry-point function

An entry-point function is the single named function in a script that integrator.io calls when a request arrives at the JavaScript API endpoint. Only this function is initially invoked; it receives the HTTP header and body data from the inbound request. The function name must match the value entered in the Function field of the JavaScript API configuration.

Virtual resource

A virtual resource is an export or import that exists only at runtime and isn't saved to the integrator.io account. Virtual resources are defined inline within a JavaScript API script and are useful when the export or import configuration needs to vary per request rather than reference a fixed, pre-configured resource.

Bearer token

A bearer token is the authentication credential required to call a JavaScript API endpoint. Before invoking a JavaScript API, the caller must obtain a bearer token and include it in the HTTP request. The exception is JavaScript APIs configured for ShipWorks authentication, which use a username and password instead.

How a JavaScript API works

A JavaScript API works by exposing a unique HTTPS endpoint that external applications can call directly. When an external application sends an HTTP request to the endpoint, integrator.io receives the request and passes the HTTP headers and body to the entry-point function defined in the associated script. The script executes synchronously and can invoke exports, imports, or flows, then return a response to the calling application in any supported content type.

Diagram showing a bidirectional data flow in integrator.io. An external application sends an HTTP request to a JavaScript API endpoint, which triggers a script that invokes an export or import and returns a response.

Flow invocation behavior

When a JavaScript API script invokes a flow, integrator.io adds the flow to the execution queue rather than guaranteeing immediate execution. JavaScript API logs, errors, and dashboards aren't updated for flow invocations triggered this way. For export and import invocations, execution is synchronous and the result is returned in the response.

Rate limits

The integrator.io API allows approximately 1,080,000 requests per hour (enforced via a leaky-bucket algorithm with a bucket size of 1,000 and a fill rate of 300 tokens per second).

Response format

JavaScript API is the only integrator.io resource that supports returning a response in a format other than JSON. Scripts can return XML, plain text, or other content types depending on what the calling application requires.

When to use JavaScript APIs

Use JavaScript APIs when:

  • An external application needs to trigger an integrator.io export, import, or flow on demand rather than on a schedule (for example, Shopify triggering a NetSuite invoice import when an order is placed).
  • You need integrator.io to receive and respond to inbound HTTP requests synchronously, such as returning an immediate response to a Slackbot.
  • You need to return data to an external application in a format other than JSON, such as XML.
  • An on-premise or cloud application needs to pull data from a source system through integrator.io on demand (for example, ShipWorks retrieving order information from an external system).

Don't use JavaScript APIs when:

  • You need to invoke Integration apps or resources within Integration apps — JavaScript API functions can't invoke Integration App resources. Use standard flow scheduling or event-based triggers instead.
  • Your use case only requires a one-directional, scheduled data transfer between two applications — a standard integrator.io flow is simpler and provides full logging and error handling.