5.6: 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.6.1: Endpoint
To create a reservation, you will use the following endpoint:
- Endpoint:
/api/v1/ext/order/reserve - Method: POST
5.6.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.6.3: Request Body
The request body should contain the reservation details, including:
| Field | Type | Required | Description |
|---|---|---|---|
slotId | string | Yes | A unique identifier for the tee time slot. |
persons | int64 | Yes | The number of persons for the reservation. |
customerName | string | Yes | The name of the customer making the reservation. |
customerEmail | string | Yes | The email of the customer. |
customerMobile | string | Yes | The mobile contact of the customer. |
customerId | string | No | The customer identifier from your system. See important note below. |
⚠️ Important —
customerIdfield:
- Wallet-based payment: If your agency settles payments via the Golfdigg credit wallet, you do not need to send
customerId.- Golfdigg Payment Gateway: If your agency uses the Golfdigg payment gateway to process payments, you must provide
customerIdin every reservation request. This field is used to associate the payment with the correct customer in the payment flow.
5.6.4: Response Format
Once a reservation is created, the order will progress through the following statuses:
| Status | Description |
|---|---|
PENDING | The reservation has been created and is awaiting payment or confirmation. |
PAID | The reservation has been successfully paid and confirmed. |
CANCEL | The reservation has been cancelled. |
REFUND | The reservation has been refunded. |
Note: A newly created reservation will always have a status of
PENDING.
5.6.5: 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). See status table above. |
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 tee time 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 applying a 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 identifier from the 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 tee time 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.6.6: 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"
}
For agencies using the Golfdigg payment gateway, include customerId:
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",
"customerId": "your_customer_id"
}
5.6.7: Response Example
The API will respond with a reservation with a status of PENDING.
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, transaction number, and initial status of PENDING.