5.5: Create a Reservation
In this section, we will walk you through the process of creating a reservation for a tee time using the Golfdigg OTA API.
5.5.1: Endpoint
To create a reservation, you will use the following endpoint:
- Endpoint:
/api/v1/ext/order/reserve - Method: POST
5.5.2: Request Parameters
In your API request, include the following parameters:
Authorization(Header): Use Basic Authentication with your API credentials.Content-Type(Header): Set toapplication/json.
5.5.3: Request Body
The request body should contain the reservation details, including:
slotId: A unique identifier for the tee time slot.persons: The number of persons for the reservation.customerName: The name of the customer making the reservation.customerEmail: The email of the customer.customerMobile: The mobile contact of the customer.
5.5.4: Response Format
The API response will be a JSON object representing a Reservation object, with the following format:
interface Reserve {
id: string;
status: string;
txNo: string;
agencyId: string;
agencyName: string;
slotId: string;
courseId: string;
courseName: string;
walletId: string;
customerName: string;
customerEmail: string;
customerMobile: string;
amount: number;
priceAfterDiscount: number;
reserveId: string;
additionGolfer: string[];
reserve: {
id: string;
code: string;
gdInvoiceId: string;
status: string;
golf: {
slotTime: number;
slotTimeString: string;
persons: number;
carts: number;
caddies: number;
};
};
customerId: string;
createdAt: string;
updatedAt: string;
}
Here's a description of the fields in the response:
| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier for the reserve. |
| status | string | Current status of the reserve (e.g., PENDING). |
| txNo | string | Transaction number associated with the reserve. |
| agencyId | string | Identifier of the agency making the reservation. |
| agencyName | string | Name of the agency making the reservation. |
| slotId | string | Identifier of the teetime slot being reserved. |
| courseId | string | Identifier of the associated golf club/course. |
| courseName | string | Name of the golf club/course being reserved. |
| walletId | string | Identifier of the wallet used for the reservation. |
| customerName | string | Name of the customer making the reservation. |
| customerEmail | string | Email of the customer making the reservation. |
| customerMobile | string | Mobile number of the customer making the reservation. |
| amount | number | Amount paid for the reservation. |
| priceAfterDiscount | int | Price after use discount code. |
| reserveId | string | Unique identifier for the specific reservation. |
| additionGolfer | string[] | List of additional golfers added to the reservation. |
| reserve | object | Details of the reservation, including a sub-object with reservation specifics. |
| customerId | string | Customer id from agency system. |
| createdAt | string | Date and time when the reservation was created. |
| updatedAt | string | Date and time when the reservation was last updated. |
The reserve object within the Reservation object:
| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier for the reservation. |
| code | string | Code associated with the reservation. |
| gdInvoiceId | string | Invoice ID in the Golf Digg system. |
| status | string | Current status of the reservation (e.g., BOOKING). |
| slotTime | number | Start time of the teetime slot in milliseconds. |
| slotTimeString | string | Formatted start time string with timezone. |
| persons | number | Number of persons for the reservation. |
| carts | number | Number of golf carts requested for the reservation. |
| caddies | number | Number of caddies requested for the reservation. |
5.5.5: Request Example
Here's an example of how to structure your API request to create a reservation:
POST /api/v1/ext/order/reserve
Host: ota-api.golfdigg.com
Authorization: Basic base64_encoded(apiKey)
Content-Type: application/json
{
"slotId": "653f6746e4b0fb16f3e2d290",
"persons": 3,
"customerName": "Your customer name",
"customerEmail": "Your customer email",
"customerMobile": "Your customer mobile
}
5.5.6: Response Example
The API will respond will response a reservation with a status BOOKING.
Here's a sample response body:
{
"id": "654c6299d6661a759a63f2e2",
"status": "PENDING",
"txNo": "ORDER-2023-11-09-66978172",
"agencyId": "6538dd8d227235165f374846",
"agencyName": "golfdigg test2",
"slotId": "653f6746e4b0fb16f3e2d292",
"courseId": "5c9c8252ef0ab53dcf12e8d2",
"courseName": "331 GOLF CLUB-test",
"walletId": "6538dd8e227235165f374847",
"customerName": "testApi",
"customerEmail": "testApi",
"customerMobile": "testApi",
"amount": 172000,
"priceAfterDiscount": 172000,
"reserveId": "654c6298e4b0d75122af7384",
"reserve": {
"id": "654c6298e4b0d75122af7384",
"code": "G231109-00002",
"gdInvoiceId": "",
"status": "BOOKING",
"golf": {
"slotTime": 1700131800000,
"slotTimeString": "2023-11-16T17:50:00+0700",
"persons": 1,
"carts": 1,
"caddies": 1,
}
},
"createdAt": "2023-11-09T11:39:52.145760151+07:00",
"updatedAt": "2023-11-09T11:39:52.145760151+07:00"
}
This response provides essential information about the created reservation, including the reservation ID, confirmation number, and status.