Buy Bus Ticket Endpoint (V2)

✅ CURRENT VERSION - This endpoint supports both Timed Schedules and Random Schedules.

This V2 endpoint handles transport ticket purchases for both Timed and Random schedules. When your customers call this endpoint through your platform, transport tickets for their selected route are created and sent to their email. You can track all purchases from your MERPI dashboard.

Key Features

  • Unified Endpoint: Handles both Timed and Random schedule types

  • Dynamic Request Structure: Request body adapts based on schedule_type

  • Flexible Seat Handling:

    • Timed schedules: Customers select specific seats

    • Random schedules: No seat selection required (seats assigned automatically)

  • Email Delivery: Tickets are automatically sent to the customer's email

  • Next of Kin Information: Required for safety and emergency contact purposes

Understanding Schedule Types

Timed Schedules

  • Fixed departure times (e.g., 6:00 AM)

  • Requires seat selection - customers choose specific seats from available options

  • Fixed pricing per seat

  • Best for long-distance routes with predictable timing

Random Schedules

  • Flexible departure within operating windows (e.g., 6:00 AM - 11:00 PM)

  • No seat selection needed - seats assigned automatically upon boarding

  • Number of passengers specified instead of seat IDs

  • Best for short-distance routes with frequent departures

API Reference

Endpoint

Buy Bus Tickets (V2 - Supports both Timed and Random schedules)

post

Endpoint to purchase bus tickets for a specific schedule. This V2 endpoint supports both Timed Schedules (fixed departure times with seat selection) and Random Schedules (flexible timing with automatic seat assignment). The request structure varies based on the schedule_type field.

Body
or
Responses
post
/api/v2/merpi/transport/buy/tickets

Request Body - Timed Schedule

Parameter
Type
Required
Description

schedule_type

String

Yes

Must be "timed" for timed schedules

schedule_id

Integer

Yes

Unique identifier for the bus schedule being booked (from Get Schedules endpoint)

seats

Array[Integer]

Yes

List of seat IDs being booked (e.g., [9, 4, 3] indicates seats with ID 9, 4, and 3)

departure_date

String

Yes

Date and time of departure in format: YYYY-MM-DD HH:MM (e.g., "2024-07-23 20:21")

customer_info

Object

Yes

Customer information object

customer_info.name

String

No

Full name of the customer

customer_info.email

String

Yes

Email address (tickets will be sent here)

customer_info.phone_number

String

Yes

Customer's phone number

customer_info.dob

String

No

Date of birth in format: DD/MM/YYYY

customer_info.username

String

No

Username for the customer

customer_info.kin

Object

No

Next of kin information

customer_info.kin.first_name

String

No

First name of next of kin

customer_info.kin.last_name

String

No

Last name of next of kin

customer_info.kin.phone_number

String

No

Phone number of next of kin

customer_info.kin.email

String

No

Email of next of kin

customer_info.kin.gender

String

No

Gender of next of kin (e.g., "male", "female")

customer_info.kin.relationship

String

No

Relationship to customer (e.g., "son", "daughter", "spouse")

Request Body - Random Schedule

Parameter
Type
Required
Description

schedule_type

String

Yes

Must be "random" for random schedules

route_id

Integer

Yes

ID of the route being booked

bus_id

Integer

Yes

ID of the bus for this trip (from buses array in Get Schedules response)

no_of_passengers

Integer

Yes

Number of passengers traveling

departure_time

String

Yes

Preferred departure time in format: HH:MM (24-hour format)

departure_date

String

Yes

Date and time of departure in format: YYYY-MM-DD HH:MM (e.g., "2024-07-23 20:21")

customer_info

Object

Yes

Customer information object

customer_info.name

String

No

Full name of the customer

customer_info.email

String

Yes

Email address (tickets will be sent here)

customer_info.phone_number

String

Yes

Customer's phone number

customer_info.dob

String

No

Date of birth in format: DD/MM/YYYY

customer_info.username

String

No

Username for the customer

customer_info.kin

Object

No

Next of kin information

customer_info.kin.first_name

String

No

First name of next of kin

customer_info.kin.last_name

String

No

Last name of next of kin

customer_info.kin.phone_number

String

No

Phone number of next of kin

customer_info.kin.email

String

No

Email of next of kin

customer_info.kin.gender

String

No

Gender of next of kin (e.g., "male", "female")

customer_info.kin.relationship

String

No

Relationship to customer (e.g., "son", "daughter", "spouse")

Response Fields Comparison

Common Fields (Both Schedule Types)

Field
Type
Description

success

Boolean

Indicates if the request was successful

status

Integer

HTTP status code (201 for successful creation)

message

String

Human-readable message about the result

data.reference

String

Unique transaction reference (e.g., "TR197016656")

data.invoice_id

Integer

Invoice ID for the purchase(Customer can present this at the transport terminal)

data.name

String

Customer's name

data.email

String

Customer's email (where ticket was sent)

data.phone_number

String

Customer's phone number

data.departure_date

String

Confirmed departure date and time

data.bus

Object

Complete bus information

data.schedule

Object

Schedule information for the booked trip

data.schedule_type

String

Type of schedule: "timed" or "random"

Timed Schedule Specific Fields

Field
Type
Description

data.seat

Array[Object]

Array of booked seat objects with full details

data.seat[].id

Integer

Seat ID

data.seat[].name

String

Seat position (e.g., "1-1" for row 1, column 1)

data.seat[].row

Integer

Row number

data.seat[].column

Integer

Column number

data.bus.seat_grid

Array

2D array showing all seats and availability

Random Schedule Specific Fields

Field
Type
Description

data.seat

Array

Empty array - seats assigned automatically upon boarding

data.no_of_passengers

Integer

Number of passengers booked

data.route_id

Integer

Route ID for the trip

data.bus_id

Integer

Bus ID for the trip

data.schedule.start_time

String

Operating window start time

data.schedule.end_time

String

Operating window end time

data.schedule.price

Integer/Number

Price for the schedule

Key Differences Summary

Key Aspect
Timed Schedule
Random Schedule

Request Field

schedule_id + seats

route_id + bus_id + no_of_passengers

Seat Selection

Required - customer chooses seats. If not, available random seats are assigned.

Not required - auto-assigned upon boarding

Departure Time

Fixed time from schedule

Customer's preferred time within window

Response Seats

Array of seat objects with details

Empty array []

Use Case

Long-distance, fixed schedule

Short-distance, flexible timing

Implementation Guide

Determine Schedule Type

After calling the Get Schedules endpoint, check the schedule_type field:

Build Request Based on Schedule Type

For Timed Schedules:

For Random Schedules:

Last updated