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β
| Header | Required | Description |
|---|---|---|
| Content-Type | Yes | Must be application/json |
| Authorization | Yes | Format: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature |
π Request Bodyβ
| Field | Type | Required | Description |
|---|---|---|---|
organizationId | string (UUID) | Yes | UUID of the organization the record belongs to |
entityType | enum | Yes | Channel that produced the lost opportunity. One of: iCall, iChat, booking |
interactionId | string | Yes | Identifier of the interaction (iCall, iChat, or booking) that was lost |
status | enum | Yes | One of: pending, processed, rejected |
reason | string | Yes | Short text describing why the opportunity was lost |
userGroupId | string (UUID) | No | User group this record is assigned to |
comment | string | No | Free-form comment from the agent or system |
origin | string | No | Origin name where the lost opportunity was captured |
userEmail | string | No | Email address (validated against RFC format when present) |
userPhone | string | No | Phone number (free-form, E.164 recommended) |
extraFields | object | No | Custom metadata bag for integration-specific data |
externalId | string | No | External 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)β
| Field | Type | Description |
|---|---|---|
id | string (UUID) | Unique identifier for the newly created record |
organizationId | string (UUID) | Organization ID |
organizationName | string | Denormalized organization name |
entityType | enum | Channel that produced the lost opportunity |
interactionId | string | Source interaction identifier |
status | enum | Record status |
reason | string | Loss reason |
comment | string | Free-form comment |
origin | string | Origin name |
userEmail | string | Contact email |
userPhone | string | Contact phone |
extraFields | object | Custom metadata |
userGroupId | string (UUID) | Assigned user group ID |
userGroup | string | Denormalized user group name |
involvedAgent | string (UUID) | Agent that handled the interaction |
visibleAt | string (ISO 8601) | Datetime the record becomes visible to agents |
externalId | string | External identifier |
createdAt | string (ISO 8601) | Creation timestamp |
updatedAt | string (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",
"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β
- Required fields
organizationId,entityType,interactionId,status,reasonmust be provided
- Enum values
entityTypeβ bookingstatusβ rejected (DTO does not acceptdraft)
- Format
organizationId,userGroupIdmust be valid UUIDsuserEmailmust be a valid email address (when provided)
π‘ Best Practicesβ
- Capture
- Always send
organizationId,entityType,interactionId, andreason - Use
externalIdto link to your upstream system
- Always send
- Reasoning
- Keep
reasonshort and consistent (e.g. use a fixed vocabulary) - Use
commentfor free-form notes
- Keep
- Classification
- Set
originto track the capture surface (e.g. "Website contact form") - Use
extraFieldsfor channel-specific metadata
- Set
π Notesβ
- The
organizationIdmust match an organization accessible by your credentials involvedAgent,organizationName,userGroup, andvisibleAtare 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
reasonfor reporting