Articles in this section

Build an export definition for a script

To create an export or run a virtual export from a script, you need a JSON export definition — the same object the integrator.io REST API returns. The quickest way to build one is to configure the export once in the UI, retrieve its JSON through the API, and remove the fields the platform manages.

This article covers that workflow. For the field-by-field schema — every property, its type, and whether it's required — see the Export schema on the Celigo Developer Platform.

Prerequisites:

  • An export that already exists in your account. If you don't have one, create it in the UI first.
  • An API token with permission for that export. See Authentication.
  • An API testing tool such as Postman.

Get the export's ID

Open the export in integrator.io and copy its ID from the address bar. For the full procedure, see Retrieve the resource ID.

IDs in this article are masked — 5c6••••••••••••••••••3fb. Yours are full-length strings.

Request the export definition

Send a GET request to the exports endpoint, replacing my_api_token with your token and the ID with your own:

GET /v1/exports/5c6••••••••••••••••••3fb HTTP/1.1
Host: api.integrator.io
Authorization: Bearer my_api_token

The response is the complete export object. For a NetSuite export that retrieves invoices above a given amount, it looks like this:

{
  "_id": "5ea••••••••••••••••••06f",
  "createdAt": "2020-05-01T23:54:24.116Z",
  "lastModified": "2020-08-11T22:05:31.240Z",
  "name": "Get NetSuite invoices that are above x amount (invoked by JavaScript API)",
  "description": "Get all invoices from NetSuite",
  "_connectionId": "5e9••••••••••••••••••6e0",
  "apiIdentifier": "e7d2a66a3d",
  "asynchronous": true,
  "pageSize": 3,
  "_templateId": "5c3••••••••••••••••••8f1",
  "rawData": "5d9d2••••••••••••••••••2e42d",
  "netsuite": {
    "type": "restlet",
    "skipGrouping": true,
    "statsOnly": false,
    "restlet": {
      "recordType": "invoice",
      "searchId": "6763",
      "criteria": [
        {
          "field": "amount",
          "operator": "greaterthan",
          "searchValue": "15000"
        }
      ]
    },
    "distributed": {
      "disabled": false,
      "forceReload": false,
      "executionContext": ["userinterface", "webstore"],
      "executionType": ["create", "edit", "xedit"]
    }
  },
  "adaptorType": "NetSuiteExport"
}

Remove the read-only fields

The response includes fields the platform generates and maintains. The Export schema marks these readOnly, and the API ignores them when you create an export or run a virtual one. In the response above, that means _id, createdAt, lastModified, apiIdentifier, asynchronous, _templateId, and rawData.

What's left is the configuration you pass to your script:

{
  "_connectionId": "5e9••••••••••••••••••6e0",
  "adaptorType": "NetSuiteExport",
  "netsuite": {
    "type": "restlet",
    "skipGrouping": true,
    "statsOnly": false,
    "restlet": {
      "recordType": "invoice",
      "searchId": "6763",
      "criteria": [
        {
          "field": "amount",
          "operator": "greaterthan",
          "searchValue": "<replace with amount>"
        }
      ]
    },
    "distributed": {
      "disabled": false,
      "forceReload": false,
      "executionContext": ["userinterface", "webstore"],
      "executionType": ["create", "edit", "xedit"]
    }
  }
}

Tip: The search criteria shown here is specific to this example. Not every export needs criteria.

Two fields decide the shape of everything else. adaptorType selects the adaptor, and the adaptor-specific object that goes with it carries the configuration — netsuite here, salesforce for a Salesforce export, http for an HTTP export. _connectionId names the connection to run against, and is required except on export types that receive data rather than fetch it. The schema lists every supported adaptorType value and the object each one expects.

Use the definition in a script

Pass the object as the export property of exports.runVirtual(), or as the argument to exports.create(). See integrator.io API and JavaScript runtime objects.

Apply this to other resources

The same workflow builds a definition for any resource type: configure it in the UI, GET it from its endpoint, and drop the read-only fields. Imports work identically — see the Import schema and the imports.runVirtual( options ) entry in integrator.io API and JavaScript runtime objects.