Trip Plan Requests

You can create new trip plan requests using APIs. This is particularly useful when you want to integrate a travel marketing website with Sembark to handle the trip plan requests from marketing site using SembarkA APIs.

Here are the available api requests and their responses.

Create

To create a trip plan request, you should send a POST request to the https://api.sembark.com/integrations/v1/trip-plan-requests endpoint with the required request data. If the request succeeds, you will receive a response with 201 (created) status code with a success message.

Request Body

{
  /**
  * Name of the Guest, required
  * @max-characters 191
  */
  'name': string
  /**
  * Contact Number of the Guest, required
  * @max-characters 191
  */
  'phone_number': string
  /**
  * Contact Email of the Guest, optional
  * @format Email 
  * @max-characters 191
  */
  'email': string | null
  /**
  * Trip Start Date, optional, 
  * - if present, it MUST be in the below format
  * @format "YYYY-MM-DD" e.g. "2023-04-22"
  */
  'start_date': string | null
  /**
  * Number of days, optional
  * @min 1
  */
  'no_of_days': number | null
  /**
  * Number of adults, optional
  * @min 1
  */
  'no_of_adults': number | null
  /**
  * Number of children, optional
  * @min 0
  */
  'no_of_children': number | null
  /**
  * Destination of the trip, optional
  * @max-characters 50
  */
  'destination': string | null
  /**
  * Any custom comments, optional
  * @max-characters 500
  */
  'comments': string | null
  /**
  * Custom Reference ID for this query
  * @max-characters 36
  */
  'reference_id': string | null
}

Response

{
  message: "Trip plan request created";
}

Here are some common implementation of the above request.

curl --location --request POST 'https://api.sembark.com/integrations/v1/trip-plan-requests?name=Traveler Name&phone_number=8000631728' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <TOKEN_HERE>'
var axios = require("axios");
var config = {
  method: "post",
  url: "https://api.sembark.com/integrations/v1/trip-plan-requests?name=Guest Name&phone_number=8000631728",
  headers: {
    Accept: "application/json",
    Authorization: "Bearer <TOKEN_HERE>", // Update the Token
  },
};
axios(config)
  .then(function (response) {
    // show the response.data.message
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    // handle the errors for 401/422/405/500 etc
    console.log(error);
  });
// create a payload for the request
$payload = http_build_query([
  'name' => 'e.g. Sembark Client', // Guest/Agent Name [required
  'phone_number' => 'e.g. 9009009999', // Contact No. [required]
  'email' => 'e.g. client@example.com', // Contact Email
  'destination' => 'e.g. Sikkim', // Destination details
  'reference_id' => 'e.g. GOOGLE_ADD_REF_1', // Any Reference ID
  // Any other custom details can be added into the comments section
  'comments' => 'e.g. 3 Adults, 4 Star Hotels, AC Vehicles'
]);

// set data to APIs and handle the response
$curl_handler = curl_init();
curl_setopt_array($curl_handler, array(
  CURLOPT_URL => 'https://api.sembark.com/integrations/v1/trip-plan-requests',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_TIMEOUT => 0,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'Authorization: Bearer <TOKEN_HERE>' // Update the token
  ),
  CURLOPT_POST => 1,
  CURLOPT_POSTFIELDS => $payload // payload here
));
$response = curl_exec($curl_handler);
if (curl_errno($curl_handler)) {
    $error_message = curl_error($curl_handler);
}
curl_close($curl_handler);
if (isset($error_message)) {
  // TODO - Handle the error
  die($error_message);
}
echo $response;
use Illuminate\Support\Facades\Http;


// create a payload for the request e.g. $request->input('name') etc.
$payload = [
  'name' => 'e.g. Sembark Client', // Guest/Agent Name [required]
  'phone_number' => 'e.g. 9009009999', // Contact No. [required]
  'email' => 'e.g. client@example.com', // Contact Email
  'destination' => 'e.g. Sikkim', // Destination details
  'reference_id' => 'e.g. GOOGLE_ADD_REF_1', // Any Reference ID
  // Any other custom details can be added into the comments section
  'comments' => 'e.g. 3 Adults, 4 Star Hotels, AC Vehicles'
];

$response = Http::acceptJson()
  ->withToken('<TOKEN_HERE>')
  ->baseUrl('https://api.sembark.com/integrations/v1')
  ->post('trip-plan-requests', $payload);

if ($response->failed()) {
  // TODO: Handle the errors
}

FAQs

Q. How to send custom/extra fields in API call?
If you have some data fields which cannot be mapped into the accepted API fields, you can send those fields along with the mapped fields. System will capture those extra fields and you can view them in the dashboard.

payload = {
  // mappable data
  'name': 'Guest Name',
  'phone_number': '1221222233',
  //...
  // Custom/Extra Fields
  'origin_city': 'New Delhi',
  'package_type': '5 star'
}

You should choose the name of the fields (e.g., origin_city, package_type etc/) as per your requirements.

Q. How to send the start date in correct format?
If you have the start date in a different format then the API accepted format (year-month-date), you MUST change the date in the accepted format. This will vary depending on your environment and implementation. Here are some common formatting implementations.

// $date = 'Your Date in d-m-Y format e.g. 16-05-2023'
$start_date = date_format(
  DateTimeImmutable::createFromFormat(
    'd-m-Y', // your existing date format
    $date // exiting data
  ), 
  'Y-m-d' // acceptable format
);

Q. How to update an existing request?

If you need to update an existing request, you can pass a client_request_uid field with a same unique value for all API call. The endpoint will merge any new data with existing data from earlier API calls. This updation can be helpful if you have integrated ChatBots (e.g. Botosynthesis) and are collecting data using bots and your landing pages for single lead.

Share

Contact Us

Please feel free to contact us for your queries or demo requests. Provide your contact details and our team will connect you shortly afterwards.

Office Address

1, Plot No 177A, Shyam Enclave Sirsi, Jhotwara
Jaipur, Rajasthan, India - 302034


Enter the Captcha
re-captcha