Leads
Some insurance types do not return a quote; for these types you pass the buyer's details to your provider as a lead, through your provider connection. You submit the lead with POST /api/v1/insurance/leads and follow its outcome on the lead endpoint and by webhook.
- A lead is a hand-over. Lunixi passes the lead to your provider and shows the outcome of the hand-over. A lead has no quote, premium, collection, policy or document; the next step (contacting the buyer, making an offer) is with the provider and is not part of the lead.
- Leads exist only on the API path. There are no leads on the Checkout Form or on payment links.
- A lead is not linked to a payment. A lead has no amount, currency, basket item or payment.
Authentication and signing: Flows › Authentication.
Lead types
| Type | Lead for | Schema |
|---|---|---|
MOTOR_THIRD_PARTY_LIABILITY | Compulsory motor third-party liability insurance | Lead schema version 1 |
MOTOR_COMPREHENSIVE | Comprehensive motor insurance | Lead schema version 1 |
CARGO_TRANSIT | Road cargo transit insurance | Lead schema version 1 |
To submit a lead:
- The type must be enabled on your account, and you must be using insurance on the API path.
- Your connections must have an active provider product that accepts leads for this type.
If a condition is not met, the request returns 412 insurance.type.not_available. Because lead-only types (CARGO_TRANSIT) do not return a quote, they are not listed in eligibility, and quote requests for them receive 412 insurance.type.not_available.
MOTOR_THIRD_PARTY_LIABILITY and MOTOR_COMPREHENSIVE return quotes too: Insurance Types › MOTOR_THIRD_PARTY_LIABILITY, MOTOR_COMPREHENSIVE. Leads and quotes work with separate products in your connections: a lead needs a product that accepts leads, a quote a product that returns quotes.
Flow
Collect the buyer's details
Collect the fields in the type's lead schema from your buyer: Insurance Types › Lead schemas.
Submit the lead
Call POST /api/v1/insurance/leads with the type and the fields. Lunixi validates and records the lead and passes it to your provider in the same request.
Handle the outcome
Continue according to the status in the response: Outcomes. When the provider receives the lead, the insurance.lead.submitted webhook is sent.
Submitting a lead: POST /api/v1/insurance/leads
Idempotency-Key is required. See Retries and Idempotency-Key.
| Field | Type | Required | Description |
|---|---|---|---|
insuranceType | string | Yes | The lead type, e.g. CARGO_TRANSIT. |
schemaVersion | integer | No | The lead schema version. If not sent, the type's current lead schema is used. |
policyholder | object | Depends on the type | The lead owner. |
| Type object | object | Depends on the type | Such as vehicle or shipment, under the name in the type's lead schema. |
company | object | Depends on the type | CARGO_TRANSIT only: the company's tax identity. |
note | string | No | The lead note. Text, at most 1000 characters. |
- The fields and their requirements are in the type's lead schema: Lead schemas. A field that is not in the schema is rejected.
- All field violations are returned in a single
422 insurance.validation.invalidresponse; if there is a violation, no lead is created and no request goes to the provider. - Formats: Data Formats.
A lead request for MOTOR_COMPREHENSIVE. The values are examples; replace the values in angle brackets with your buyer's details:
{
"insuranceType": "MOTOR_COMPREHENSIVE",
"policyholder": {
"identityType": "TCKN",
"identityNumber": "<identity number>",
"birthDate": "<YYYY-MM-DD>",
"email": "<email>",
"phone": "<E.164 phone>"
},
"vehicle": {
"plate": "<plate>",
"registrationDocument": {
"serial": "<serial code>",
"number": "<registration number>"
}
},
"note": "<lead note>"
}source lunixi-sign.sh
BODY='<lead request, compact JSON>'
lunixi_sign POST "/api/v1/insurance/leads" "$BODY"
curl -X POST "https://api-gateway.lunixi.com/api/v1/insurance/leads" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: insurance-lead-1001" \
-H "X-Key-Id: $LUNIXI_KEY_ID" \
-H "X-Date: $DATE" \
-H "X-Nonce: $NONCE" \
-H "Digest: $DIGEST" \
-H "X-Signature: $SIGNATURE" \
--data-raw "$BODY"The fields and an example of the CARGO_TRANSIT lead: Insurance Types › CARGO_TRANSIT.
Response
When the request completes, it returns 201 with the lead object in data. If the provider received the lead, status is SUBMITTED; if the outcome is not known, it is UNKNOWN.
Outcomes
| Outcome | Response | On the lead | What to do |
|---|---|---|---|
| The provider received the lead | 201 | status: SUBMITTED | The lead was passed on. insurance.lead.submitted is sent. |
| The outcome is not known | 201 | status: UNKNOWN | The request reached the provider but its outcome is not known. The lead is not sent again and the outcome does not become final later. Confirm with your buyer if needed; if you need to submit a new lead, use a new Idempotency-Key. |
| The provider rejected the lead | 422 insurance.lead.rejected | status: FAILED, errorCode: insurance.lead.rejected | The provider did not accept the lead; retrying the same request does not change the outcome. You can correct the details and submit a new lead with a new Idempotency-Key. |
| The product in your connection does not accept a value | 422 insurance.validation.invalid (reason: not_supported_by_provider) | status: FAILED, errorCode: insurance.validation.invalid | The request was not sent to the provider. For example, if the product accepts only Turkish mobile numbers, another number gets this outcome. Correct the value and send it again with a new Idempotency-Key. |
| The provider could not be reached | 503 insurance.provider.unavailable | status: FAILED, errorCode: insurance.provider.unavailable | The lead was not passed to the provider. Send it again after a while with a new Idempotency-Key. |
details.leadId in the error response carries the lead's ID; you can see the lead on the retrieve endpoint. If processing stops with an unexpected error, the response is 500 insurance.internal.integrity and the lead shows as UNKNOWN.
Retries and Idempotency-Key
- The lead is passed to the provider in the same request. The request can take up to 45 seconds; set your client timeout accordingly.
- If you did not receive the response after a timeout or a
5xx, repeat the request with the sameIdempotency-Keyand the same body. If the lead was created on the first attempt, no new lead is created; the existing lead is returned with its current status and is not sent to the provider again. - The same key returns the same lead whatever its status. To send a
FAILEDorUNKNOWNlead again, generate a new key. Sending anUNKNOWNlead again may create a second lead at the provider. - If you use the same key with a different request (another type, version or body), the response is
409 insurance.idempotency.conflict.
The lead object
| Field | Type | Description |
|---|---|---|
leadId | string | The lead ID (insl_…). |
insuranceType | string | The lead type, e.g. CARGO_TRANSIT. |
schemaVersion | integer | The version of the lead schema the lead was validated against. |
status | string | The lead status; see Statuses. |
errorCode | string or null | If the lead is FAILED, the Lunixi code of the reason. |
requestMasked | object | The masked view of the lead body. Personal data and the note show as ***. |
submittedAt | string or null | When the provider received the lead. null until SUBMITTED. |
createdAt | string | Creation time, ISO 8601. |
updatedAt | string | Last change time, ISO 8601. |
The lead does not carry the provider's name, code, raw message or lead reference.
Statuses
status | Meaning |
|---|---|
PENDING | The lead was created and is being passed to the provider. You only see this value in requests you read while the request is in progress or that you repeat with the same Idempotency-Key. A PENDING lead older than 5 minutes shows as UNKNOWN. |
SUBMITTED | The provider received the lead. |
UNKNOWN | The request reached the provider but its outcome is not known. The lead is not sent again. |
FAILED | The provider rejected the lead or the request did not reach the provider. The reason is in the errorCode field. |
SUBMITTED and FAILED are final; they do not change. The provider's steps after the lead (contacting the buyer, an offer or a policy) are not reflected in the lead's status.
Listing: GET /api/v1/insurance/leads
Returns your leads newest first, in cursor-based pages.
| Query parameter | Type | Description |
|---|---|---|
limit | integer | Records per page, 1-100. Default 25. |
cursor | string | pageInfo.nextCursor from the previous response. Not sent on the first page. |
insuranceType | string | Only the leads of this type. |
status | string | Only the leads in this status: PENDING, SUBMITTED, UNKNOWN or FAILED. |
In the response the leads are in the data.items array; paging information is in the pageInfo field. A malformed cursor returns 422 insurance.validation.invalid (field: cursor).
source lunixi-sign.sh
REQ_PATH="/api/v1/insurance/leads?limit=25&insuranceType=CARGO_TRANSIT"
lunixi_sign GET "$REQ_PATH"
curl "https://api-gateway.lunixi.com$REQ_PATH" \
-H "X-Key-Id: $LUNIXI_KEY_ID" \
-H "X-Date: $DATE" \
-H "X-Nonce: $NONCE" \
-H "X-Signature: $SIGNATURE"Retrieval: GET /api/v1/insurance/leads/{leadId}
Returns a single lead. In the response, data is the lead object. Use this endpoint to confirm an outcome whose webhook you did not receive.
Errors
| HTTP | code | What to do |
|---|---|---|
400 | VALIDATION_ERROR | Fix the format. This error is also returned if Idempotency-Key is missing or an undefined root field was sent. |
404 | insurance.lead.not_found | The lead was not found or belongs to another account. |
409 | insurance.idempotency.conflict | The same Idempotency-Key was used with a different request; generate a new key for a new lead. |
412 | insurance.type.not_available | The type is not a lead type, is not enabled on your account, or your connections have no product that accepts leads for this type. |
422 | insurance.validation.invalid | Fix the fields in details.errors[]. An unknown schemaVersion is returned with field: schemaVersion, reason: unsupported_schema_version. |
422 | insurance.lead.rejected | The provider did not accept the lead; the lead becomes FAILED. |
503 | insurance.provider.unavailable | The provider could not be reached; if the lead was created, it becomes FAILED. Send it again after a while with a new Idempotency-Key. |
Common codes: Flows › Responses and errors. Code details: Error Codes › Leads.
Related
- Insurance Types and Schemas: lead schemas
- Webhook Events:
insurance.lead.submitted - Error Codes: lead codes