Pre-Loading Bookings
Bookings can be created in advance of prompting the user for payment via the TMT API.
User Tokens
All API requests must include a valid JWT token. To obtain a token, perform an API request as follows, where {username}
and {password}
are the user credentials supplied to you by Trust My Travel:
Request
POST /wp-json/jwt-auth/v1/token HTTP/1.1
Host: https://tmtprotects.com/wp
Content-Type: application/json
{
"username": "{username}",
"password": "{password}"
}
Response
{
"id": 2,
"name": "testsiteadmin",
"username": "testsiteadmin",
"user_email": "testsiteadmin@example.org",
"user_nicename": "testsiteadmin",
"user_display_name": "testsiteadmin",
"usertype": "member_admin",
"type": "member_admin",
"sites": [
{
"name": "TMT Test Site",
"url": "http://tmtprotects.com/tmt-test",
"path": "/tmt-test/"
}
],
"token": "eyJ0e...PiUmyY",
"refresh_token": "eyJ0e...p37TI"
}
Add Booking
{path}
corresponds with your site path{token}
corresponds with a User Token{channel_id}
corresponds with the ID of the channel you wish to add the booking to{channel_currency}
corresponds with the currency of the channel you wish to add the booking to
Request
POST /wp-json/tmt/v2/bookings HTTP/1.1
Host: https://tmtprotects.com/{path}
Content-Type: application/json
Authorization: Bearer {token}
{
"firstname": "John",
"surname": "Smith",
"email": "john.smith@example.org",
"date": "2028-08-12",
"total": 1000,
"currencies": "{channel_currency}",
"channels": {channel_id},
"countries": "GB"
}
Notes
- The
date
field is for the date of travel. - The
countries
field pertains to the country the booking takes place in and must be a valid ISO 3166-1 alpha-2 value - The
total
for the booking is in cents
Response
{
"id": 3097,
"trust_id": "3-3097",
"author": null,
"created": "2020-03-31 12:28:03",
"modified": "2020-03-31 12:28:03",
"status": "draft",
"internal_id": 3097,
"title": "Smith | john.smith@example.org",
"content": null,
"firstname": "John",
"surname": "Smith",
"email": "john.smith@example.org",
"date": "2028-08-12",
"pax": null,
"reference": null,
"total": 1000,
"total_unpaid": 1000,
"currencies": null,
"countries": "GB",
"country": "GB",
"transaction_ids": [],
"channels": null,
"language": "enGB"
}
Notes
For full detail on the bookings endpoint you can request the schema using the example below where {token}
corresponds with a User Token and {path}
corresponds with your site path.
OPTIONS /wp-json/tmt/v2/bookings HTTP/1.1
Host: https://tmtprotects.com/{path}
Authorization: Bearer {token}