Bookings
Create, fetch, and cancel reservations. Each booking owns a booking_code from the provider and a local_number internal to GreenFlow; both are accepted as {code}.
POST /bookings — create
Consumes the tokenc minted by POST /fleet/show. On 201, the server persists a Booking + Sale, queues the voucher PDF job, and sends the confirmation email.
Fields
| Field | Type | Notes |
|---|---|---|
| brand | int | required. Same vendor id as in /fleet/list. |
| pickup_location / dropoff_location | string | required. Office code. |
| pickup_date / dropoff_date | datetime | required. Format Y-m-d\TH:i:s (no offset). |
| rate | string | required. From rates[].code. |
| vehicle_code | string | required. From cars[].vehicle_code. |
| tokenc | uuid | required. From /fleet/show. |
| coupon_code | string | optional. See coupons. |
| customer.* | object | required. See curl below. |
| airline / frequent_flyer | object | optional. Propagated to ABG/ANE adapters. |
| mail_notification / sms_notification | bool | Defaults true / false. |
bash
curl -X POST https://greenflow.live/api/v1/bookings \
-H "Authorization: Bearer gfc_7s2wprmy_DWTZRBGBEV6La4dTOoFdMkEhWmWCsXdwc3zVMnqP" \
-H "Content-Type: application/json" \
-d '{
"brand": 11,
"pickup_location": "AACGH", "dropoff_location": "AACGH",
"pickup_date": "2026-05-15T10:00:00", "dropoff_date": "2026-05-18T10:00:00",
"rate": "011880", "vehicle_code": "B",
"tokenc": "836c7fb31f624ca2a8b5a519f26825d2",
"customer": {
"name": "Joao", "lastname": "Silva", "email": "joao@example.com", "age": 30,
"address": { "country_code": "BR" },
"telephone": { "phone_number": "11987654321" }
}
}'
json
{
"data": {
"uuid": "01935f1e-9b0a-7c88-b9e3-3f7c8e9d1a02",
"booking_code": "BR-1234567",
"local_number": "GFC042389XY",
"brand": "LOCALIZA",
"name": "Joao", "last_name": "Silva",
"voucher": { "status": "queued" }
}
}
Side effects
- Creates a
Booking(statusRESERVED) andSale(PENDING) in a DB transaction. - Queues the voucher PDF emission + booking confirmation email.
- Dispatches the
booking.createdwebhook event. - Writes a
booking.createdaudit log row.
GET /bookings/{code}
Requires lastname as a query parameter — lightweight pseudo-auth so the code alone is not sufficient to read the booking.
bash
curl -s "https://greenflow.live/api/v1/bookings/BR-1234567?lastname=Silva" \
-H "Authorization: Bearer gfc_7s2wprmy_DWTZRBGBEV6La4dTOoFdMkEhWmWCsXdwc3zVMnqP"
json
{
"data": {
"uuid": "01935f1e-9b0a-7c88-b9e3-3f7c8e9d1a02",
"booking_code": "BR-1234567",
"local_number": "GFC042389XY",
"status": "RESERVED",
"pickup_date": "2026-05-15 10:00:00",
"dropoff_date": "2026-05-18 10:00:00",
"gds": { "booking_code": "BR-1234567", "status": "RESERVED" }
}
}
DELETE /bookings/{code}
Cancels upstream. If a coupon was applied, it is reverted and the usage slot freed.
bash
curl -X DELETE https://greenflow.live/api/v1/bookings/BR-1234567 \
-H "Authorization: Bearer gfc_7s2wprmy_DWTZRBGBEV6La4dTOoFdMkEhWmWCsXdwc3zVMnqP"
json
{ "data": { "success": true, "booking_code": "BR-1234567", "local_number": "GFC042389XY" } }
Errors
| HTTP | Body |
|---|---|
| 401 | {"message": "Invalid API key"} |
| 422 | {"error": {"message": "RATE NOT AVAILABLE FOR THIS CAR CLASS"}} |
| 422 | {"error": "coupon_validation_failed", "reason": "coupon_expired"} |
| 404 | Cross-tenant booking or mismatched lastname. |