Book Hotel Room Tickets

Purchase hotel accommodation. Allows your customers to book rooms at available hotels, apartments, or resorts.

Important: MERPI only creates transactions for successful bookings. If the booking fails for any reason (unavailable room, payment issue, etc.), no transaction record is created.

POST /v2/merpi/hotels/buy

Request Body

{
    "room_id": 10,
    "number_of_guests": 1,
    "number_of_rooms": 1,
    "checkin_date": "2026-02-03",
    "checkout_date": "2026-02-04",
    "customer_info": {
        "name": "John Doe",
        "email": "john@example.com",
        "phone_number": "+2348012345678",
        "dob": "1990-01-01"
    }
}

Request Fields

Field
Type
Required
Description

room_id

number

Yes

Room identifier from hotel rooms endpoint

number_of_guests

number

Yes

Total number of guests (must not exceed max_occupancy)

number_of_rooms

number

Yes

Number of rooms to book (of the same type)

checkin_date

string

Yes

Check-in date (YYYY-MM-DD format)

checkout_date

string

Yes

Check-out date (YYYY-MM-DD format)

customer_info

object

Yes

Guest information

Customer Info Object

Field
Type
Required
Description

name

string

No

Full name of primary guest

email

string

Yes

Guest email address

phone_number

string

No

Guest phone number (format: +234XXXXXXXXXX)

dob

string

No

Date of birth (YYYY-MM-DD format)

Header Parameters

Parameter
Type
Required
Description

X-API-KEY

string

Yes

Your API key to access this endpoint

TransactionMedium

string

Yes

Transaction medium: Web, Mobile, or POS

Content-Type

string

Yes

Must be application/json

Code Examples

JavaScript - Fetch

JavaScript - Axios

cURL

Response

Success Response (201)

Error Response (400/422)

Response Fields

Success Response (201)

Field
Type
Description

success

boolean

Indicates if the booking was successful

status

number

HTTP status code (201 for successful creation)

message

string

Success message

data

object

Booking details

Error Response (400/422)

Field
Type
Description

success

boolean

Always false for errors

status

number

HTTP error code (400 for bad request, 422 for validation errors)

message

string

Error message describing what went wrong

errors

object

Detailed validation errors (when applicable)

Data Object (Success Only)

Field
Type
Description

reference

string

Unique transaction reference number

invoice_id

number

Invoice identifier for this booking

booking_number

string

Unique booking confirmation number (use for check-in)

name

string

Guest name

email

string

Guest email

phone_number

string

Guest phone number

hotel

object

Hotel information

room

object

Room details

checkin_date

string

Check-in date (YYYY-MM-DD)

checkout_date

string

Check-out date (YYYY-MM-DD)

number_of_nights

number

Total number of nights

number_of_guests

number

Total number of guests

number_of_rooms

number

Number of rooms booked

amount

number

Total booking amount in Naira

Hotel Object

Field
Type
Description

id

number

Hotel identifier

name

string

Hotel name

location

string

Hotel location/address

Room Object

Field
Type
Description

id

number

Room type identifier

room_name

string

Room category name (e.g., Basic, Deluxe)

room_number

string

Number of rooms available in this category

Example:

  • Room price: ₦25,650/night

  • Number of nights: 1 (Feb 3 - Feb 4)

  • Number of rooms: 1

  • Total: ₦25,650

For multi-night stays:

  • Room price: ₦25,650/night

  • Number of nights: 3 (Feb 3 - Feb 6)

  • Number of rooms: 2

  • Total: ₦153,900

Important Notes

Transaction Creation: Transactions are ONLY created for successful bookings. Failed bookings do not create transaction records in the system.

Date Format: Always use YYYY-MM-DD format for dates (e.g., "2026-02-03").

Number of Nights Calculation: The system automatically calculates nights based on check-in and check-out dates. Check-out date is exclusive.

Booking Number: The booking_number field is what guests should present at hotel check-in. Make sure to display this prominently in confirmation emails/screens.

Reference Number: The reference field is the unique transaction identifier. Use this for tracking, customer support, and transaction queries.

Availability Check: Always verify room availability immediately before calling this endpoint by checking is_available in the rooms response.

Occupancy Validation: Ensure number_of_guests does not exceed the room's max_occupancy.

Phone Number Format: Use international format with country code: +234XXXXXXXXXX

Common Errors

Error Code
Error Message
Cause
Solution

422

Room is no longer available

Room already booked or unavailable

Check availability before booking

422

Invalid dates

Check-out before check-in or past dates

Ensure checkout_date > checkin_date and dates are in future

422

Exceeds occupancy

Too many guests for room type

Select larger room or book multiple rooms

400

Invalid phone format

Wrong phone number format

Use +234XXXXXXXXXX format

400

Invalid email

Malformed email address

Verify email format is correct

401

Unauthorized

Invalid or missing API key

Check X-API-KEY header

Complete Booking Flow Example

Verifying Booking Status

After successful booking, you can verify the transaction using the reference number:

See Transaction Queryarrow-up-right documentation for complete details on verifying transactions.

Last updated