Insurance
API Path
Eligibility

Eligibility

The eligibility endpoints return which insurance types you can offer your buyer for your basket items. Which insurance is offered is resolved from the insurance fields in the items, the insurance settings on your account and your provider connections. These endpoints are read-only: they do not create a quote and do not send a request to the provider.

EndpointWhen
POST /api/v1/insurance/productsBefore you create the payment. You send the items you will send in the payment in the body.
GET /api/v1/insurance/productsAfter you create the payment. You send the payment ID; the items sent when the payment was created are used.
GET /api/v1/insurance/products (without a payment ID)For types sold without a basket item: Without a basket item.

In the flow where you add the premium to your payment's basket, you get the quote and the order before the payment. So use the POST endpoint in that flow; see Premium and Payment.

Authentication and signing: Flows › Authentication.

Before the payment: POST /api/v1/insurance/products

FieldTypeRequiredDescription
currencystringYesCurrency of the payment, ISO 4217 (TRY).
context.itemsarrayYesThe basket items you will send in the payment; 1-100 entries. The format is the same as the payment request's basketItems[]: Basket Items.
context.items[].insuranceContextobjectNoThe item's non-personal details (trip, model, dates and so on). The response's prefill is filled from them: Basket Items › Insurance context.
context.items[].insuranceDataobjectNoThe personal details you know for the quote and the policy (insured person, booking code, IMEI, plate and so on). Not stored; the response's providedFields and quoteReady are computed from it: Basket Items › Insurance data.
insuranceTypestringNoOnly this insurance type. Example: TICKET_CANCELLATION.
  • The items you want to offer insurance for must carry insurance fields. At least insuranceCategory is needed: Basket Items › Insurance fields.
  • If one of the items carries insurance fields, the item ids must be unique.
  • Insurance is per unit: in an item carrying insurance fields, send each unit as a separate item.
  • You can send insuranceData in the items; it is not stored and is used only to compute the pre-fill fields of this response: Pre-fill data and the automatic quote.

A basket with two tickets. The first ticket also carries the trip and the passenger's details; the second only the insurance fields. The values are examples; replace the values in angle brackets with your buyer's details:

{
  "currency": "TRY",
  "context": {
    "items": [
      {
        "id": "ticket-1",
        "name": "Izmir-Ankara train ticket",
        "price": 50000,
        "category1": "ticket",
        "itemType": "VIRTUAL",
        "insuranceCategory": "TICKET",
        "insuranceTypes": ["TICKET_CANCELLATION"],
        "insuranceContext": {
          "transportMode": "TRAIN",
          "departureAt": "2025-12-23T12:50:00+03:00",
          "originCity": "Izmir",
          "destinationCity": "Ankara",
          "carrier": "Sample Carrier"
        },
        "insuranceData": {
          "insured": [
            { "identityType": "TCKN", "identityNumber": "<identity number>", "birthDate": "<YYYY-MM-DD>" }
          ],
          "tickets": { "priceAmount": 50000 }
        }
      },
      {
        "id": "ticket-2",
        "name": "Izmir-Ankara train ticket",
        "price": 50000,
        "category1": "ticket",
        "itemType": "VIRTUAL",
        "insuranceCategory": "TICKET",
        "insuranceTypes": ["TICKET_CANCELLATION"]
      }
    ]
  }
}
source lunixi-sign.sh
BODY='{"currency":"TRY","context":{"items":[...]}}'
lunixi_sign POST "/api/v1/insurance/products" "$BODY"
 
curl -X POST "https://api-gateway.lunixi.com/api/v1/insurance/products" \
  -H "Content-Type: application/json" \
  -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"

Replace [...] in BODY with your items as compact JSON.

After the payment: GET /api/v1/insurance/products

Query parameterTypeRequiredDescription
paymentIntentIdstring (UUID)NoLunixi payment ID. If omitted, the types sold without a basket item are returned: Without a basket item.
currencystringYesCurrency of the payment, ISO 4217.
insuranceTypestringNoOnly this insurance type.
  • The items are the ones you sent when the payment was created with POST /api/v1/payments/intents. A value you send later does not replace the items.
  • The items' insuranceData is deleted once the payment is 24 hours old; after that, providedFields no longer appears in the response.
  • currency must equal the payment's currency; otherwise the request returns 422 insurance.validation.invalid (reason: currency_mismatch).
  • If the payment was not created with insured items, the list is empty.
source lunixi-sign.sh
REQ_PATH="/api/v1/insurance/products?paymentIntentId=<payment ID>&currency=TRY"
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"

Without a basket item: GET /api/v1/insurance/products

If you do not send paymentIntentId, the response returns the insurance types sold without a basket item. These types are sold only on the API path; flow: Selling Without a Basket Item.

  • The response contains only types sold without a basket item; basketItemIds is an empty array.
  • When you query with items or with a payment ID, types sold only without a basket item are not listed.
  • Lead types, which do not return a quote, are not in this list: Leads.
source lunixi-sign.sh
REQ_PATH="/api/v1/insurance/products?currency=TRY"
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"

Response

All endpoints return the same response: data.products is the list of insurance types offered. The list is sorted by the type order on your account.

FieldTypeDescription
insuranceTypestringInsurance type code. You send this code in the quote request.
typeObjectstringName of the type's object in the quote request. Example: tickets for TICKET_CANCELLATION.
schemaVersionintegerCurrent schema version of the type.
basketItemIdsstring[]ids of the basket items this type is offered for.
titleobjectName of the type; text by language code (tr-TR, en-US).
descriptionobjectDescription of the type; text by language code. An empty object if there is no description.
fieldsarrayFields in the type's schema: field name, its format and the stage at which it is required (requiredAt: QUOTE or POLICY).
prefillobjectThe non-personal fields filled from the items' insuranceContext, in the format of the quote request. A field also given in insuranceData is not included here. An empty object if there is none. See Pre-fill data and the automatic quote.
providedFieldsarrayThe fields provided by the items' insuranceData. Each entry carries path (the field path, for example insured[0].birthDate) and masked (the masked value). An empty array if there is none.
quoteReadybooleantrue if the details in the items are enough for a quote: you can get the quote without sending further fields. false if there is no context and no pre-fill data.
insuranceDataIssuesarrayPre-fill data that cannot be used. Each entry carries basketItemId, field and reason; no value is written. An empty array if there is no issue.

fields shows which fields you need to send in your quote request. Field descriptions and rules: Insurance Types and Schemas.

Pre-fill data and the automatic quote

prefill, providedFields, quoteReady and insuranceDataIssues are computed from the insuranceContext and insuranceData fields of the basket items: Basket Items › Insurance pre-fill data.

  • On the GET endpoint the items are the ones you sent when the payment was created. On the POST endpoint the context.items[].insuranceData in the body is used and not stored.
  • providedFields never returns a personal value in plain form: personal values become ***; non-personal values such as identityType, amounts and dates are returned as they are.
  • quoteReady: true shows that the context and pre-fill data meet the required fields of the quote stage and the quote rules of at least one of your enabled products. You can get the quote with only insuranceType, currency and the basket source: Quote › Quote with pre-fill data. It does not guarantee that the provider makes an offer.
  • The type object in prefill and providedFields is built from the items that carry context or pre-fill data. An item that carries neither does not appear in these objects.
  • A field does not appear in both prefill and providedFields; pre-fill data takes precedence over the context.

The response for a basket with a single ticket carrying insuranceContext and insuranceData. title, description and fields are left out of the example:

{
  "data": {
    "products": [
      {
        "insuranceType": "TICKET_CANCELLATION",
        "typeObject": "tickets",
        "schemaVersion": 1,
        "basketItemIds": ["ticket-1"],
        "prefill": {
          "tickets": [
            {
              "basketItemId": "ticket-1",
              "transportMode": "BUS",
              "carrier": "Example Carrier",
              "departureAt": "2025-12-23T12:50:00+03:00",
              "originCity": "Ankara",
              "destinationCity": "Istanbul"
            }
          ]
        },
        "providedFields": [
          { "path": "tickets[0].priceAmount", "masked": 50000 },
          { "path": "insured[0].identityType", "masked": "PASSPORT" },
          { "path": "insured[0].identityNumber", "masked": "***" },
          { "path": "insured[0].birthDate", "masked": "***" }
        ],
        "quoteReady": true,
        "insuranceDataIssues": []
      }
    ]
  }
}

Pre-fill data that cannot be used

If an item's pre-fill data does not fit the type's schema, the payment does not stop; that item's pre-fill data is not used and the reason is returned in insuranceDataIssues:

{
  "insuranceDataIssues": [
    { "basketItemId": "phone-1", "field": "device.imei", "reason": "invalid_imei" }
  ]
}
reasonReason
unknown_fieldThe field is not in the schema of any of the item's insurance types.
not_applicableThe field does not apply in this case; for example an airport code on a ticket with transportMode: BUS.
no_matching_schemaThe pre-fill data fits none of the item's insurance types; for example both a device and a vehicle object on the same item. The field value is insuranceData.
unavailableThe pre-fill data could not be read at the moment. The fields are asked of the buyer; you can send these fields in the quote request.
Other reasonsThe value does not fit the type's format (for example invalid_imei, invalid_checksum, invalid_format). The reasons are the same as for insurance.validation.invalid.

Correct the pre-fill data and send it with a new payment, or send the missing fields in the quote request. Treat a reason you do not recognise as meaning the field is invalid.

Product requirements

A type's schema covers the fields of every product that offers the type. The fields array also shows the rules of the enabled products in your connections:

FieldTypeDescription
requiredAtstringThe stage at which the field is required by the type's schema or by all your enabled products: QUOTE or POLICY. Absent if the field is optional.
requiredByarrayShows that the field is needed at an earlier stage, or only by some of your products. Each entry carries underwriterCode (the insurance company's Lunixi code; null if no company is stated) and stage (QUOTE or POLICY). Absent if there is no such product.

If you do not send a field listed in requiredBy at that stage, only that product's option is excluded from the quote: Quotes › Excluded options. To get every option, send these fields as well.

Empty list

If data.products is an empty array, no insurance is offered for this basket. An empty list is not an error and does not affect your payment; you can take the payment without insurance.

The list is empty when:

  • Insurance or the API path is not enabled on your account.
  • The items carry no insurance fields, an item carries insuranceEligible: false, or the requested type does not match the item's category.
  • The type is not enabled on your account or the item does not meet the type's eligibility conditions.
  • You have no usable provider connection with the type enabled.
  • You queried without a basket item and your account has no enabled type sold without a basket item.

Checklist: Testing › If insurance is not offered.

Errors

HTTPcodeWhat to do
400VALIDATION_ERRORFix the format of currency, paymentIntentId, insuranceType or the items; details.errors shows the invalid field.
422insurance.validation.invalidThe items do not satisfy the rules; details.errors[] lists the violations.

Common codes: Flows › Responses and errors.

Related