Book one or more users onto a course date.
Use this API call to create a new order. The response body will contain a summary with the id of the newly created order. How the price of each participant is worked out is explained under Prices, below the parameters.
For every API request you make, you'll need to present the API access key in the HTTP Header as X-API-Key to be authenticated.
| Name | Required | Value | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| coursedate_id | required | number | Course date identifier. i.e. 12792066 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payment_method | required | string |
The
Information related to card payments
When the
Additionally, you can provide custom URLs for payment completion or cancellation by using the optional Example
You can use other endpoints like i.e. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_paid | optional | boolean | Set to true to register the order as already paid, e.g. when it was paid outside FrontCore. The order and every participant on it are marked paid, exactly as PUT /v2/orders/:id with is_paid does, before any receipt or webhook goes out. Default: false.Not available with card payment, on company internal courses (whose bookings share one order), or when booking a partner's course; those requests are rejected with 400. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payment_complete_url | optional | string | Card payment only. This URL will be used to redirect the user after a successful payment. You can also use other endpoints, such as GET /v2/orders/:id, to enhance the optional custom payment completion page with additional information if needed. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payment_cancel_url | optional | string | Card payment only. This URL will be used to redirect the user if the payment is canceled |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currency | optional | string | Three-letter ISO currency code, in lowercase. Must be a supported currency. Exchange rate must exist for the selected currency ISO code. Defaults to selected standard currency. Supported currencies:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| campaign_code | optional | string | Campaign code if any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| voucher_code | optional | string | Voucher code if any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| booker_name | optional | string | Booker name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| booker_email | optional | string | Booker email | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| booker_phone | optional | string | Booker phone number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| company | optional | string | Company name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| company_number | optional | string | Orgnr. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gln_number | optional | string | GLN Number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_reference | optional | string | Invoice reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_address_1 | optional | string | Invoice address line 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_address_2 | optional | string | Invoice address line 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_address_3 | optional | string | Invoice address line 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_zipcode | optional | string | Invoice zipcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_city | optional | string | Invoice city | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_email | optional | string | Invoice email | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_firstname | optional | string | Invoice firstname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_lastname | optional | string | Invoice lastname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoice_phone | optional | string | Invoice phone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| participants | required | array |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config | optional | object |
|
Every participant gets one order line per product: the course itself, plus any add-on products. For each line, FrontCore uses the first of these prices that applies:
price on the participant. For an add-on product, put price on that product. FrontCore uses your price exactly as sent, without comparing it to any price set up in FrontCore."config": { "use_price_engine": true }. The course's price is then worked out the same way as in FrontCore's own booking form and in GET /v2/price-quote: the course's rate plan, then any price rules (such as early-bird). Member prices and add-on products are not affected.A participant with their own course price (2400) and an add-on product with its own price (400):
"participants": [
{
"firstname": "John",
"lastname": "Doe",
"email": "john@example.com",
"price": 2400,
"products": [
{ "id": 202, "price": 400 }
]
}
]
Then, on each line:
discount_percent or discount_amount on the product, or else the discount from a campaign_code. They don't add up: a discount on the product replaces the campaign's discount on that line. Anything paid with a voucher_code is subtracted from what is left.All amounts are in the booking's currency.
Example: you send "price": 1000 on the participant, and a campaign code gives 10% off. The course product has 25% VAT. The line is 1000 − 100 = 900 before VAT, and 900 + 225 = 1125 with VAT.
{
"coursedate_id": 12761394,
"payment_method": "invoice",
"campaign_code": "SUMMER10",
"participants": [
{ "firstname": "John", "lastname": "Doe", "email": "john@example.com", "price": 1000 }
]
}
You can do this in two ways.
1. Ask FrontCore for the price of the whole booking. Send the booking request with "quote": true in config (and use_price_engine if you want the price engine's prices). Nothing is booked:
{
"coursedate_id": 12761394,
"payment_method": "invoice",
"config": { "quote": true, "use_price_engine": true },
"participants": [
{ "firstname": "John", "lastname": "Doe", "email": "john@example.com" }
]
}
The response shows each participant's lines and the totals with and without VAT. Here an early-bird rule gives 10% off a course priced at 6000, with 25% VAT:
{
"successful": true,
"quote": {
"currency": "nok",
"total_before_discounts": 5400,
"total_calculated_discounts": 0,
"total_after_discounts_excl_vat": 5400,
"total_vat": 1350,
"total_after_discounts_incl_vat": 6750,
"total_spent_from_voucher": 0,
"campaign": null,
"voucher": null,
"participants": [
[
{
"product_id": 101,
"title": "Course fee",
"price": 5400,
"discount": 0,
"total_excl_vat": 5400,
"total_incl_vat": 6750,
"price_engine": {
"original_price": 6000,
"price_label": "Early bird",
"rule_id": 12,
"rateplan_id": null,
"campaign_allowed": false
}
}
]
]
}
}
When the customer confirms, send the same request without quote. price_engine is null on lines the price engine didn't price. When the price engine couldn't calculate a price, it is { "error": "..." } and the line has the product's own price.
2. Get the course's price and send it yourself. Call GET /v2/price-quote?coursedate_id=12761394 and show final_price (before VAT) to the customer:
{
"prices": [
{
"course_id": 9,
"coursedate_id": 12761394,
"final_price": 5400,
"original_price": 6000,
"price_label": "Early bird",
"currency": "NOK",
...
}
]
}
Then send it as price on the participant when booking. FrontCore charges exactly that price:
"participants": [
{ "firstname": "John", "lastname": "Doe", "email": "john@example.com", "price": 5400 }
]
Prices from the price engine can change over time, for example when an early-bird rule ends. A price you fetched earlier and send yourself is kept; with use_price_engine the booking gets the price at the moment it is made.
If the method is successful it responds with an JSON structure, as it is shown below.
{
"successful": true,
"summary": {
"order_id": "221530",
"booking_id": "472721",
"coursedate_id": "12792066",
"currency": "nok",
"total_before_discounts": 1250,
"total_calculated_discounts": 0,
"total_excl_vat": 1250,
"total_incl_vat": 1375,
"total_vat": 125,
"number_of_participants": 1,
"payment_details": {
"payment_type": "card",
"requires_redirect": true,
"payment_session_id": "61303e7d-55b6-4a3e-8995-5c679c0138b1",
"redirect_url": "https://somepaymentprovider.com/creditcard/payments/authorize/440996e71a469eb69c544218e5a933d29dcff1088d36ba68b76251df126d2dc7"
}
}
}
Unsuccessful response sample:
{
"successful": false,
"errors": [
{
"code" => some_error_code,
"message" => "A human readable error response"
}
]
}
{
"coursedate_id": "12761394",
"payment_method": "invoice",
"currency": "usd",
"booker_name": "Jane Doe",
"booker_email": "jane@example.com",
"booker_phone": "12345678",
"company": "Example Company Inc",
"company_number": 123456789,
"invoice_reference": "Ref 1234",
"invoice_address_1": "125 Holburn Lane",
"invoice_address_2": "",
"invoice_address_3": "",
"invoice_zipcode": "0262",
"invoice_city": "Heckfordbridge",
"invoice_email": "invoice@example.com",
"invoice_firstname": "Jane",
"invoice_lastname": "Doe",
"invoice_phone": "12398765",
"participants": [
{
"firstname": "John",
"lastname": "Doe",
"date_of_birth" : "1979-12-01",
"email": "john@example.com",
"phone": "987654321",
"price" : 5999,
"status_id": 1,
"products": [
{
"id": 25883,
"title": "Exam", // Added for clarity. Documentation only.
"price": 100,
"discount_percent": 50
}
],
"home_address": {
"address_line_1": "125 Holburn Lane",
"address_line_2": "",
"address_line_3": "",
"zipcode": "0262",
"city": "Heckfordbridge"
},
"work_address": {
"address_line_1": "125 Holburn Lane",
"address_line_2": "",
"address_line_3": "",
"zipcode": "0262",
"city": "Heckfordbridge"
}
}
],
"config": {
"auto_append_course_product" : true,
"allow_customer_autoconnect" : true,
"allow_user_autoconnect" : true,
"send_account_created_email_to_user" : true,
"send_receipt_email_to_participant" : true
}
}{
"payment_method": "invoice",
"coursedate_id": "12761394",
"participants": [
{
"firstname": "John",
"lastname": "Doe",
"email": "john@example.com",
"price" : 1250 // This will override the price from the automatically appended main course product.
}
],
"config": {
"auto_append_course_product" : true
}
}
| school_account_invalid | The school account provided through the api token is not valid. Check that your requests are specifying a valid account token. |
| course_identifier_invalid | Course identifier is missing or invalid. Check that your requests are specifying a valid course date ID. |
| course_date_identifier_invalid | Course date identifier is missing or invalid.. Check that your requests are specifying a valid course date ID. |
| course_date_cancelled | The course date has been cancelled. Booking is not allowed on cancelled course dates. |
| default_course_product_missing | The course price is missing. The course is not correctly configured. |
| currency_missing | Currency is either missing or not supported. |
| exchange_rate_does_not_exist | Occurs when a currency has been specified which does not have a exchange rate in the settings section |
| participant_name_invalid_empty | Participant {index} must have a name specified. Make sure requests include all required parameters. |
| participant_email_invalid_empty | Participant {index} must have an email address. Make sure requests include all required parameters. |
| participant_products_empty | Participant {index} must have a product. No course product found. Make sure that all participants have at least a course product. |
| participant_products_invalid | One of the products for participant {index} have an invalid id: {product_id}. Make sure that product ID exists on the platform. |
| participant_does_not_have_a_course_product | Participant {index} is missing the course product. |
| participant_have_multiple_course_products | Participant {index} is multiple course products. Only 1 course product pr. participant. |
| participant_product_price_invalid | Participant must have a price. Check that you have a price set for all participants. |
| participant_count_invalid | No participants found. At least one participant must be added to complete the booking. |
| internal_course_order_not_resolvable | Could not resolve order for this course. |
| internal_course_orderline_not_resolvable | Could not resolve the main orderline for this course. |
| booking_could_not_be_created | Booking could not be created. |
| order_could_not_be_created | Order could not be created. |
| campaign_code_invalid | The campaign code provided is not valid. |
| campaign_code_expired | The campaign code has expired. |
| voucher_code_invalid | The voucher code provided is not valid. |
| voucher_code_expired | The voucher code has expired |