Saltar al contenido principal

Create Lost Opportunity

This endpoint creates a new lost opportunity associated with your organization. It is typically invoked by an integration after an iCall, iChat, or booking interaction fails to convert.

🔹 Endpoint Details​

POST /api/v1/lost-opportunities

🔒 Authentication​

HeaderRequiredDescription
Content-TypeYesMust be application/json
AuthorizationYesFormat: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature

📝 Request Body​

FieldTypeRequiredDescription
organizationIdstring (UUID)YesUUID of the organization the record belongs to
entityTypeenumYesChannel that produced the lost opportunity. One of: iCall, iChat, booking
interactionIdstringYesIdentifier of the interaction (iCall, iChat, or booking) that was lost
statusenumYesOne of: pending, processed, rejected
reasonstringYesShort text describing why the opportunity was lost
userGroupIdstring (UUID)NoUser group this record is assigned to
commentstringNoFree-form comment from the agent or system
originstringNoOrigin name where the lost opportunity was captured
userEmailstringNoEmail address (validated against RFC format when present)
userPhonestringNoPhone number (free-form, E.164 recommended)
extraFieldsobjectNoCustom metadata bag for integration-specific data
externalIdstringNoExternal identifier from the upstream integration (e.g. Dilema form id)

📤 Request Example​

curl -X POST "https://openapi.onlive.site/api/v1/lost-opportunities" \
-H "Content-Type: application/json" \
-H "Authorization: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature" \
-d '{
"organizationId": "123e4567-e89b-12d3-a456-426614174001",
"entityType": "iCall",
"interactionId": "call_abc123",
"status": "pending",
"reason": "Customer chose a competitor",
"comment": "Customer asked to be contacted again in Q3",
"origin": "Website contact form",
"userEmail": "[email protected]",
"userPhone": "+33612345678",
"userGroupId": "550e8400-e29b-41d4-a716-446655440000",
"extraFields": {
"department": "Sales",
"location": "New York"
},
"externalId": "frm_abc123"
}'

📥 Response​

Success Response (201 Created)​

FieldTypeDescription
idstring (UUID)Unique identifier for the newly created record
organizationIdstring (UUID)Organization ID
organizationNamestringDenormalized organization name
entityTypeenumChannel that produced the lost opportunity
interactionIdstringSource interaction identifier
statusenumRecord status
reasonstringLoss reason
commentstringFree-form comment
originstringOrigin name
userEmailstringContact email
userPhonestringContact phone
extraFieldsobjectCustom metadata
userGroupIdstring (UUID)Assigned user group ID
userGroupstringDenormalized user group name
involvedAgentstring (UUID)Agent that handled the interaction
visibleAtstring (ISO 8601)Datetime the record becomes visible to agents
externalIdstringExternal identifier
createdAtstring (ISO 8601)Creation timestamp
updatedAtstring (ISO 8601)Last update timestamp

Response Example​

{
"id": "123e4567-e89b-12d3-a456-426614174000",
"organizationId": "123e4567-e89b-12d3-a456-426614174001",
"organizationName": "Acme Inc.",
"entityType": "iCall",
"interactionId": "call_abc123",
"status": "pending",
"reason": "Customer chose a competitor",
"comment": "Customer asked to be contacted again in Q3",
"origin": "Website contact form",
"userEmail": "[email protected]",
"userPhone": "+33612345678",
"extraFields": {
"department": "Sales",
"location": "New York"
},
"userGroupId": "550e8400-e29b-41d4-a716-446655440000",
"userGroup": "Sales Team",
"involvedAgent": "123e4567-e89b-12d3-a456-426614174002",
"visibleAt": "2025-05-13T15:00:00Z",
"externalId": "frm_abc123",
"createdAt": "2025-05-13T15:00:00Z",
"updatedAt": "2025-05-13T15:00:00Z"
}

❌ Error Responses​

This endpoint follows the standard error format.

🔍 Validation Rules​

  1. Required fields
    • organizationId, entityType, interactionId, status, reason must be provided
  2. Enum values
    • entityType ∈ booking
    • status ∈ rejected (DTO does not accept draft)
  3. Format
    • organizationId, userGroupId must be valid UUIDs
    • userEmail must be a valid email address (when provided)

💡 Best Practices​

  1. Capture
    • Always send organizationId, entityType, interactionId, and reason
    • Use externalId to link to your upstream system
  2. Reasoning
    • Keep reason short and consistent (e.g. use a fixed vocabulary)
    • Use comment for free-form notes
  3. Classification
    • Set origin to track the capture surface (e.g. "Website contact form")
    • Use extraFields for channel-specific metadata

📘 Notes​

  • The organizationId must match an organization accessible by your credentials
  • involvedAgent, organizationName, userGroup, and visibleAt are server-managed
  • The server enforces ownership — records cannot be created on behalf of other organizations

✅ Common Use Cases​

  • 📞 Failed iCall: Capture a missed call as a lost opportunity
  • 💬 Dropped iChat: Persist an abandoned chat for follow-up
  • 📅 Unfulfilled Booking: Track a booking that did not complete
  • 📊 Loss Analytics: Persist a structured reason for reporting