(API) Sending your first request - P2

This tutorial is in order to send your first P2 request using the version 1.0 of Sandbox Botdoc API. In order to use this version, you have to put “v1” on the API’s endpoint.

To a better understanding about the versioning, please go to https://api.botdoc.io/documentation/#section/Get-Started/Versioning
and to a better understanding about the Sandbox, please go to https://api.botdoc.io/documentation/#section/Get-Started/Sandbox-Platform

Instructions

The first thing you need to understand is every request MUST have a token:
Thus, no matter what endpoint, you always need to pass the token on the header that looks like the following:
Authorization: JWT your-token-here

1 - Create a Container:

Botdoc P2 Container is a session with multiple secure Features inside of it, with P2 you can make a Flow automation or just a simple file "push", "pull", “DocuSign” or “External URL”.

Endpoint: https://api.botdoc.io/v1/module_container/container/ 
Method: POST.

Example of the body in JSON format:

{ "page_type": "p2", "callback_url": "https://link.to.your.callback.url", "display_chat": true }

Example how to create a Container by cURL:

curl -i --request POST "https://api.botdoc.io/v1/module_container/container/" \ --header "Authorization: JWT <Authorization Token>" \ --header "Content-Type: application/json" \ --data-raw "{ "page_type": "p2", "callback_url": "https://link.to.your.callback.url", "display_chat": true }"

1.2 - Create a Container with a Requester:

To create a Container with a Requester attached, is simple, first of all, you need to create a Requester, if you don't have any Requester registered, follow the link: How to create a Requester

After that, we need to create a new Container adding our Requester, the process is simple, follow:

Endpoint: https://api.botdoc.io/v1/module_container/container/ 
Method: POST.

Example of the body in JSON format:

{ "page_type": "p2", "requester": {requester_id} }

Example how to create a Container with a Requester by cURL:

Remember that, whenever a Container with a Requester attached to it is sent, the Requester is duplicated to a table RequesterContainer, to keep the data concise with the data on the day and time of the Container was sent, in case of this requester is modified or even deleted.


2 - Define Recipient(s):

After the Secure Container was created, you need to create the Recipient(s) of your Secure Container.
Endpoint: https://api.botdoc.io/v1/module_container/container/{container_id}/recipient/
Method: POST.

Example of the body in JSON format:

Example how to create a Recipient by cURL:

3 - Define your RecipientItem(s)

Now, we need to add our RecipientItem linked to the Recipient in the Step 2.
Endpoint: https://api.botdoc.io/v1/module_container/recipient/{recipient_id}/recipient_item/
Method: POST.

Example of the body in JSON format:

Example how to create a Recipient Item by cURL:

4 - Set an AuthCode

Now, if you want, you can protect your Secure Container with Two Factor Authentication.
Endpoint: https://api.botdoc.io/v1/module_container/authcode/
Method: POST.

Example of the body in JSON format:

Example how to create an AuthCode by cURL:

5 - Define Email Message

Now, you must inform the Email Message if in the previewer step the transport method was sent to Email.
Endpoint: https://api.botdoc.io/v1/module_container/container/{container_id}/email/
Method: POST.

Example of the body in JSON format:

Example how to create an Email message by cURL:

6 - Define SMS Message

Now, you must inform the SMS Message if in the previewer step, the transport method was sent to SMS.
Endpoint: https://api.botdoc.io/v1/module_container/container/{container_id}/sms/
Method: POST.

Example of the body in JSON format:

Example how to create an SMS message by cURL:

7 - Add Features

Now, you must add a feature, can be Pull, Push or DocuSign, see 3 examples below:

7.1 - Pull Feature

If you want to request file(s) FROM your receiver, you must send a Pull Feature:
Endpoint: https://api.botdoc.io/v1/module_container_pull/pull/
Method: POST.

Example of the body in JSON format:

Example how to create a Pull Feature by cURL:

7.2 - Push Feature

If you want to SEND file(s) to your Receiver, you must send a Push Feature:
Endpoint: https://api.botdoc.io/v1/module_container_push/push/
Method: POST.

Example of the body in JSON format:

Example how to create a Push Feature by cURL:

7.2.1 - Push File Feature

If you want to SEND file(s) to your Receiver, you must send a Push Feature and a Push File (required):
Endpoint: https://api.botdoc.io/v1/module_container_push/pushfile/
Method: POST.

Example of the body in JSON format:

Example how to create a PushFile Feature by cURL:

7.3 - DocuSign Feature

If you want the Receiver to Sign something, you must send a DocuSign Feature:
Endpoint: https://api.botdoc.io/v1/module_container_docusign/docusign/
Method: POST.

Example of the body in JSON format:

Example how to create a DocuSign Feature by cURL:


7.4 - External URL Feature

If you want to send some link(s) to your receiver, you must send a External URL, the URL in the body must have a https:// prefix.
Endpoint: https://api.botdoc.io/v1/module_container_iframe/iframe/
Method: POST.

Example of the body in JSON format:

Example how to create a External URL Feature by cURL:

8 - Send the Notification to the Receiver(s)

Now, just send the Notification to the Receiver(s).
Endpoint: https://api.botdoc.io/v1/module_container/container/{container_id}/send_notification/
Method: POST.

Example how to send a notification by cURL:

 

 

For more details about creating a requests you can take a look at our Botdoc API Reference on api.botdoc.io/documentation/#create-request

Related articles

FULL VIEW CLICK HERE