Articles in this section

Script API endpoints

download.svg​​ Download Postman collection

Understand and create scripts

Script API endpoints

Relative URI

Method

Success code

Description

/scripts

GET

200

Get all scripts.

POST

201

Create a script.

/scripts/<_id>

GET

200

Get a specific script.

PATCH

204

Update part of a specific script.

PUT

200

Update a specific script.

DELETE

204

Delete a specific script.

/scripts/<_id>/logs

GET

200

Get logs for a specific script.

/scripts/<_id>/dependencies

GET

200

Get all resources using or used by this script.

The following field is available to update using PATCH. You must use the following format to update the fields:

[
    {
        "op": "replace",
        "path": "/fieldname",
        "value": "newvalue"
    }
]

Field

Data type

debugUntil

date

Script API examples

Get a specific script

GET /v1/scripts/654•••••••••fd3 HTTP/1.1
Host: api.integrator.io
Authorization: Bearer my_api_token

Sample response

{
 "_id": "654•••••••••fd3",
 "lastModified": "2023-10-31T08:00:05.771Z",
 "createdAt": "2023-10-31T07:58:53.330Z",
 "name": "Test hook",
 "sandbox": false,
 "postResponseHookToProcessOnChildRecord": false,
 "content": "import { exports } from 'integrator-api'\n\nfunction runExport(options) {\n \n const output = exports.run( {_id : '64c••••••••••8ff' })\n return {\n statusCode: 200,\n headers: {},\n body:output\n }\n}"
}

Update a script

PUT /v1/scripts/654•••••••••fd3 HTTP/1.1
Host: api.integrator.io
Authorization: Bearer my_api_token

{
 "name": "Test hook",
 "sandbox": false,
 "postResponseHookToProcessOnChildRecord": false,
 "content": "import { exports } from 'integrator-api'\n\nfunction runExport(options) {\n }\n}"
}

Sample response

{
 "_id": "654•••••••••fd3",
 "lastModified": "2024-01-11T09:08:15.295Z",
 "createdAt": "2023-10-31T07:58:53.330Z",
 "name": "Test hook",
 "sandbox": false,
 "postResponseHookToProcessOnChildRecord": false
}

Get logs of a script

GET /v1/scripts/654•••••••••fd3/logs HTTP/1.1
Host: api.integrator.io
Authorization: Bearer my_api_token

Sample response

{
"logs": [
    {
     "time": "2024-01-11 09:15:56.867",
     "functionType": "preSavePage",
     "_resourceId": "64c•••••••••62b",
     "logLevel": "INFO",
     "message": "presavePage"
    }
  ]
}
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.