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_HOLDworkflow - ISSUED booking →
BOOKING_CONFIRMEDworkflow
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
| Parameter | Type | Required | Description |
|---|---|---|---|
ve_id | number | Yes | Booking 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:
| Field | Type | Description |
|---|---|---|
data.booking_id | number | Booking ID confirmed |
data.pnr | string | PNR confirmed |
data.airline | string | Airline code |
data.workflow | string | Email 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)
🔗 Related APIs
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
| Feature | SkyAgent Email (Kafka) | VJ Email API |
|---|---|---|
| Method | Async (queue) | Sync (direct) |
| Speed | Fast response | Slower |
| Template | SkyAgent custom | VJ standard |
| Language | Vietnamese | Multi-language support |
| Retry | Auto (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