The integrator-api module exposes your account's resources to your scripts as runtime objects. Each object represents one resource type — exports, imports, flows, and so on — and provides methods to find, read, create, update, delete, and in some cases run that resource. This article is the complete method reference for all ten runtime objects.
Import the objects your script needs:
import { exports, imports, flows } from 'integrator-api'Every method throws an error if the underlying API call fails, so wrap calls in error handling where a failure shouldn't stop the script.
Warning: You can't call the create, read, update, and delete functions on runtime objects from hooks. Lookup caches are the exception: a hook script can create and manage a lookup cache and its data, as long as the lookup cache is registered with an integration. See Create and manage lookup caches.
Warning: A hook that calls an export, lookup, or import must belong to a flow inside an integration. You can't call a resource from a hook in a standalone flow. To do this, create an integration and add your flow to it.
Runtime objects at a glance
| Runtime object | Methods |
|---|---|
| Exports |
find, get, create, update, patch, delete, run, runVirtual, runVirtualWithPaging
|
| Imports |
find, get, create, update, patch, delete, run, runVirtual, runMapping
|
| Flows |
find, get, create, update, patch, delete, run
|
| Connections |
find, get, create, update, patch, delete
|
| Integrations |
get, update, delete
|
| Access tokens |
find, get, create, update, delete
|
| Async helpers |
find, get, create, update, delete
|
| File definitions |
find, get, create, update, delete
|
| State |
getKeysForResource, getForResource, putForResource, deleteForResource
|
| Lookup caches |
find, get, create, update, patch, delete, getData, putData, deleteData, purgeData
|
Conventions used across runtime objects
These behaviors are consistent across objects, so each entry describes only what is distinct about that function.
find( query ) — Returns an array of matching resources. If you call it with no query, it returns every resource of that type the script can access. The query object supports one property only: externalId, a custom value you assign when you create the resource.
get( _id ) — Returns the resource, or undefined if no resource has that ID. To find an ID, see Retrieve the resource ID.
create( resource ) and update( resource ) — Take the full resource object and return the created or updated resource.
delete( _id ) — Deletes the resource and returns undefined.
Exceptions — Every method throws an error if the API call fails.
Important: patch is always an array of JSON Patch operations, each with op, path, and value. A single object of fields and values fails with invalid patch data. Each object accepts a limited, resource-specific set of whitelisted paths; patching anything else throws an error naming the path, such as /name is not a whitelisted property. patch() returns undefined on success, so call get() when you need to read the result.
imports.patch({
_id: importId,
patch: [{ op: 'replace', path: '/debugUntil', value: '2026-11-16T17:31:40.205Z' }]
})Exports
The exports object represents the exports in your account.
exports.find( query )
Finds all exports matching the query.
Argument query <Object> |
Key-value pairs representing your search criteria. externalId is the only supported property. |
| Returns <Array> | An array of exports. |
exports.get( _id )
Returns the export with the given ID.
Argument _id <String, required> |
The ID of the export. |
| Returns <Object | Undefined> | The export, or undefined. |
exports.create( export )
Creates an export.
Argument export <Object, required> |
The export to create. |
| Returns <Object> | The new export. |
exports.update( export )
Updates an export.
Argument export <Object, required> |
The updated export to save. |
| Returns <Object> | The updated export. |
exports.patch( options )
Updates only the properties you specify, leaving the rest of the export unchanged.
Argument options <Object, required> |
_id <String, required> — the ID of the export to patch.patch <Array<Object>, required> — the operations to apply, each with op, path, and value. |
| Returns <Undefined> | Call get() to read the updated export. |
exports.delete( _id )
Deletes the export with the given ID.
Argument _id <String, required> |
The ID of the export to delete. |
| Returns <Undefined> |
exports.run( options )
Runs an export that exists in your account.
Argument options <Object, required> |
_id <String, required> — the ID of the export to run.startDate <Date> — start of the window for delta exports.endDate <Date> — end of the window for delta exports.data <Array | Object> — data to pass to the export.settings <Object> — settings to pass to the export.listenerData <Array> — data to pass to an integrator.io application-type webhook listener. |
| Returns <Object> |
data <Array> — the exported data. This returns the first page of records only; use exports.runVirtualWithPaging() to retrieve more.dataURIs <Array> — matching URI array, depending on the export's configuration.errors <Array> — any errors the export returned. |
Warning: Passing a webhook alias in exports.run isn't supported.
To pass a value from your script into the export itself, use exports.runVirtual() instead of listenerData.
Pass data and settings like this:
exports.run({ _id: '5f4••••••••••••••••••d34', data: myData, settings: expSettings })Reference that data inside the export with handlebars. The syntax depends on the application:
- NetSuite — array:
{{[0].id}}; object:{{id}} - All others — array:
{{data.[0].id}}; object:{{data.id}}
Example: pass data to a webhook listener
import { exports } from 'integrator-api'
function main (options) {
const myData = [{
name: 'Celigo customer',
email: 'celigocustomer@celigo.com'
}]
return {
statusCode: 200,
body: {
response: exports.run({ _id: '5f4••••••••••••••••••d34', listenerData: myData })
}
}
}exports.runVirtual( options )
Runs a virtual export — one your script defines inline and that isn't saved to your account. It still runs against a real connection. See Real and virtual resources in scripts.
Argument options <Object, required> |
export <Object, required> — the virtual export definition to run.startDate <Date> — start of the window for delta exports.endDate <Date> — end of the window for delta exports.data <Object> — data to send to the export. |
| Returns <Object> |
data <Array> — the exported data.dataURIs <Array> — matching URI array, depending on the virtual export's configuration.errors <Array> — any errors the export returned. |
For a worked example, see Populate a form field from a connector using a virtual export.
exports.runVirtualWithPaging( options )
Runs a virtual export and returns one page of data per call. Use it when the result set is larger than a single page.
Argument options <Object, required> |
export <Object, required> — the virtual export definition to run.pagedExportState <Object> — the state object returned by the previous call to this function. Pass it back unchanged.startDate <Date> — start of the window for delta exports.endDate <Date> — end of the window for delta exports. |
| Returns <Object> |
data <Array> — the exported data for this page.dataURIs <Array> — matching URI array, depending on the virtual export's configuration.pagedExportState <Array> — the state object to pass to the next call.errors <Array> — any errors the export returned. |
To page through a full result set, call the function in a loop, passing the pagedExportState you received back on each subsequent call.
Imports
The imports object represents the imports in your account.
imports.find( query )
Finds all imports matching the query.
Argument query <Object> |
Key-value pairs representing your search criteria. externalId is the only supported property. |
| Returns <Array> | An array of imports. |
imports.get( _id )
Returns the import with the given ID.
Argument _id <String, required> |
The ID of the import. |
| Returns <Object | Undefined> | The import, or undefined. |
imports.create( import )
Creates an import.
Argument import <Object, required> |
The import to create. |
| Returns <Object> | The new import. |
imports.update( import )
Updates an import.
Argument import <Object, required> |
The updated import to save. |
| Returns <Object> | The updated import. |
imports.patch( options )
Updates only the properties you specify, leaving the rest of the import unchanged.
Argument options <Object, required> |
_id <String, required> — the ID of the import to patch.patch <Array<Object>, required> — the operations to apply, each with op, path, and value. |
| Returns <Undefined> | Call get() to read the updated import. |
imports.delete( _id )
Deletes the import with the given ID.
Argument _id <String, required> |
The ID of the import to delete. |
| Returns <Undefined> |
imports.run( options )
Runs an import that exists in your account.
Argument options <Object, required> |
_id <String, required> — the ID of the import to run.data <Array, required> — the data to import.settings <Object> — settings to pass to the import. |
| Returns <Array> | One entry per record, each containing:statusCode <Integer> — 200 (success), 422 (error), or 401 (connection is offline).ignored <Boolean> — true if the import ignored the record, depending on its configuration.errors <Array> — the errors the import returned._json <Object> — the raw response from the destination application. |
Pass data and settings like this:
imports.run({ _id: '6f7••••••••••••••••••e46', data: myData, settings: impSettings })Reference that data inside the import with handlebars. The syntax depends on the application:
- NetSuite — array:
{{[0].id}}; object:{{id}} - All others — array:
{{data.[0].id}}; object:{{data.id}}
imports.runVirtual( options )
Runs a virtual import — one your script defines inline and that isn't saved to your account. It still runs against a real connection.
Argument options <Object, required> |
import <Object, required> — the virtual import definition to run.data <Array, required> — the data to import. |
| Returns <Array> | One entry per record, each containing:statusCode <Integer> — 200 (success), 422 (error), or 401 (connection is offline).ignored <Boolean> — true if the import ignored the record, depending on its configuration.errors <Array> — the errors the import returned._json <Object> — the response from the destination application. |
imports.runMapping( options )
Applies only the mapping instructions in a virtual import and returns the mapped data. It doesn't send anything to the destination application.
Argument options <Object, required> |
import <Object, required> — the virtual import definition containing the mapping instructions.data <Array, required> — the data to map. |
| Returns <Array> | One entry per record, each containing:statusCode <Integer> — 200 (success), 422 (error), or 401 (connection is offline).data <Object> — the mapped data.errors <Array> — the mapping errors the import returned. |
Flows
The flows object represents the flows in your account.
flows.find( query )
Finds all flows matching the query.
Argument query <Object> |
Key-value pairs representing your search criteria. externalId is the only supported property. |
| Returns <Array> | An array of flows. |
flows.get( _id )
Returns the flow with the given ID.
Argument _id <String, required> |
The ID of the flow. |
| Returns <Object | Undefined> | The flow, or undefined. |
flows.create( flow )
Creates a flow.
Argument flow <Object, required> |
The flow to create. |
| Returns <Object> | The new flow. |
flows.update( flow )
Updates a flow.
Argument flow <Object, required> |
The updated flow to save. |
| Returns <Object> | The updated flow. |
flows.patch( options )
Updates only the properties you specify, leaving the rest of the flow unchanged.
Argument options <Object, required> |
_id <String, required> — the ID of the flow to patch.patch <Array<Object>, required> — the operations to apply, each with op, path, and value. |
| Returns <Undefined> | Call get() to read the updated flow. |
flows.delete( _id )
Deletes the flow with the given ID.
Argument _id <String, required> |
The ID of the flow to delete. |
| Returns <Undefined> |
flows.run( options )
Runs the flow with the given ID.
Argument options <Object, required> |
_id <String, required> — the ID of the flow to run.startDate <Date> — start of the window for delta exports.endDate <Date> — end of the window for delta exports. |
| Returns <Object> | The flow run status. |
Connections
The connections object represents the connections in your account.
connections.find( query )
Finds all connections matching the query.
Argument query <Object> |
Key-value pairs representing your search criteria. externalId is the only supported property. |
| Returns <Array> | An array of connections. |
connections.get( _id )
Returns the connection with the given ID.
Argument _id <String, required> |
The ID of the connection. |
| Returns <Object | Undefined> | The connection, or undefined. |
connections.create( connection )
Creates a connection.
Argument connection <Object, required> |
The connection to create. |
| Returns <Object> | The new connection. |
connections.update( connection )
Updates a connection.
Argument connection <Object, required> |
The updated connection to save. |
| Returns <Object> | The updated connection. |
connections.patch( options )
Updates only the properties you specify, leaving the rest of the connection unchanged.
Argument options <Object, required> |
_id <String, required> — the ID of the connection to patch.patch <Array<Object>, required> — the operations to apply, each with op, path, and value. |
| Returns <Undefined> | Call get() to read the updated connection. |
connections.delete( _id )
Deletes the connection with the given ID.
Argument _id <String, required> |
The ID of the connection to delete. |
| Returns <Undefined> |
Integrations
The integrations object lets you read, update, or delete an integration in your account. It doesn't provide find() or create() — you can retrieve an integration only by its ID, and you create integrations in the UI.
integrations.get( _id )
Returns the integration with the given ID.
Argument _id <String, required> |
The ID of the integration. |
| Returns <Object | Undefined> | The integration, or undefined. |
integrations.update( integration )
Updates an integration.
Argument integration <Object, required> |
The updated integration to save. |
| Returns <Object> | The updated integration. |
integrations.delete( _id )
Deletes the integration with the given ID.
Argument _id <String, required> |
The ID of the integration to delete. |
| Returns <Undefined> |
Access tokens
The accessTokens object represents the access tokens in your account.
accessTokens.find( query )
Finds all access tokens matching the query.
Argument query <Object> |
Key-value pairs representing your search criteria. externalId is the only supported property. |
| Returns <Array> | An array of access tokens. |
accessTokens.get( _id )
Returns the access token with the given ID.
Argument _id <String, required> |
The ID of the access token. |
| Returns <Object | Undefined> | The access token, or undefined. |
accessTokens.create( accessToken )
Creates an access token.
Argument accessToken <Object, required> |
The access token to create. |
| Returns <Object> | The new access token. |
accessTokens.update( accessToken )
Updates an access token.
Argument accessToken <Object, required> |
The updated access token to save. |
| Returns <Object> | The updated access token. |
accessTokens.delete( _id )
Deletes the access token with the given ID.
Argument _id <String, required> |
The ID of the access token to delete. |
| Returns <Undefined> |
Async helpers
The asyncHelpers object represents the async helpers in your account. An async helper polls an asynchronous API at intervals until a long-running request finishes.
asyncHelpers.find( query )
Finds all async helpers matching the query.
Argument query <Object> |
Key-value pairs representing your search criteria. externalId is the only supported property. |
| Returns <Array> | An array of async helpers. |
asyncHelpers.get( _id )
Returns the async helper with the given ID.
Argument _id <String, required> |
The ID of the async helper. |
| Returns <Object | Undefined> | The async helper, or undefined. |
asyncHelpers.create( asyncHelper )
Creates an async helper.
Argument asyncHelper <Object, required> |
The async helper to create. |
| Returns <Object> | The new async helper. |
asyncHelpers.update( asyncHelper )
Updates an async helper.
Argument asyncHelper <Object, required> |
The updated async helper to save. |
| Returns <Object> | The updated async helper. |
asyncHelpers.delete( _id )
Deletes the async helper with the given ID.
Argument _id <String, required> |
The ID of the async helper to delete. |
| Returns <Undefined> |
File definitions
A file definition tells integrator.io how to parse an EDI template. The fileDefinitions object represents the file definitions in your account.
fileDefinitions.find( query )
Finds all file definitions matching the query.
Argument query <Object> |
Key-value pairs representing your search criteria. externalId is the only supported property. |
| Returns <Array> | An array of file definitions. |
fileDefinitions.get( _id )
Returns the file definition with the given ID.
Argument _id <String, required> |
The ID of the file definition. |
| Returns <Object | Undefined> | The file definition, or undefined. |
fileDefinitions.create( fileDefinition )
Creates a file definition.
Argument fileDefinition <Object, required> |
The file definition to create. |
| Returns <Object> | The new file definition. |
fileDefinitions.update( fileDefinition )
Updates a file definition.
Argument fileDefinition <Object, required> |
The updated file definition to save. |
| Returns <Object> | The updated file definition. |
fileDefinitions.delete( _id )
Deletes the file definition with the given ID.
Argument _id <String, required> |
The ID of the file definition to delete. |
| Returns <Undefined> |
State
The state object stores a JSON value against a resource. Write a value during one part of your processing and read it later — for example, to track where a long-running job left off, or to pass a value between runs.
All four methods take a resourceType of integrations, imports, or exports. Flows and connections aren't supported; a call with either fails with State not available for the given model.
These limits apply to all four methods:
- The resource has to belong to the integration the script runs in. Otherwise the call fails with
export: <id> doesn't belong to this integration. - One resource holds at most 10 keys. An eleventh new key fails with
Cannot save state, allowed number of states already reached for export: <id>; updating an existing key still works. - The value has to be a non-empty object or array. A string, number, boolean,
null,{}, or[]is refused. -
state.getForResourceandstate.deleteForResourcethrowState not found for key.when the key doesn't exist; they don't returnundefined, so catch the error on a script's first run. -
state.getKeysForResourcereturns{ keys: [...] }, or an empty string when the resource has no keys yet. - Keys can contain letters, digits, and
_ -.: & + =. A space, a slash,?,#,%, quotes, braces, or non-ASCII characters fail (for example,Invalid uri).
state.getKeysForResource( options )
Retrieves all keys stored against a resource.
Argument options <Object, required> |
resourceType <String, required> — integrations, imports, or exports._id <String, required> — the ID of the resource. |
| Returns <Object> | All keys stored against the resource. |
state.getForResource( options )
Retrieves the value stored against one key.
Argument options <Object, required> |
resourceType <String, required> — integrations, imports, or exports._id <String, required> — the ID of the resource.key <String, required> — the key to retrieve. |
| Returns <Object> | The value stored against the key. |
state.putForResource( options )
Sets the value for a key.
Argument options <Object, required> |
resourceType <String, required> — integrations, imports, or exports._id <String, required> — the ID of the resource.key <String, required> — the key to update.value <Object> — the value to store. |
| Returns <Undefined> |
state.deleteForResource( options )
Deletes a key and its value.
Argument options <Object, required> |
resourceType <String, required> — integrations, imports, or exports._id <String, required> — the ID of the resource.key <String, required> — the key to delete. |
| Returns <Undefined> |
Lookup caches
The lookupcaches object represents the lookup caches in your account. A lookup cache stores reusable key-value data for fast retrieval across flows. See Create and manage lookup caches.
Tip: Register the lookup cache with an integration before you reference or edit its data from a script hook. See Register lookup caches and create aliases.
lookupcaches.find( query )
Finds all lookup caches matching the query.
Argument query <Object> |
Key-value pairs representing your search criteria. externalId is the only supported property — for example, { externalId: 'testLookup' }. |
| Returns <Array> | An array of lookup caches. |
import { lookupcaches } from 'integrator-api'
function handleRequest (options) {
const lcacheFind = lookupcaches.find()
return {
statusCode: 200,
headers: { },
body: [lcacheFind]
}
}lookupcaches.get( _id )
Returns the lookup cache with the given ID.
Argument _id <String, required> |
The ID of the lookup cache to retrieve. |
| Returns <Object | Undefined> | The lookup cache's high-level fields, or undefined. |
import { lookupcaches } from 'integrator-api'
function handleRequest (options) {
const lcache = lookupcaches.get('67b••••••••••f2b')
return {
statusCode: 200,
headers: { },
body: lcache
}
}lookupcaches.create( cache )
Creates a lookup cache.
Argument cache <Object, required> |
The lookup cache to create. |
| Returns <Object> | The new lookup cache. |
import { lookupcaches } from 'integrator-api'
function handleRequest (options) {
const lookupcachesBody = {
name: 'lookupcache1',
description: 'This is a test lookup cache 1',
includeDataInTemplatesAndCloning: true
}
const lcache = lookupcaches.create(lookupcachesBody)
return {
statusCode: 200,
headers: { },
body: lcache
}
}lookupcaches.update( cache )
Updates a lookup cache.
Argument cache <Object, required> |
The lookup cache to update. |
| Returns <Object> | The updated lookup cache. |
import { lookupcaches } from 'integrator-api'
function handleRequest (options) {
const lookupcachesUpdateBody = {
_id: '67b••••••••f2b',
name: 'lookupcacheUpdated'
}
const lcache = lookupcaches.update(lookupcachesUpdateBody)
return { statusCode: 200, body: lcache }
}lookupcaches.patch( options )
Updates specific fields and values in a lookup cache.
Argument options <Object, required> |
_id <String, required> — the ID of the lookup cache to patch.patch <Array<Object>, required> — the operations to apply, each with op, path, and value. |
| Returns <Undefined> | Call get() to read the updated lookup cache. |
For example, to rename a lookup cache:
import { lookupcaches } from 'integrator-api'
function handleRequest (options) {
const _id = '67b•••••••f2b'
lookupcaches.patch({
_id,
patch: [{
op: 'replace',
path: '/name',
value: 'PatchedName'
}]
})
/* patch() returns undefined, so read the cache back to see the change */
const lcache = lookupcaches.get(_id)
return {
statusCode: 200,
headers: { },
body: [lcache]
}
}lookupcaches.delete( _id )
Deletes the lookup cache with the given ID.
Argument _id <String, required> |
The ID of the lookup cache to delete. |
| Returns <Undefined> |
import { lookupcaches } from 'integrator-api'
function handleRequest (options) {
const lcache = lookupcaches.delete('67d•••••••••875')
return {
statusCode: 200,
body: [lcache],
errors: options.errors
}
}lookupcaches.getData( options )
Retrieves data from a lookup cache.
Argument options <Object, required> |
_id <String, required> — the ID of the lookup cache.keys <Array, optional> — the keys to retrieve.nextPageURL <String, optional> — the URL returned in the previous response.pageSize <String, optional> — the page size. Supported only when you don't provide keys. |
| Returns <Object> | The keys and values. nextPageURL is returned as /v1/lookupcaches/:lookUpCache/getData?startAfterKey=<key>. |
import { lookupcaches } from 'integrator-api'
function preSavePage (options) {
const getDataPayload = {
_id: '67b••••••••••••f2b'
// keys: ['key1','key2']
}
const lcache = lookupcaches.getData(getDataPayload)
return {
statusCode: 200,
body: lcache
}
}lookupcaches.putData( options )
Creates or updates data in a lookup cache.
Argument options <Object, required> |
_id <String, required> — the ID of the lookup cache.data <Array<Object>, required> — the keys and values to write. |
| Returns <Array> | Each key with its success status and any errors. |
import { lookupcaches } from 'integrator-api'
function preSavePage (options) {
const putDataPayload = {
_id: '67b•••••••••••f2b',
data: [
{ key: 'key1', value: { value1: 123, value2: 'val' } },
{ key: 'key2', value: { value1: 124, value2: 'val' } }
]
}
const lcache = lookupcaches.putData(putDataPayload)
return {
body: lcache
}
}lookupcaches.deleteData( options )
Deletes specific keys from a lookup cache.
Argument options <Object, required> |
_id <String, required> — the ID of the lookup cache.keys <Array, required> — the keys to delete. |
| Returns <Array> | Each key with its success status. |
import { lookupcaches } from 'integrator-api'
function preSavePage (options) {
const deleteDataPayload = {
_id: '67b•••••••••••••••••f2b',
keys: ['key1', 'key2']
}
const lcache = lookupcaches.deleteData(deleteDataPayload)
return {
statusCode: 200,
body: lcache
}
}lookupcaches.purgeData( options )
Deletes all data in a lookup cache. The cache itself remains.
Argument options <Object, required> |
_id <String, required> — the ID of the lookup cache. |
| Returns <Undefined> |
import { lookupcaches } from 'integrator-api'
function preSavePage (options) {
const purgeDataPayload = { _id: '67b••••••••••••803' }
const lcache = lookupcaches.purgeData(purgeDataPayload)
return {
statusCode: 200,
headers: { },
body: [lcache]
}
}