# Policy

## Policy object

| Name                          | Type    | Description                                                                                         |
| ----------------------------- | ------- | --------------------------------------------------------------------------------------------------- |
| id                            | string  | The unique identifier of the policy.                                                                |
| version\_id                   | string  | The version identifier of the policy.                                                               |
| distributor\_id               | string  | The ID of the distributor associated with the policy.                                               |
| touchpoint\_id                | string  | The ID of the touchpoint associated with the policy.                                                |
| item\_id                      | string  | The ID of the item related to the policy.                                                           |
| product\_id                   | string  | The ID of the product linked to the policy.                                                         |
| product\_version\_id          | string  | The version ID of the product associated with the policy.                                           |
| integration\_version\_id      | string  | The ID of the integration version associated with the policy.                                       |
| insurer\_policy\_id           | string  | The insurer's assigned policy ID.                                                                   |
| distributor\_key              | string  | The key or token for the distributor.                                                               |
| insurer\_external\_policy\_id | string  | The external policy ID from the insurer, if applicable.                                             |
| first\_name                   | string  | The first name of the customer associated with the policy.                                          |
| last\_name                    | string  | The last name of the customer associated with the policy.                                           |
| expired                       | boolean | Indicates whether the policy has expired (false) or not (true).                                     |
| email                         | string  | The email address of the customer associated with the policy.                                       |
| currency                      | string  | The currency used for the policy.                                                                   |
| policy\_created\_date         | string  | The timestamp when the policy was created.                                                          |
| start\_date                   | string  | The start date of the policy coverage.                                                              |
| end\_date                     | string  | The end date of the policy coverage, if applicable.                                                 |
| termination\_date             | string  | The termination date of the policy, if applicable.                                                  |
| language                      | string  | The language used for communication related to the policy.                                          |
| status                        | string  | The status of the policy (e.g., "paid", "pending", etc.).                                           |
| data                          | object  | An object containing additional data related to the policy (e.g., company details).                 |
| quote                         | object  | An object containing detailed information about the quote related to the policy.                    |
| metadata                      | object  | An object containing additional metadata about the policy.                                          |
| cancellation\_reason          | string  | The reason for cancellation, if applicable.                                                         |
| cancelled\_by                 | string  | The entity that cancelled the policy, if applicable.                                                |
| cancelled\_at                 | string  | The timestamp when the policy was cancelled, if applicable.                                         |
| referrer\_url                 | string  | The referring URL, if applicable.                                                                   |
| assets                        | array   | An array of asset files associated with the policy.                                                 |
| media                         | array   | An array of media files associated with the policy.                                                 |
| is\_locked                    | boolean | Indicates whether the policy is locked (true) or not (false).                                       |
| localized\_dates              | object  | An object containing localized dates for different fields.                                          |
| contains\_sensitive\_data     | boolean | Indicates whether the policy contains sensitive data (true) or not (false).                         |
| sales\_lead\_id               | string  | The ID of the sales lead associated with the policy, if applicable.                                 |
| \_links                       | object  | An object containing various links related to the policy (e.g., self-link, distributor link, etc.). |

{% hint style="info" %}
Depending on the requester permissions, some fields of the policy object are restricted.
{% endhint %}

<details>

<summary>Policy object example</summary>

```json
{
    "id": "tpol_3a1d4c1e1d58fd04ad6b0de1b50c",
    "version_id": "tpv_f9e793a24197f7bf8284d9b061a89",
    "distributor_id": "zDKx5dRWea8wv2Yr1pq3LbBGNM9rAPXZ",
    "touchpoint_id": "in_e2b0a5a90e0595939c2b1978e5ccf",
    "item_id": "ins_97980026870abce8b812668b2d09",
    "product_id": "pr_41f331a0f8defc25bb81c2d8fcbf4",
    "product_version_id": "prv_75241db48258635241f22c7602e2",
    "integration_version_id": "inv_bf5bb218c2684489b8b52ae701fe",
    "insurer_policy_id": "TEST-TESTE76R4R7D",
    "distributor_key": "pk_test_2jngq6d7GRmxQ58w0yVKW3PBrJXbEvoM",
    "insurer_external_policy_id": null,
    "first_name": "Test",
    "last_name": "Test",
    "expired": false,
    "email": "neglitis@kasko.io",
    "currency": "eur",
    "policy_created_date": "2023-08-02T05:56:26+00:00",
    "start_date": "2023-08-05T21:00:00+00:00",
    "end_date": null,
    "termination_date": null,
    "language": "en",
    "status": "paid",
    "data": {
        "company_name": "Test",
        "company_registered_date": "2023-07-31",
        "optins": true,
        "street": "Tellplatz",
        "house_number": "52",
        "postcode": "4053",
        "subsidiary": 12,
        "phone_number": "+443333333333",
        "city": "Basel",
        "payment_metadata": []
    },
    "quote": {
        "version": 2,
        "customer_input": {
            "employee_number": 11,
            "yearly_turnover": 1100000,
            "company_backup": "never",
            "encryption": true,
            "deductible": 100000,
            "insured_sum": 10000000,
            "online_revenue_percentage": "0_25",
            "policy_start_date": "2023-08-06",
            "third_party_coverage": false
        },
        "subscription_plan_id": "pp_a6c37bc94f56cafaa7fcc02d771a0",
        "gross_payment_amount": 275000,
        "payment_data": {
            "gross_premium": 275000,
            "premium_tax": 25000,
            "net_premium": 250000,
            "net_net_premium": 250000,
            "net_commission_total": 0,
            "tax_rate": 0.1
        },
        "data": {
            "total_gross_premium": 275000,
            "total_premium_tax": 25000,
            "total_net_premium": 250000,
            "start_date": "2023-8-06"
        },
        "duration_strategy": "fixed_start",
        "duration_data": {
            "policy_start_date": "2023-08-05T21:00:00+00:00"
        },
        "billing_cycles": 1,
        "issue_date": "2023-08-02T05:55:36+00:00",
        "livemode": false,
        "pricing_logic_id": "pl_5ddfa3967d164864648c2ac6b12b6",
        "pricing_logic_revision_id": "plr_6c43dac260c3c93b0547a3aba041",
        "insurer_private_data": [],
        "integration_id": "in_e2b0a5a90e0595939c2b1978e5ccf",
        "integration_version_id": "inv_bf5bb218c2684489b8b52ae701fe",
        "product_version_id": "prv_75241db48258635241f22c7602e2",
        "item_id": "ins_97980026870abce8b812668b2d09"
    },
    "metadata": {},
    "cancellation_reason": null,
    "cancelled_by": "",
    "cancelled_at": null,
    "referrer_url": null,
    "assets": [],
    "media": [],
    "is_locked": false,
    "localized_dates": {
        "start_date": "2023-08-06T00:00:00+03:00",
        "end_date": null,
        "termination_date": null,
        "policy_created_date": "2023-08-02T08:56:26+03:00",
        "time_zone": "Europe/Riga"
    },
    "contains_sensitive_data": false,
    "sales_lead_id": null,
    "_links": {
        "_self": {
            "href": "https://api.qa-u.eu1.kaskoqa.com/policies/tpol_3a1d4c1e1d58fd04ad6b0de1b50c"
        },
        "distributor": {
            "href": "https://api.qa-u.eu1.kaskoqa.com/accounts/zDKx5dRWea8wv2Yr1pq3LbBGNM9rAPXZ"
        },
        "item": {
            "href": "https://api.qa-u.eu1.kaskoqa.com/items/ins_97980026870abce8b812668b2d09"
        },
        "touchpoint": {
            "href": "https://api.qa-u.eu1.kaskoqa.com/touchpoints/in_e2b0a5a90e0595939c2b1978e5ccf"
        }
    }
}
```

</details>

## View policy

## View Policy

<mark style="color:blue;">`GET`</mark> `https://api.eu1.kaskocloud.com/policies/{policyId}`

#### Path Parameters

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| policyId<mark style="color:red;">\*</mark> | String | Policy ID   |

#### Headers

| Name          | Type   | Description           |
| ------------- | ------ | --------------------- |
| Authorization | String | Bearer: \<Secret-key> |

{% tabs %}
{% tab title="200: OK OK" %}

```json
{
  "id": "tpol_cde29ddf602568d0d04394db9d68",
  "version_id": "tpv_4b663ec3839d8c4a22f67424255aa",
  "distributor_id": "zDKx5dRWea8wv2Yr1pq3LbBGNM9rAPXZ",
  "insurer_id": "6V05nRPO1KLazbpx7KyJmxoW8NM7Evdk",
  "item_id": "ins_1d93409d7fa29df7b791abab1418",
  "product_version_id": "prv_7b08924b0e11aebf1b2bdb0c20dc",
  "touchpoint_id": "in_1e68dc1ab6de95249a45602b03a64",
  "product_id": "pr_8ee32431d94515171e2b27df930c7",
  "integration_version_id": "inv_bf3d89a38434947faf1ccfd2c059",
  "subscription_plan_id": "pp_ced41db0d46d56f5494f01d26b27c",
  "insurer_policy_id": "TEST-XXX-12345",
  "first_name": "Test",
  "last_name": "Test",
  "email": "test@kasko.io",
  "currency": "eur",
  "language": "en",
  "flow": "default",
  "status": "accepted",
  "quote": {
    "version": 2,
    "customer_input": {},
    "subscription_plan_id": "pp_ced41db0d46d56f5494f01d26b27c",
    "gross_payment_amount": 0,
    "payment_data": {
      "gross_premium": 0,
      "premium_tax": 0,
      "net_premium": 0,
      "net_net_premium": 0,
      "net_commission_total": 0,
      "tax_rate": 0.1
    },
    "data": {
      "total_gross_premium": 0,
      "total_premium_tax": 0,
      "total_net_premium": 0,
      "start_date": "2023-7-30"
    },
    "duration_strategy": "fixed_start",
    "duration_data": {
      "policy_start_date": "2023-07-29T23:00:00+00:00"
    },
    "billing_cycles": 1,
    "issue_date": "2023-07-28T12:58:40+00:00",
    "livemode": false,
    "pricing_logic_id": "pl_0138cd03d2df1269caa656702ea69",
    "pricing_logic_revision_id": "plr_21f4442d7da558a280f4b7388d17",
    "insurer_private_data": [],
    "integration_id": "in_1e68dc1ab6de95249a45602b03a64",
    "integration_version_id": "inv_bf3d89a38434947faf1ccfd2c059",
    "product_version_id": "prv_7b08924b0e11aebf1b2bdb0c20dc",
    "item_id": "ins_1d93409d7fa29df7b791abab1418"
  },
  "data": {},
  "media": [],
  "metadata": {},
  "cancellation_reason": null,
  "cancelled_by": "",
  "cancelled_at": null,
  "distributor_traffic_source": null,
  "referrer_url": null,
  "payment_token": null,
  "whitelisted_referrer_url": null,
  "linked_policy_id": null,
  "customer_id": "tcu_dfc0c13661e8c785b67378dacd4f",
  "accepted_at": "2023-07-28T12:59:25+00:00",
  "created_at": "2023-07-28T12:58:45+00:00",
  "assets": [],
  "contains_sensitive_data": false,
  "is_version_assembled": true,
  "_links": {}
}
```

{% endtab %}

{% tab title="404: Not Found Not Found" %}

```json
{
    "status": "Not Found",
    "message": "Policy of id: \"lpol_33_char_offer_id____________\" not found."
}
```

{% endtab %}
{% endtabs %}

<details>

<summary>View policy example</summary>

```
curl --location 'https://api.eu1.kaskocloud.com/policies/tpol_3a1d4c1e1d58fd04ad6b0de1b50c' \
--header 'Accept: application/vnd.kasko.v2+json' \
--header 'Authorization: Bearer <SECRET-KEY>'
```

</details>

## Cancel policy

## Cancel Policy

<mark style="color:green;">`POST`</mark> `https://api.eu1.kaskocloud.com/policies/{policyId}/cancel`

#### Headers

| Name                                            | Type   | Description           |
| ----------------------------------------------- | ------ | --------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: \<Secret-key> |
| If-Match<mark style="color:red;">\*</mark>      | String | Policy version ID     |

#### Request Body

| Name                                                   | Type   | Description                    |
| ------------------------------------------------------ | ------ | ------------------------------ |
| cancellation\_reason<mark style="color:red;">\*</mark> | String | Cancellation reason            |
| termination\_date<mark style="color:red;">\*</mark>    | String | Termination date in ISO format |

{% tabs %}
{% tab title="404: Not Found Not Found" %}
This response is returned in case the specified policy cannot be found in the system.

```json
{
    "status": "Not Found",
    "message": "Policy of id: \"lpol_33_char_offer_id____________\" not found."
}
```

{% endtab %}

{% tab title="202: Accepted Accepted" %}

```json
{
  "policy_id": "tpol_3a1d4c1e1d58fd04ad6b0de1b50c",
  "_links": {
    "status": {
      "href": "https://api.eu1.kaskocloud.com/policies/tpol_3a1d4c1e1d58fd04ad6b0de1b50c/versions/tpv_df8688809866c91f7938a8d586c16/status"
    }
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Bad Request" %}
Response indicates that one or more of the fields provided in the payload.

```json
{
    "status": "Bad Request",
    "message": "Brief description"
}
```

{% endtab %}

{% tab title="412: Precondition Failed Precondition Failed" %}
Indicates that the provided header value does not match the current version ID.

```json
{
    "status": "Precondition Failed",
    "message": "Resource has been changed: \"lpv_33_char_policy_version_id____\" is not an active version."
}
```

{% endtab %}

{% tab title="409: Conflict Conflict" %}
Indicates that the policy update is already in progress and it is not possible to cancel policy currently.

```json
{
    "status": "Conflict",
    "message": "Resource modification already initialized at 1989-02-04T05:34:12+00:00."
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Unprocessable Entity" %}
Indicates either that policy is expired or it is already cancelled.

```json
{
    "status": "Unprocessable Entity",
    "message": "Policy already cancelled."
}
```

```json
{
    "status": "Unprocessable Entity",
    "message": "Policy is expired. Can\'t cancel expired policy."
}
```

{% endtab %}
{% endtabs %}

<details>

<summary>Policy cancellation request example</summary>

```
curl --location 'https://api.eu1.kaskocloud.com/policies/tpol_bddc5c1ecc1668d49ba51a44945b/cancel' \
--header 'Accept: application/vnd.kasko.v2+json' \
--header 'If-Match: tpv_b564b57cfa170e42dc9ce29047994' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <SECRET-KEY>' \
--data '{
    "cancellation_reason": "Not valid",
    "termination_date": "2023-08-06"
}'
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kasko.io/kasko-api-documentation/rest-api/resources/policy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
