Skip to main content

Send SkyAgent Email - Gửi Email Qua Kafka Queue

API Endpoint: POST /api/v1/services/booking/v1/ve/{ve_id}/send-email


Overview

Send booking confirmation email to passenger via SkyAgent Kafka queue.

Email Type:

  • HOLD booking → BOOKING_HOLD workflow
  • ISSUED booking → BOOKING_CONFIRMED workflow

Method: Asynchronous (Kafka queue)


API Specification

Endpoint

POST {{base_url}}/api/v1/services/booking/v1/ve/{ve_id}/send-email

Headers

{
"Content-Type": "application/json",
"Authorization": "Bearer {access_token}"
}

URL Parameters

ParameterTypeRequiredDescription
ve_idnumberYesBooking ID

Request Body

{}

Note: Empty body - all data retrieved from booking ID


Success Response

Status: 200 OK

{
"message": "Email notification sent to queue successfully",
"data": {
"booking_id": 659,
"pnr": "59EEKU",
"airline": "VJ",
"workflow": "BOOKING_HOLD",
"message": "Email notification queued successfully. Workflow: BOOKING_HOLD"
},
"status": "success",
"code": 200
}

Response Fields:

FieldTypeDescription
data.booking_idnumberBooking ID confirmed
data.pnrstringPNR confirmed
data.airlinestringAirline code
data.workflowstringEmail workflow type

Email Workflows

BOOKING_HOLD

Sent when: HOLD booking created

Email contains:

  • Booking details (PNR, route, date)
  • Payment deadline
  • Total amount to pay
  • Payment link

BOOKING_CONFIRMED

Sent when: Ticket issued (ISSUED booking)

Email contains:

  • E-ticket details
  • Flight information
  • Passenger details
  • No payment required message

Usage Example

// Send email for HOLD booking
const result = await fetch(`/api/v1/services/booking/v1/ve/${ve_id}/send-email`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});

const response = await result.json();
console.log('Workflow:', response.data.workflow);
// Output: "BOOKING_HOLD" or "BOOKING_CONFIRMED"

Email Processing

Processing:

  • Immediate API response (queued)
  • Async email sending (within ~5 seconds)
  • Retry on failure (3 attempts)

🐛 Error Handling

Booking Not Found

Response:

{
"status": "error",
"message": "Booking not found",
"code": 404
}

Email Already Sent

Note: API allows re-sending emails (no duplicate prevention)


Prerequisites:

  • 02-GET-DETAILS.md - Get booking info

Alternative:

  • 07-SEND-VJ-EMAIL.md - Send email via VJ API (direct, not Kafka)

Important Notes

Kafka vs VJ Email

FeatureSkyAgent Email (Kafka)VJ Email API
MethodAsync (queue)Sync (direct)
SpeedFast responseSlower
TemplateSkyAgent customVJ standard
LanguageVietnameseMulti-language support
RetryAuto (3x)Manual

When to Use

Use SkyAgent Email:

  • After booking creation
  • Custom email template needed
  • Vietnamese language preferred

Use VJ Email:

  • Need multi-language
  • Official VJ branding required
  • Direct itinerary from VJ