Subscriptions
API methods to work with Subscriptions
At BookDirect.com you can create Subscriptions to be notified about any changes at Property ARI or about Booking changes. You can think about Subscriptions like about Push-notifications. When some changes happened at Property ARI, we are call provided endpoint and send changed data.
Subscription List
Retrieve list of Subscriptions associated with user Properties.
Request:
GET https://staging.bookdirect.com/api/v1/subscriptionsSuccess Response Example
Status Code: 200 OK
{
"data": [
{
"id": "a9a88747-767e-458c-99e0-9212fcfb0b39",
"type": "subscription",
"attributes": {
"request_params": null,
"is_active": true,
"send_data": true,
"id": "a9a88747-767e-458c-99e0-9212fcfb0b39",
"event_mask": "*",
"callback_url": "https://YOUR-WEBSITE.COM/api/push_message"
},
"relationships": {
"property": {
"data": {
"type": "property",
"id": "716305c4-561a-4561-a187-7f5b8aeb5920"
}
}
}
}
]
}Unauthorised Error Response
Status Code: 401 Unauthorized
Returns
Success
Method can return a Success result with 200 OK HTTP Code if operation is successful. Will contain a list of Subscription objects in the answer.
Unauthorised Error
Method can return a Unauthorised Error result with 401 Unauthorized HTTP Code if wrong Bearer Token provided.
Create Subscription
Create new Subscription.
Request:
POST https://staging.bookdirect.com/api/v1/subscriptionsQuery body (JSON):
{
"subscription": {
"property_id": "716305c4-561a-4561-a187-7f5b8aeb5920",
"callback_url": "https://YOUR-WEBSITE.COM/api/push_message",
"event_mask": "*",
"request_params": {},
"is_active": true,
"send_data": true
}
}Success Response Example
Status Code: 201 Created
{
"data": {
"type": "subscription",
"id": "227d4b09-7eef-4c7e-bc72-44c0c40b5299",
"attributes": {
"request_params": {},
"is_active": true,
"send_data": true,
"id": "227d4b09-7eef-4c7e-bc72-44c0c40b5299",
"event_mask": "*",
"callback_url": "https://website.com/api/push_message"
},
"relationships": {
"property": {
"data": {
"type": "property",
"id": "52397a6e-c330-44f4-a293-47042d3a3607"
}
}
}
}
}Unauthorised Error Response
Status Code: 401 Unauthorized
Validation Error Response
Status Code: 422 Unprocessable Entity
Fields
property_id [required]
String with valid UUID of Property object what you would like to associate with created Subscription.
callback_url [required]
Valid URL address. Note: This URL will be called via POST request when trigger event is happened.
event_mask [required]
Non-empty string with event mask.
Note: Right now we have two events, what can trigger Subscription - ari and booking. You can specify different endpoints for different events using event_mask field or subscribe to any event by passing * as event_mask.
For ari event event mask support filtering by restriction, room type id and rate plan id. In that case, event mask should looks like: event:restrictions:room_type_ids:rate_plan_ids where restrictions, room_type_ids and rate_plan_ids can contain several comma separated values.
Real example to listen rate changes at Rate Plan with ID equal to 96a44e07-2158-43e4-8baa-8f6f56922ba8:
ari:rate:*:96a44e07-2158-43e4-8baa-8f6f56922ba8
request_params [optional]
JSON Object with specific connection settings.
Note: If you would like use URL endpoint protected via authentication, you can define request headers at this field.
Example:{"Authorization": "Basic user:password"}
is_active [optional]
Boolean value.
Note: This field represent active status of Subscription. Only Subscriptions with is_active field equal to true value can receive notifications.
Receive false as default value.
send_data [optional]
Boolean value.
Note: This field is a flag to send payload data in push callback. If value is false we are call callback url without any information about changes.
Receive false as default value.
Returns
Success
Method can return a Success result with 201 Created HTTP Code if operation is successful. Will contain a Subscription object in the answer.
Unauthorised Error
Method can return a Unauthorised Error result with 401 Unauthorized HTTP Code if wrong Bearer Token provided.
Validation Error
Method can return a Validation Error result with 422 Unprocessable Entity HTTP Code if any validation rule is failed.
Update Subscription
Update Subscription.
Request:
Query body (JSON):
Success Response Example
Status Code: 200 OK
Unauthorised Error Response
Status Code: 401 Unauthorized
Not Found Error
Status Code: 404 Not Found
Validation Error Response
Status Code: 422 Unprocessable Entity
Fields
This method use same fields as Create Subscription method.
Returns
Success
Method can return a Success result with 200 OK HTTP Code if operation is successful. Will contain a Subscription object in the answer.
Unauthorised Error
Method can return a Unauthorised Error result with 401 Unauthorized HTTP Code if wrong Bearer Token provided.
Not Found Error
Method can return a Not Found Error result with 404 Not Found HTTP Code if Subscription with provided ID is not present at system.
Validation Error
Method can return a Validation Error result with 422 Unprocessable Entity HTTP Code if any validation rule is failed.
Remove Subscription
Remove Subscription.
Request:
Success Response Example
Status Code: 200 OK
Unauthorised Error Response
Status Code: 401 Unauthorized
Not Found Error
Status Code: 404 Not Found
Returns
Success
Method can return a Success result with 200 OK HTTP Code if operation is successful. Will contain a Meta object with message in the answer.
Unauthorised Error
Method can return a Unauthorised Error result with 401 Unauthorized HTTP Code if wrong Bearer Token provided.
Not Found Error
Method can return a Not Found Error result with 404 Not Found HTTP Code if Subscription with provided ID is not present at system.
Test Subscription
Test Subscription by sending test query to your endpoint.
Request:
Query body (JSON):
Success Response Example
Status Code: 200 OK
Returns
Success
Method can return a Success result with 200 OK HTTP Code with body and status code of request results to your endpoint.
Last updated
Was this helpful?