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
policyIdvalue from the order'spolicies[]array: Order object.
Authentication and signing: Flows › Authentication.
Request
| Path parameter | Description |
|---|---|
policyId | Policy 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.pdfResponse
A successful response returns 200 and the body is the PDF file itself; there is no JSON envelope.
| Header | Value |
|---|---|
Content-Type | application/pdf |
Content-Disposition | attachment; filename="<policyId>.pdf" |
Cache-Control | no-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 status | Response |
|---|---|
ISSUED, CANCEL_PENDING | The document is returned. |
CANCELLED | 409 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_supportedis 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.unavailableis 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.pdfCertificate: 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_supportedis 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.unavailableis 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.pdfErrors
| HTTP | code | What to do |
|---|---|---|
404 | insurance.policy.not_found | The policy was not found or belongs to another account. Take the policyId value from the order. |
409 | insurance.order.state_conflict | The policy is not in force; see details.reason. |
412 | insurance.document.not_supported | The product does not provide a receipt or a certificate. Returned only by the receipt and certificate endpoints. |
503 | insurance.document.unavailable | The document cannot be retrieved right now; retry later. |
Common codes: Flows › Responses and errors.
Related
- Orders and Payment Binding:
policies[]and the document status - Concepts and Statuses: the document axis