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 to application/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:

FieldTypeDescription
idstringUnique identifier for the reserve.
statusstringCurrent status of the reserve (e.g., PENDING).
txNostringTransaction number associated with the reserve.
agencyIdstringIdentifier of the agency making the reservation.
agencyNamestringName of the agency making the reservation.
slotIdstringIdentifier of the teetime 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 use 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 id from 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 teetime 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.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.