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 to application/json.

5.6.3: Request Body

The request body should contain the reservation details, including:

FieldTypeRequiredDescription
slotIdstringYesA unique identifier for the tee time slot.
personsint64YesThe number of persons for the reservation.
customerNamestringYesThe name of the customer making the reservation.
customerEmailstringYesThe email of the customer.
customerMobilestringYesThe mobile contact of the customer.
customerIdstringNoThe customer identifier from your system. See important note below.

⚠️ Important — customerId field:

  • 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 customerId in 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:

StatusDescription
PENDINGThe reservation has been created and is awaiting payment or confirmation.
PAIDThe reservation has been successfully paid and confirmed.
CANCELThe reservation has been cancelled.
REFUNDThe 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:

FieldTypeDescription
idstringUnique identifier for the reserve.
statusstringCurrent status of the reserve (e.g., PENDING). See status table above.
txNostringTransaction number associated with the reserve.
agencyIdstringIdentifier of the agency making the reservation.
agencyNamestringName of the agency making the reservation.
slotIdstringIdentifier of the tee time slot being reserved.
courseIdstringIdentifier of the associated golf club/course.
courseNamestringName of the golf club/course being reserved.
walletIdstringIdentifier of the wallet used for the reservation.
customerNamestringName of the customer making the reservation.
customerEmailstringEmail of the customer making the reservation.
customerMobilestringMobile number of the customer making the reservation.
amountnumberAmount paid for the reservation.
priceAfterDiscountintPrice after applying a discount code.
reserveIdstringUnique identifier for the specific reservation.
additionGolferstring[]List of additional golfers added to the reservation.
reserveobjectDetails of the reservation, including a sub-object with reservation specifics.
customerIdstringCustomer identifier from the agency system.
createdAtstringDate and time when the reservation was created.
updatedAtstringDate and time when the reservation was last updated.

The reserve object within the Reservation object:

FieldTypeDescription
idstringUnique identifier for the reservation.
codestringCode associated with the reservation.
gdInvoiceIdstringInvoice ID in the Golf Digg system.
statusstringCurrent status of the reservation (e.g., BOOKING).
slotTimenumberStart time of the tee time slot in milliseconds.
slotTimeStringstringFormatted start time string with timezone.
personsnumberNumber of persons for the reservation.
cartsnumberNumber of golf carts requested for the reservation.
caddiesnumberNumber 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.