Changes

Jump to navigation Jump to search

API V2.0

9,288 bytes added, 15 March
= Capabilities =
API V2 can allow third parties to access your account, properties, bookings and inventory. More information can be found here [https://beds24.com/api/v2 beds24.com/api/v2] = Authentication =To use most API endpoints you will need to include a token header. '''Step 1: Get an invite code''' Invite codes can be generated here [https://beds24.com/control3.php?pagetype=apiv2 Invite Codes] For more information about invite codes, [[API_V2.0#Invite_codes|see here]]. This step is the only one that must be done manually, all other steps can be performed and automated programmatically.  '''Step 2: Get a refresh token using the invite code''' You can use the invite code generated in step one with GET /authentication/setup. This will return a ''token'' and a ''refresh token''. '''Step 3: Use the token to authenticate calls''' The ''token'' returned in step 2 can be included as a header to authenticate calls to other API endpoints. <span style="color:#019cde; font-size: 150%;“ >{{#fas:info-circle}} </span> ''Tokens'' expire after 24 hours. '''Step 4: Use the refresh token to generate new tokens''' As ''tokens'' expire after 24 hours, you will need to use the ''refresh token'' with GET /authentication/token to get new tokens when old ones expire. <span style="color:#019cde; font-size: 150%;“ >{{#fas:info-circle}} </span> ''Refresh tokens'' do not expire so long as they have been used within the past 30 days.
= Invite codes =
Multiple IP addresses can be added if separated by commas, e.g.
192.168.0.1, 127.0.0.1, 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Each category of API endpoint (except /authentication) requires a corresponding scope to access.
== bookings ==The '''bookings''' scope provides access to basic information for GET /bookings POST /bookings == bookings-personal==The '''bookings-personal''' scope provides access to personal information (in addition to the basic information granted by the ''bookings'' scope) for GET /bookings POST /bookings GET ​/bookings​/messages POST ​/bookings​/messages PATCH ​/bookings​/messages == bookings-financial==The '''bookings-financial''' scope provides access to financial information (in addition to the basic information granted by the ''bookings'' scope) for GET /bookings POST /bookings == inventory==The '''inventory''' scope provides access to GET ​/inventory​/offers GET ​/inventory​/availability GET ​/inventory​/calendar POST ​/inventory​/calendar == properties ==The '''properties''' scope provides access to accountsGET /properties channelPOST /properties
== accounts ==
The '''account''' scope provides access to
GET /accounts
POST /accounts
== Linked Properties ==
Tokens do not provide access to linked properties and their bookings by default.
 
If you wish to access properties that are not in your account you must tick the "Allow linked properties" checkbox when selecting the scopes for the token.
 
Note: Properties must be linked under Account Management > Manage Account > Manage Property. Other methods of linking properties are not supported in API V2.
 
== Subcategory scopes ==
Some categories have additional scopes that allow access to personal or financial information. For example, the "bookings" scope would grant access to a booking's basic information such as the check-in and checkout dates. To access personal information such as the name of a guest, the "bookings-personal" scope would be required. Similarly, to access the invoice of a bookings, the "bookings-financial" scope would be required.
Each response item will contain a "success" boolean field. Success will be false if there were any errors in processing the item.
<span style="color:#019cde; font-size: 150%;“ >{{#fas:info-circle}} Note: </span> Success being false does not necessarily mean that nothing has changed.  <span style="color:#019cde; font-size: 150%;“ >{{#fas:info-circle}} </span> E.g. if a valid booking with an invalid info item is posted, the booking will be created but the info item will not. Success will be false in this case because there was an error.
A response item may also contain one or more of the following:
}
]
 
= Prices =
 
To get price setup rules, include the "includePriceRules" parameter in GET /properties like this
/api/v2/properties?includePriceRules=true
 
A room can have up to 16 prices.
 
In the control panel, these can be set under Prices -> Daily Price Rules.
 
In the API these can be accessed through GET and POST /inventory/calendar
{
"data": [
{
"calendar": [
{
"price1": 100,
"price2": 300,
"price3": 200,
...
}
]
}
]
}
 
= Webhooks =
== Booking webhooks ==
To access booking webhooks for API V2 please contact support. They can then be enabled under Settings > Properties > Access > Booking webhooks.
== Other webhooks ==
Information about other webhooks (including non API V2 webhooks) can be found here [https://wiki.beds24.com/index.php/Category:Webhooks Webhooks]
 
= Best Practices =
== Token Management ==
Tokens last 24 hours. This means that you do not need to retrieve a new token for each request. Getting a new token costs credits so it is best to use an existing one when possible.
 
== Retrieving information at high frequencies ==
If you need to get data such as new messages or bookings when they come in you do not need to perform frequent GET requests. Instead, you can use webhooks to be notified as soon as a new message/booking etc arrives.
 
== Sending information at high frequencies ==
If you need to send large amounts of information such as messages at high frequencies it is best to send them grouped in bulk POST requests instead of sending one request per message. For example, you could send one POST request every 30 seconds containing all messages sent in the past 30 seconds.
 
== Sending or getting information in one call ==
If you need to retrieve information about multiple different things, such as information about several properties, you can retrieve that in one call by specifying multiple IDs in the one request instead of performing one GET request per property. The same principle applies when POSTing information, for example, you can create or update multiple properties in one call.
= Examples =
"expiresIn": 3600
}</nowiki>
 
= Changelog =
The API V2 changelog is [[API_V2.0_changelog|available here]].
 
=FAQ=
==How do I access API V2?==
Create an invite code under {{#fas:cog}} (SETTINGS) Apps & Integrations > API.
 
Exchange this invite code for a refresh token and token using the POST /authentication/setup endpoint.
 
Include the token in your requests to authenticate them.
 
You can try this out using our interactive UI here [https://beds24.com/api/v2 beds24.com/api/v2].
 
==What are scopes?==
Scopes limit what your token can do.
 
For example, the read/bookings scope allows your token to retrieve bookings via the API, but if your token does not have the write/bookings scope then it cannot be used to create or modify bookings.
 
==Where are scopes set?==
Scopes are set when you create an invite code.
 
Scopes cannot be changed later, you must create a new invite code with the scopes you want and exchange it for a new token.
 
==How long do invite codes/tokens last?==
Invite codes expire after 15 minutes.
 
Refresh tokens last forever so long as they are being used. Unused refresh tokens expire after 30 days.
 
Tokens expire after 24 hours.
 
==How big are tokens?==
Tokens will be between 152 and 172 characters long.
 
==What is the API credit limit?==
The API credit limit restricts how much you can use the API in a 5 minute window.
 
Each API request has a cost, this cost is calculated dynamically and depends on how complex the request is.
 
If you go over this limit you will not be able to make additional API calls until the 5 minute period is over.
 
==Where can I see my API credit limit?==
Information about your credit limit is included in the following API response headers:
 
*x-five-min-limit-remaining - the number of credits you have left for this 5 minute period.
*x-five-min-limit-resets-in - the number of seconds until the current period resets.
*x-request-cost - the number of credits this request cost.
 
==Is the API limited per token or per account?==
The API credit limits are at the account level.
 
This means that tokens under the same account share the same credit limit.
 
==How do I make a new property/room/booking etc?==
Simply do not include an id in your POST request.
 
Examples for how to do this can be found here:
 
[https://beds24.com/api/v2/#/Properties/post_properties Properties/Rooms]
 
[https://beds24.com/api/v2/#/Bookings/post_bookings Bookings]
 
==Where can I see or set price rules?==
Price rules can be found under /properties.
 
To retrieve them you must set the includePriceRules parameter to true.
 
==Where can I see or set offers?==
Offer setup rules can be found under /properties.
 
To retrieve them you must set the includeOffers parameter to true.
 
You can retrieve offers (i.e. calculated prices for specific dates) through the /inventory/rooms/offers endpoint.
 
==How can I see or set prices, min stay, availability etc for specific dates like in the UI calendar?==
These per date values can be read and set through the /inventory/rooms/calendar endpoint.
 
==Where can I see examples for how to use the API?==
Examples can be found here [https://beds24.com/api/v2 beds24.com/api/v2].
 
==Can I use API V2 to send pictures or webhooks?==
Currently no, however these features are coming soon.
 
==How can I see if a date is available for check-in/out?==
The GET /inventory/rooms/availability returns information about if dates are available or not. If a date is false, it means it is not available for check-in. However, if the previous date is available, it means the date is available for check-out.
 
For example, with the following a booking cannot check-in on 2024-01-03 because that date is unavailable. However, because the previous date 2024-01-04 is available, it means 2024-01-03 is available for check-out.
"availability": {
"2024-01-01": true,
"2024-01-02": true,
"2024-01-03": false
}
 
==What is the maximum amount of data I can send in a POST request?==
The API has a limit of approximately 1MB per POST payload.
 
In addition, there is a limit of 10000 top level JSON array item per POST request.
 
==Where can I see the possible values for a booking's apiSourceId (API Source ID)==
[[/API_V2.0_apisourceids | apiSourceId values can be found here.]]

Navigation menu