Insurance
API Path
Policy Document

Policy Document

GET /api/v1/insurance/policies/{policyId}/document returns the document of an issued policy as a PDF.

  • Lunixi does not store the document. It is fetched from the provider on every request and passed to you as is.
  • Insurance is per unit; each basket item has its own policy and its own document. You take the policyId value from the order's policies[] array: Order object.

Authentication and signing: Flows › Authentication.

Request

Path parameterDescription
policyIdPolicy ID (insp_…).
source lunixi-sign.sh
REQ_PATH="/api/v1/insurance/policies/<policyId>/document"
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" \
  -o policy.pdf

Response

A successful response returns 200 and the body is the PDF file itself; there is no JSON envelope.

HeaderValue
Content-Typeapplication/pdf
Content-Dispositionattachment; filename="<policyId>.pdf"
Cache-Controlno-store

Error responses are the JSON error envelope, as on the other endpoints. Tell the PDF apart from an error by the response's Content-Type header.

The document carries your buyer's personal data; so the response is not cached (no-store).

When the document is available

The document is available while the policy is in force: the policy's policyStatus must be ISSUED or CANCEL_PENDING. What counts is the status of that policy (policies[].policyStatus), not of the order.

Policy statusResponse
ISSUED, CANCEL_PENDINGThe document is returned.
CANCELLED409 insurance.order.state_conflict, reason: policy_cancelled
Others (not issued yet, being issued, could not be issued)409 insurance.order.state_conflict, reason: policy_not_issued

While the policy is in force, you can request the document regardless of the documentStatus value. If the provider cannot provide the document at that moment, 503 is returned as described below.

If the provider is unreachable

If the provider cannot provide the document at that moment, 503 insurance.document.unavailable is returned (details.retryable: true).

  • The policy remains valid; the status of the policy and the order does not change.
  • Repeat the request later. Increase the wait between retries.

Receipt: GET /api/v1/insurance/policies/{policyId}/receipt

If the product in your connection provides a receipt, this endpoint returns the policy's premium receipt as a PDF.

  • The rules are the same as for the policy document: the receipt is not stored by Lunixi, it is fetched from the provider on every request, and it is available only while the policy is in force (When the document is available).
  • The response headers are the same; the file name is <policyId>-receipt.pdf.
  • If the product does not provide a receipt, 412 insurance.document.not_supported is returned. Retrying does not change the result; the policy document is not affected.
  • If the provider cannot provide the receipt at that moment, 503 insurance.document.unavailable is returned, as for the policy document.
source lunixi-sign.sh
REQ_PATH="/api/v1/insurance/policies/<policyId>/receipt"
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" \
  -o receipt.pdf

Certificate: GET /api/v1/insurance/policies/{policyId}/certificate

If the product in your connection issues a certificate for the policy, this endpoint returns the certificate as a PDF. For example, the Green Card certificate of a MOTOR_GREEN_CARD policy is downloaded from this endpoint.

  • The rules are the same as for the policy document: the certificate is not stored by Lunixi, it is fetched from the provider on every request, and it is available only while the policy is in force (When the document is available).
  • The response headers are the same; the file name is <policyId>-certificate.pdf.
  • If the product does not issue a certificate, 412 insurance.document.not_supported is returned. Retrying does not change the result; the policy document and the receipt are not affected.
  • If the provider cannot provide the certificate at that moment, 503 insurance.document.unavailable is returned, as for the policy document.
source lunixi-sign.sh
REQ_PATH="/api/v1/insurance/policies/<policyId>/certificate"
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" \
  -o certificate.pdf

Errors

HTTPcodeWhat to do
404insurance.policy.not_foundThe policy was not found or belongs to another account. Take the policyId value from the order.
409insurance.order.state_conflictThe policy is not in force; see details.reason.
412insurance.document.not_supportedThe product does not provide a receipt or a certificate. Returned only by the receipt and certificate endpoints.
503insurance.document.unavailableThe document cannot be retrieved right now; retry later.

Common codes: Flows › Responses and errors.

Related