You are on page 1of 37

Webhook Bots

Eliminate time-consuming tasks and reduce human errors by transferring information to the
third-party systems you need. Keep all the information up-to-date with airSlate's no-code
webhook Bots.
2

Table of Contents
Send Webhook upon Documents Opening Bot 3
Installation 3
Response body parameters 7
Webhook response 8
Webhook requests 9
Fetch 9
Subscription 10
Delete 12
Statistics 13
Code examples 14
PHP code 14
Node.js code 15

Send Webhook upon Slate Completion Bot 17


Installation 17
Response body 20
Webhook response 22
Webhook requests 23
Fetch 23
Subscription 23
Delete 25
Statistics 25
Code Examples 27
PHP code 27
Node.js code 28

Create Slate from External Event 29


Installation 30
Slate creation 34
Code Examples 35
PHP code 35
Node.js code 36

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
3

Send Webhook upon Documents Opening Bot


Install and configure the Bot to send a webhook when a contract, invoice, or other document is opened. The
Bot gathers data, formats it in .JSON format, and transfers it to the selected URL based on the ‘if-this-then-that’
conditions you set.

Installation

1. Find the Send Webhook upon Slate Opening Bot and click the Install Bot button to add the Bot to your
Flow.

2. In your Postman account (or any other console), copy the Authorization token from the infobox and
paste it as the Authorization header value.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
4

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
5

🗒 Note: The slate_addons will have a single token within different Flow versions. Using this token,
users will be able to access the data from all slate_addons and different Flow versions.
The Bot operates within versioning. If the versioning doesn’t display, it means that your Flow only has
one version by default that is always up to date. Versioning will become available right after you create
another Flow version.

3. Configure the Bot execution conditions and Advanced settings as needed. Press Apply setup when
finished.

4. Send a POST request to subscribe for Slate opening events.

POST https://hostname/webhook-bot/v2/subscription
Headers: Authorization: {authorization_token}
Request body:
{
"data" : {
"type" : "subscriptions",

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
6

"attributes": {
"callback_url" : "callback_url"
}
}
}
Hostname:

bots.airslate.com — the hostname that should be used in subsequent requests instead of the {hostname}
placeholder for US-based services.

Example:
POST https://bots.airslate.com/webhook-bot/v2/subscription

bots.airslate-au.com — the hostname that should be used in subsequent requests instead of the {hostname}
placeholder for AU-based services.

Example: POST https://bots.airslate-au.com/webhook-bot/v2/subscription

callback_url — the service URL that will receive a webhook.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
7

Response body parameters

Example of response body:

{
"data": {
"type": "subscriptions",
"id": "A88CB620-0000-0000-00002D5D",
"attributes": {
"callback_url": "https://automation.pdffillers.com/report/whprefill"
},
"relationships": {
"slates": {
"data": {
"type": "slates",
"id": "B2D12859-9300-0000-0000BA29"
}
},
"slate_addons": {
"data": {
"type": "slate_addons",
"id": "51131C22-A700-0000-000093F0"
}
},
"flow_revisions": {
"data": {
"type": "flow_revisions",
"id": "6602784C-9300-0000-000049B7"
}
}
}

data.id the unique subscription identifier.

slates.data.type the ‘slates’ value of this attribute means that the


slates.data object describes the attributes of a
particular Flow.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
8

slates.data.id the unique Flow identifier. As a Bot user, you are


subscribed to Slate opening events from this Flow.

flow_revisions.data.type the ‘flow_revisions’ value of this attribute means that


the flow_revisions.data object describes the
attributes of a particular Flow version.

flow_revisions.data.id the unique Flow version identifier.

slate_addons.data.type the ‘slate_addons’ value of this attribute means that


the slate_addons.data object describes the attributes
of a Bot that is set up for a particular Flow version,
not a Slate.

slate_addons.data.id the unique identifier of a Bot set up in a particular


Flow version.

Status code of the response:

200 — the request was received. The response body will contain the subscription information such as
subscription, Flow, and Bot IDs.
400 — the request failed due to incorrect input parameters. Verify the request body. It might be missing or its
attributes’ values are wrong.
401 — the request failed due to authorization issues. Verify the Authorization header. It might be missing or its
value is wrong. Ensure the Authorization token matches your request token and resend the request.
403 — the request is forbidden since the Bot was disabled. Enable the Bot and resend the request.

Webhook response

Every time the Bot is triggered by creating a Slate or Revision, a webhook that contains the data needed to get
a specific document is sent in a POST request to the {callback_url} of your service.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
9

flow_id — the unique Flow identifier where a Slate was opened, or Revision created.
slate_addon_id — the unique identifier of the Bot set up in a particular Flow.
slate_id — the unique identifier of the opened Slate.
revision_id — the unique identifier of the opened Slate Revision.
organization_id — the unique identifier of your Workspace.

🗒 Note: If the service is currently unavailable or the response code to the webhook request is not 200,
the Bot will try to send the webhook three times at one-hour intervals. You can always check the status of
the webhook in the Bots log section.

Webhook requests

Fetch

Send a GET request to the /webhook-bot/fetch endpoint to retrieve every document from all Slates and their
Revisions for which the Bot has sent webhooks. You can also filter the documents by a particular Slate
ID/Revision ID/Flow Revision ID. The response body will contain a list of filtered documents, their fields, and an
extended list of the fields’ attributes.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
10

Request example:

GET https://hostname/webhook-bot/v2/fetch?filter[slate_id]={slate_id_1}&filter[revision_id]={revision_id_1}

Headers: Authorization: {authorization_token}

Request parameters:

filter[slate_id] — the request parameter which allows for filtering documents by a specific Slate ID —
{slate_id_1}.
filter[revision_id] — the request parameter which allows for filtering documents by a specific Revision ID —
{revision_id_1}.
filter[flow_revision_id] — the request parameter which allows for filtering documents by a specific Flow revision
ID — {flow_revision_id_1}.

Status code of the response

200 — the request was received. The response body will contain a list of filtered documents, their fields, and
an extended list of the fields’ attributes.
401 — the request failed due to authorization issues. Verify the Authorization header. It might be missing or its
value is wrong. Ensure the Authorization token matches your request token and resend the request.

Response example:

Status code: 200


Response body: The response body will display the list of filtered documents, their fields, and the extended
list of fields' attributes.

Subscription

Send a GET request to the /webhook-bot/v2/subscription endpoint to review the active subscriptions of the Bot.

Request example:

GET https://{hostname}/webhook-bot/v2/subscription
Headers: Authorization: {authorization_token}

Response example:

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
11

Status code: 200


Response body:
{
"data":[ {
"type":"subscriptions",
"id":"00B43310-0000-0000-00002D5D",
"attributes":{
"callback_url":"{callback_url}"
},
"relationships":{
"slates":{
"data":{
"Type":"slates",
"id":"4404E192-C200-0000-0000BA29"
}
},
"slate_addons":{
"data":{
"type":"slate_addons",
"id":"87DC5CD5-3500-0000-000093F0"
}
},

"flow_revisions": {
"data": {
"type": "flow_revisions",
"id": "4BDA29C6-7100-0000-000049B7"

}
}
]
}

Response body parameters:

data.id the unique subscription identifier.

slates.data.type the ‘slates’ value of this attribute means that the


slates.data object describes the attributes of the
particular Flow.

slates.data.id the unique Flow identifier. You, as a Bot user, have


subscribed to Slate opening events from this Flow.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
12

flow_revisions.data.type the ‘flow_revisions’ value of this attribute means that


the flow_revisions.data object describes the
attributes of a particular Flow version.

flow_revisions.data.id the unique Flow version identifier.

slate_addons.data.type the ‘slate_addons’ value of this attribute means that


the slate_addons.data object describes the attributes
of a Bot that is set up for a particular Flow, not a
Slate.

slate_addons.data.id the unique identifier of a Bot set up in a particular


Flow version.

Status code of the response:

200 — the request was received. The response body will contain the subscription data: subscription ID
(data.id), callback URL (data.callback_url), Flow ID (slates.data.id), and Bot ID (slate_addons.data.id).
401 — the request failed due to authorization issues. Verify the Authorization header. It might be missing or its
value is wrong. Ensure the Authorization token matches your request token and resend the request.

Delete

To unsubscribe, send the DELETE request to the /webhook-bot/v2/subscription/{subscription_id} endpoint.

Request example:

DELETE https://{hostname}/webhook-bot/v2/subscription/{subscription_id}
Headers: Authorization: {authorization_token}

Response example:

Status code: 204


Response body: No response body

subscription_id — value of the data.id attribute from the subscription response body.

Status code of the response:

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
13

204 — the request was received and processed by the service. You have unsubscribed from receiving
webhooks.
400 — the request failed due to incorrect input parameters. Verify the {subscription_id}. It might be missing or
its value is wrong.

Statistics
Retrieve a list of webhooks sent by the Bot by sending the GET request to the /webhook-bot/stats endpoint.

Request example:

GET https://{hostname}/webhook-bot/stats
Headers: Authorization: {authorization_token}

The response example:

Status code: 200


Response body:
[
{
"slate_id": "C4D64766-6000-0000-0000C9C1", "revision_id": "3BEC3F61-8000-0000-00005363",
"flow_revision_id": "4BDA29C6-7100-0000-000049B7","webhooks": [
{
"notified_at": 1578919682,

"status": "success"
}
]
},
{
"slate_id": "C86D5866-6000-0000-0000C9C1", "revision_id": "011AB071-8000-0000-00005363",
"flow_revision_id": "4BDA29C6-7100-0000-000049B7","webhooks": [
{
"notified_at": 1578920763,
"status": "success"
}
]
}
]

Send the GET request to the /webhook-bot/stats endpoint with the corresponding request parameters to
retrieve the list of webhooks sent by the Bot and filtered by a Slate ID/Revision ID/Flow Revision ID.

Request example:

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
14

GET https://{hostname}/webhook-bot/stats?filter[revision_ids]={revision_id_1},{revision_ id_2}


Headers: Authorization: {authorization_token}
OR
GET https://{hostname}/webhook-bot/stats?filter[slate_ids]={slate_id_1},{slate_id_2}
Headers: Authorization: {authorization_token}
OR
GET https://{hostname}/webhook-bot/stats?filter[flow_revision_ids]={flow_revision_id_1},
{flow_revision_id_2}
Headers: Authorization: {authorization_token}
OR
GET
https://{hostname}/v2/stats?filter[slate_ids]={slate_id_1}&filter[revision_ids]={rev
ision_id_1}&filter[flow_revision_ids]={flow_revision_id_1}
Headers: Authorization: {authorization_token}

Request parameters:

filter[slate_ids] — the request parameter which allows for filtering webhooks by


specified Slate ID — {slate_id_1}.
filter[revision_ids] — the request parameter which allows for filtering webhooks
by a specific Revision ID — {revision_id_1}.
filter[flow_revision_ids] — the request parameter which allows for filtering
webhooks by a specific Flow revision ID — {flow_revision_id_1}.

Code examples

Please find below the PHP and Node.js code examples for the requests described above.

PHP code
<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client(['base_uri' => 'https://bots.airslate.com/', 'headers' =>['Authorization' => 'your-token']]);

$url = '/webhook-bot/v2/subscription';
$statsUrl = '/webhook-bot/stats';

$body = ["data" => ["type" => "subscriptions", "attributes" => ["callback_url" =>
'https://your-callback-url']]];
// Add new subscription

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
15

$subscribeResponse = $client->post($url, ['json' => $body]);


// Review subscriptions
$viewResponse = $client->get($url);
echo $viewResponse->getBody()
->getContents();
// Unsubscribe
$id = json_decode($subscribeResponse->getBody()->getContents() , true) ['data']['id'];

$client->delete($url . '/' . $id);


// Review webhook statistics
$statsResponse = $client->get($statsUrl);
echo $statsResponse->getBody() ->getContents();
The code can also be found in this article.

Node.js code
const https = require('https');
// Add new subscription
const subscribeReq = https.request({
hostname: 'bots.airslate.com',
path: '/webhook-bot/v2/subscription',
method: 'POST',
headers: {
Authorization:'your-token'
}
},
res => {
res.on('data', d => process.stdout.write(d))
}
);
const data = new TextEncoder().encode(
JSON.stringify({
data: {
type: 'subscriptions',
attributes: {
callback_url: 'https://your-callback-url-t'
}
}
})
);
subscribeReq.write(data); subscribeReq.end();
// Review subscriptions
const viewReq = https.request({
hostname: 'bots.airslate.com',
path: '/webhook-bot/v2/subscription',
method: 'GET',
headers: {
Authorization: 'your-token'

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
16

}
},
res => {
res.on('data', d => process.stdout.write(d))
}
);
viewReq.end();

// Unsubscribe
const deleteReq = https.request({
hostname: 'bots.airslate.com',
path: '/webhook-bot/v2/subscription/{UID}',
method: 'DELETE',
headers: {
Authorization: 'your-token'
}
},
res => {
res.on('data', d => process.stdout.write(d))
}
);
deleteReq.end();

// Review webhook statistics

const statsReq = https.request({


hostname: 'bots.airslate.com',
path: '/webhook-bot/v2/stats',
method: 'GET',
headers: {
Authorization: 'your-token'
}
},
res => {
res.on('data', d => process.stdout.write(d))
}
);
statsReq.end();
The code can also be found in this article.

Send Webhook upon Slate Completion Bot


Automatically transfer data to any third-party system with the Send Webhook on Documents Completion Bot.
The Bot gathers data, formats it in .JSON, and transfers it to the selected URL based on the ‘if-this-then-that’
conditions you set.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
17

Installation

1. Find the Send Webhook on Document Completion Bot and click the Install Bot button to add the Bot to
your Flow.

2. In your Postman account (or any other console), copy the Authorization token from the infobox and
paste it as the Authorization header value.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
18

1. The slate_addons will have a single token within different Flow versions. Using this token, users will be
able to access the data from all slate_addons and different Flow versions.
2. The Bot operates within versioning. If versioning doesn’t display, it means that your Flow only has one
version by default that is always up to date. Versioning will become available right after you create
another Flow version.

3. Configure the Bot execution conditions and Advanced settings as needed. Press Apply setup when
finished.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
19

4. Send a POST request to the /webhook-bot/subscription endpoint to subscribe to Slate completion


events.
POST https://hostname/webhook-bot/v2/subscription
Headers: Authorization: {authorization_token}
Request body:
{
"data" : {
"type" : "subscriptions",
"attributes": {
"callback_url" : "callback_url"
}
}
}

Hostname:
bots.airslate.com — the hostname that should be used in subsequent requests instead of the {hostname}
placeholder for US-based services.

Example: POST https://bots.airslate.com/webhook-bot/v2/subscription

bots.airslate-au.com — the hostname that should be used in subsequent requests instead of the {hostname}
placeholder for AU-based services.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
20

Example: POST https://bots.airslate-au.com/webhook-bot/v2/subscription

callback_url — the service URL which will receive a webhook.

Response body

Status code: 200


Response body:
{
"data": {
"type": "subscriptions",
"id": "6E198D00-0000-0000-00002D5D",
"attributes": {
"callback_url": "{callback_url}" },
"relationships": {
"slates": {
"data": {
"type": "slates",
"id": "7551C1A2-D100-0000-0000BA29"
}

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
21

},
"slate_addons": {
"data": {
"type": "slate_addons",
"id": "86E801EB-7300-0000-000093F0"
}
},
"flow_revisions": {
"data": {
"type": "flow_revisions",
"id": "4BDA29C6-7100-0000-000049B7"
}
}
}
}
}

Status code of the response

200 — the request was received. The response body will contain the subscription information such as
subscription, Flow, and Bot IDs.
400 — the request failed due to incorrect input parameters. Verify the request body. It might be missing or its
attributes’ values are wrong.
401 — the request failed due to authorization issues. Verify the Authorization header. It might be missing or its
value is wrong. Ensure the Authorization token matches your request token and resend the request.
403 — the request is forbidden since the Bot was disabled. Enable the Bot and resend the request.

Parametrs

data.id the unique subscription identifier.

slates.data.type the ‘slates’ value of this attribute means that the


slates.data object describes the attributes of a
particular Flow.

slates.data.id the unique Flow identifier. As a Bot user, you have


subscribed to Slate completion events from this Flow.

flow_revisions.data.type the ‘flow_revisions’ value of this attribute means that


the flow_revisions.data object describes the
attributes of a particular Flow version.

flow_revisions.data.id the unique Flow version identifier

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
22

slate_addons.data.type the ‘slate_addons’ value of this attribute means that


the slate_addons.data object describes the attributes
of a Bot that is set up for a particular Flow version,
not a Slate.

slate_addons.data.id the unique identifier of a Bot set up in a particular


Flow version.

Webhook response

Every time the Bot is triggered (when an airSlate user completes documents), a webhook that contains the
data needed to get a completed document, will be sent in a POST request to the {callback_url} of your service.

flow_id — the unique Flow identifier where documents from the Slate were completed, and Revisions created.
slate_addon_id — the unique identifier of the Bot set up in a particular Flow. slate_id — the unique identifier of
the Slate where documents were completed.
revision_id — the unique identifier of the Slate Revision where documents were completed.
organization_id — the unique identifier of your Workspace.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
23

Note: If the service is currently unavailable or the response code to the webhook request is not 200, the Bot
will try to send the webhook three times at one-hour intervals. You can always check the status in the Bots log
section.

Webhook requests

Fetch

Send a GET request to the /webhook-bot/fetch endpoint to retrieve every document from all Slates and their
Revisions for which the Bot has sent webhooks. You can also filter the documents by a particular Slate
ID/Revision ID/Flow Revision ID. The response body will contain the list of filtered documents, their fields, and
an extended list of the fields’ attributes.

Request example:

GET https://{hostname}/webhook-bot/v2/fetch?filter[slate_id]={slate_id_1}&filter[revisio n_id]={revision_id_1}


Headers: Authorization: {authorization_token}

Parameters

filter[slate_id] — the request parameter which allows for filtering documents by a specific Slate ID —
{slate_id_1}.
filter[revision_id] — the request parameter which allows for filtering documents by a specific Revision ID —
{revision_id_1}.
filter[flow_revision_id] — the request parameter which allows for filtering documents by a specific Flow revision
ID — {flow_revision_id_1}.

Status code of the response:

200 — the request was received. The response body will contain a list of filtered documents, their fields, and
an extended list of the fields’ attributes.
401 — the request failed due to authorization issues. Verify the Authorization header. It might be missing or its
value is wrong. Ensure the Authorization token matches your request token and resend the request.

Subscription

Send the GET request to the /webhook-bot/v2/subscription endpoint to review the active subscriptions of the
Bot.
Request example

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
24

GET https://{hostname}/webhook-bot/v2/subscription
Headers: Authorization: {authorization_token}

Response example

Status code: 200 Response body:


{
"data":[ {
"type":"subscriptions", "id":"00B43310-0000-0000-00002D5D",
"attributes":{
"callback_url":"{callback_url}" },
"relationships":{
"slates":{
"data":{
"type":"slates", "id":"4404E192-C200-0000-0000BA29"
}
},
"slate_addons":{
"data":{
"type":"slate_addons",
"id":"87DC5CD5-3500-0000-000093F0"
}
},
]
"flow_revisions": {
"data": {
"type": "flow_revisions",
"id": "4BDA29C6-7100-0000-000049B7"
}
}
]
}

Parameters

data.id — the unique subscription identifier.


slates.data.type — the ‘slates’ value of this attribute means that the slates.data
object describes the attributes of the particular Flow.
slates.data.id — the unique Flow identifier. You, as a Bot user, have subscribed to
Slate completion events from this Flow.
flow_revisions.data.type — the ‘flow_revisions’ value of this attribute means that
the flow_revisions.data object describes the attributes of a particular Flow version.
flow_revisions.data.id — the unique Flow version identifier.
slate_addons.data.type — the ‘slate_addons’ value of this attribute means that the slate_addons.data object
describes the attributes of a Bot that is set up for a particular Flow, not a Slate.
slate_addons.data.id — the unique identifier of a Bot set up in a particular Flow version.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
25

Status code of the response:

200 — the request was successfully received. The response body will contain the subscription data:
subscription ID (data.id), callback URL (data.callback_url), Flow ID (slates.data.id), and Bot ID
(slate_addons.data.id).
401 — the request has failed due to authorization issues. Verify the Authorization header. It might be missing
or its value is wrong. Ensure the Authorization token matches your request token and resend the request.

Delete

To unsubscribe, send the DELETE request to the /webhook-bot/v2/subscription/{subscription_id} endpoint.

Request example:

DELETE https://hostname/webhook-bot/v2/subscription/subscription_id
Headers: Authorization: {authorization_token}

Status code of the response:

204 — the request was received and processed by the service. You have unsubscribed from receiving
webhooks.
400 — the request failed due to incorrect input parameters. Verify the {subscription_id}. It might be missing or
its value is wrong.

Response example:

Status code: 204


Response body: No response body

Statistics

Get a list of webhooks sent by the Bot by sending the GET request to the /webhook-bot/stats endpoint.

Request example:

GET https://{hostname}/webhook-bot/stats
Headers: Authorization: {authorization_token}

Response example

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
26

Status code: 200 Response body:


[
{
"slate_id": "C4D64766-6000-0000-0000C9C1", "revision_id": "3BEC3F61-8000-0000-00005363",
"flow_revision_id": "4BDA29C6-7100-0000-000049B7","webhooks": [
{
"notified_at": 1578919682,

"status": "success"
}
]
},
{
"slate_id": "C86D5866-6000-0000-0000C9C1",
"revision_id": "011AB071-8000-0000-00005363",
"flow_revision_id": "4BDA29C6-7100-0000-000049B7",
"webhooks": [
{
"notified_at": 1578920763,
"status": "success"
}
]
}
]

Status code of the response:

200 — the request was received. The response body will contain the list of webhooks sent by the Bot.
401 — the request failed due to authorization issues. Verify the Authorization header. It might be missing or its
value is wrong. Ensure the Authorization token matches your request token and resend the request.
Send the GET request to the /webhook-bot/stats endpoint with the corresponding request parameters to
retrieve the list of webhooks sent by the Bot and filtered by a Slate ID/Revision ID/Flow Revision ID.

Request example

GET https://{hostname}/webhook-bot/stats?filter[revision_ids]={revision_id_1},{revision_ id_2}


Headers: Authorization: {authorization_token}
OR
GET https://{hostname}/webhook-bot/stats?filter[slate_ids]={slate_id_1},{slate_id_2}
Headers: Authorization: {authorization_token}
OR
GET https://{hostname}/webhook-bot/stats?filter[flow_revision_ids]={flow_revision_id_1},
{flow_revision_id_2}
Headers: Authorization: {authorization_token}
OR

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
27

GET https://{hostname}/v2/stats?filter[slate_ids]={slate_id_1}&filter[revision_ids]={rev
ision_id_1}&filter[flow_revision_ids]={flow_revision_id_1}
Headers: Authorization: {authorization_token}

Parameters:

filter[slate_ids] — the request parameter which allows for filtering webhooks by


a specific Slate ID — {slate_id_1}.
filter[revision_ids] — the request parameter which allows for filtering webhooks
by a specific Revision ID — {revision_id_1}.
filter[flow_revision_ids] — the request parameter which allows for filtering
webhooks by a specific Flow revision ID — {flow_revision_id_1}.

Code Examples
Please find below the PHP and Node.js code examples for the requests described above.

PHP code

<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client(['base_uri' => 'https://bots.airslate.com/', 'headers' => ['Authorization' => 'your-token']]);

$url = '/webhook-bot/v2/subscription';
$statsUrl = '/webhook-bot/stats';

$body = ["data" => ["type" => "subscriptions", "attributes" => ["callback_url" =>'https://your-callback-url']]];
// Add new subscription
$subscribeResponse = $client->post($url, ['json' => $body]);
// Review subscriptions
$viewResponse = $client->get($url);
echo $viewResponse->getBody()
->getContents();
// Unsubscribe
$id = json_decode($subscribeResponse->getBody()
->getContents() , true) ['data']['id'];
$client->delete($url . '/' . $id);
// Review webhook statistics
$statsResponse = $client->get($statsUrl);
echo $statsResponse->getBody()
->getContents();

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
28

The code can also be found in this article.

Node.js code

const https = require('https');

// Add new subscription


const subscribeReq = https.request({
hostname: 'bots.airslate.com',
path: '/webhook-bot/v2/subscription',
method: 'POST',
headers: {
Authorization:'your-token'
}
},
res => {
res.on('data', d => process.stdout.write(d))
}
);
const data = new TextEncoder().encode(
JSON.stringify({
data: {
type: 'subscriptions',
attributes: {
callback_url: 'https://your-callback-url-t'
}
}
})
);
subscribeReq.write(data); subscribeReq.end();
// Review subscriptions
const viewReq = https.request({
hostname: 'bots.airslate.com',
path: '/webhook-bot/v2/subscription',
method: 'GET',
headers: {
Authorization:'your-token'
}
},
res => {
res.on('data', d => process.stdout.write(d))

}
);
viewReq.end();
// Unsubscribe
const deleteReq = https.request({

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
29

hostname: 'bots.airslate.com',
path: '/webhook-bot/v2/subscription/{UID}',
method: 'DELETE',
headers: {
Authorization: 'your-token'
}
},
res => {
res.on('data', d => process.stdout.write(d))
}
);
deleteReq.end();
// Review webhook statistics
const statsReq = https.request({
hostname: 'bots.airslate.com',
path: '/webhook-bot/v2/stats',
method: 'GET',
headers: {
Authorization:'your-token'
}
},
res => {
res.on('data', d => process.stdout.write(d))
} );
statsReq.end();

The code can also be found in this article.

Create Slate from External Event


The Autostart From External Event endpoint enables airSlate users to create new Slates pre-filled with custom
data from external events. It's triggered by a POST request from the external service to the respective airSlate
endpoint.

Supported documents:
● Uploaded PDF documents
● Form or Survey
● Document generation
● Contract
● Spreadsheet

You can pre-fill all field types except:


● Signature

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
30

● Initials
● Image

Installation

1. Right after you’ve visualized your workflow, click the Flow Start block and then click Add autostart.

2. Select the From the External Event option:

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
31

3. In your Postman account (or any other console), copy the Authorization token from the infobox and
paste it as the Authorization header value.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
32

4. Indicate the alias of the respective field indicated in the Bot settings scheme which will be used as the
id attribute.

An alias may contain letters, digits, “_”, “-”, and quotation marks. Its maximum length is 35 characters and the
minimum length is 3 characters.

5. Send a POST request /slate-creation-from-event-bot/create-slate for the Slate creation.

Example:

POST https://hostname/slate-creation-from-event-bot/create-slate
Headers: Authorization : {authorization_token}
Request body:
{
"data" : {
"type": "slate_creation_requests",
"attributes": {

"callback_url" : {callback_url}

}
},

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
33

"meta": {
"fields": [

//id - {{field alias indicated in the addon settings scheme}}

{
"id": "field1",

"value": "Pre-fill text value"


},

//Configure the pre-fill of the field_type: array field with objects {


"id": "field2",
"value": [
},
{
"id": 0,
"value": "option_1"
},
{
"id": 1,
"value": "option_2"
}
]
//Configure the pre-fill of the field_type: array field with strings {
"id": "field3",
"value": ["value_1", "value_2", "value_3"]
}
]
}
}
Hostname:

bots.airslate.com — the hostname that should be used in subsequent requests instead of the {hostname}
placeholder for US-based services.
bots.airslate-au.com — the hostname that should be used in subsequent requests instead of the {hostname}
placeholder for AU-based services.
callback_url — the service URL which will receive a webhook.
data.type — parameter with the predefined slate_creation_requests value.
meta.fields — an array of fields with their attributes and pre-fill values. {callback_url} — the service URL which
will receive a POST request when the Slate is created and pre-filled (the Slate creation status — is_completed:
true).

Taking into account the validation rules — the field_type and the extended set of field attributes — add the
pre-fill data for each field to the corresponding value attributes.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
34

You can create Slates from the latest Flow version or from a draft Flow version. To create a Slate from a draft
version, indicate meta.use_draft_flow:true.

Status code of the response:

201 — the request for Slate creation and pre-filling was successfully submitted. The response body will contain
the unique Slate creation id — {request_id} and the operation status in the data.attributes.is_completed
property.
403 — the request failed due to authorization issues. Verify the Authorization header. It might be missing or its
value is wrong. Ensure the Authorization token matches your request token and resend the request.

Response example

Status code: 200


Slate is not created Response body:
{
"data": {
"type": "slate_creation_requests",
"id": "43619000-0000-0000-0000591D", //{request_id} "
attributes": {
"callback_url": {callback_url},
"is_completed": false,
"message": null
}
}
}

Slate creation

Usually it takes a minute to create a pre-filled Slate in a Flow. To check the Slate creation status, send a GET
request to the
/slate-creation-from-event-bot/create-slate/{request_id} endpoint.
{request_id} — unique Slate creation ID. Replace the {request_id} placeholder with the id attribute value of the
create and pre-fill Slate response JSON.

Request example

GET https://bots.airslate.com/slate-creation-from-event-bot/create-slate/{request_id}
Headers: Authorization : {authorization_token}

Check the is_completed attribute of the response body:

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
35

false — Slate is not created.


true — Slate is created.

Code Examples

Please find below the PHP and Node.js code examples for the requests described above.

PHP code

<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client(['base_uri' => 'https://bots.airslate.com/', 'headers'


=> ['Authorization' => '{authorization_token}']]);

$createSlateUrl = '/slate-creation-from-event-bot/create-slate';

// send a request to create a pre-filled Slate

$body = ["data" => ["type" => "slate_creation_requests", "attributes" =>


["callback_url" => 'https://{callback_url}']], 'meta' => ['fields' => [['id'
=> {FIELD_ALIAS}, 'value' => 'value', ]]]];
$createSlateResponse = $client->post($createSlateUrl, ['json' => $body]);

// check the request status

$requestID = json_decode($createSlateResponse->getBody()
->getContents() , true) ['data']['id'];

$slateStatusResponse = $client->get($createSlateUrl . '/' . $requestID);

echo $slateStatusResponse->getBody()
->getContents();

The code can also be found in this article.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
36

Node.js code
const https = require('https');

// send a request to create a pre-filled Slate

const slateCreateReq = https.request(


{

hostname: 'bots.airslate.com',
path: '/slate-creation-from-event-bot/create-slate',
method: 'POST',
headers: {

Authorization: '{authorization_token}'
}
},
res => {
res.on('data', d => process.stdout.write(d))
}
);
const data = new TextEncoder().encode(
JSON.stringify({

data: {
type: 'slate_creation_requests',
attributes: {

callback_url: 'https://{callback_url}'
}

},
meta: {
fields: [ {
id: '{FIELD_ALIAS}',

value: 'value'
}
]
}
})
);
slateCreateReq.write(data);
slateCreateReq.end();

// check the request status

const statusReq = https.request(


{

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.
37

hostname: 'bots.airslate.com',
path: '/slate-creation-from-event-bot/create-slate/{request_id}',
method: 'GET',
headers: {

Authorization: '{authorization_token}'
}
},
res => {
res.on('data', d => process.stdout.write(d))
}

);
statusReq.end();

The code can also be found in this article.

© 2022 airSlate Inc.


www.airslate.com
All rights reserved.

You might also like