# Offer

## Offer object

| Name                         | Type    | Description                                                                        |
| ---------------------------- | ------- | ---------------------------------------------------------------------------------- |
| id                           | string  | The unique identifier of the offer.                                                |
| version\_id                  | string  | The version identifier of the offer.                                               |
| distributor\_id              | string  | The ID of the distributor associated with the offer.                               |
| insurer\_id                  | string  | The ID of the insurer associated with the offer.                                   |
| item\_id                     | string  | The ID of the item related to the offer.                                           |
| product\_version\_id         | string  | The version ID of the product associated with the offer.                           |
| touchpoint\_id               | string  | The ID of the touchpoint associated with the offer.                                |
| product\_id                  | string  | The ID of the product linked to the offer.                                         |
| integration\_version\_id     | string  | The ID of the integration version associated with the offer.                       |
| subscription\_plan\_id       | string  | The ID of the subscription plan related to the offer.                              |
| insurer\_policy\_id          | string  | The assigned insurer's policy ID.                                                  |
| first\_name                  | string  | The first name of the customer associated with the offer.                          |
| last\_name                   | string  | The last name of the customer associated with the offer.                           |
| email                        | string  | The email address of the customer associated with the offer.                       |
| currency                     | string  | The currency used for the offer.                                                   |
| language                     | string  | The language used for communication related to the offer.                          |
| flow                         | string  | The flow or process used for handling the offer.                                   |
| status                       | string  | The status of the offer (e.g., accepted, pending, etc.).                           |
| quote                        | object  | An object containing detailed information about the quote related to the offer.    |
| data                         | object  | An object containing additional data related to the offer (e.g., company details). |
| media                        | array   | An array of media files or assets associated with the offer.                       |
| metadata                     | object  | An object containing additional metadata about the offer.                          |
| cancellation\_reason         | string  | The reason for cancellation, if applicable.                                        |
| cancelled\_by                | string  | The entity that cancelled the offer, if applicable.                                |
| cancelled\_at                | string  | The timestamp when the offer was cancelled, if applicable.                         |
| distributor\_traffic\_source | string  | The traffic source of the distributor, if applicable.                              |
| referrer\_url                | string  | The referring URL, if applicable.                                                  |
| payment\_token               | string  | The payment token, if applicable.                                                  |
| whitelisted\_referrer\_url   | string  | A whitelisted referring URL, if applicable.                                        |
| linked\_id                   | string  | The ID of a linked offer, if applicable.                                           |
| customer\_id                 | string  | The ID of the customer associated with the offer.                                  |
| accepted\_at                 | string  | The timestamp when the offer was accepted.                                         |
| created\_at                  | string  | The timestamp when the offer was created.                                          |
| assets                       | array   | An array of asset files associated with the offer.                                 |
| contains\_sensitive\_data    | boolean | Indicates whether the offer contains sensitive data.                               |
| is\_version\_assembled       | boolean | Indicates whether the version of the offer is assembled.                           |
| \_links                      | object  | An object containing various links related to the offer.                           |

<details>

<summary>Offer object example</summary>

```json
{
  "id": "tpol_3a1d4c1e1d58fd04ad6b0de1b50c",
  "version_id": "tpv_2a6ead5140156cd8b131648007b2d",
  "distributor_id": "zDKx5dRWea8wv2Yr1pq3LbBGNM9rAPXZ",
  "insurer_id": "6V05nRPO1KLazbpx7KyJmxoW8NM7Evdk",
  "item_id": "ins_97980026870abce8b812668b2d09",
  "product_version_id": "prv_75241db48258635241f22c7602e2",
  "touchpoint_id": "in_e2b0a5a90e0595939c2b1978e5ccf",
  "product_id": "pr_41f331a0f8defc25bb81c2d8fcbf4",
  "integration_version_id": "inv_bf5bb218c2684489b8b52ae701fe",
  "subscription_plan_id": "pp_a6c37bc94f56cafaa7fcc02d771a0",
  "insurer_policy_id": "TEST-TESTE76R4R7D",
  "first_name": "Test",
  "last_name": "Test",
  "email": "test@test.io",
  "currency": "eur",
  "language": "en",
  "flow": "default",
  "status": "accepted",
  "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"
  },
  "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"
  },
  "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-08-02T05:56:28+00:00",
  "created_at": "2023-08-02T05:55:54+00:00",
  "assets": [],
  "contains_sensitive_data": false,
  "is_version_assembled": true,
  "_links": {
    "_self": {
      "href": "https://api.qa-u.eu1.kaskoqa.com/offers/tpol_3a1d4c1e1d58fd04ad6b0de1b50c"
    },
    "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>

## Create an offer

## Create an offer

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

#### Query Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| key  | String | Public key  |

#### Headers

| Name                                     | Type   | Description                   |
| ---------------------------------------- | ------ | ----------------------------- |
| Accept<mark style="color:red;">\*</mark> | String | application/vnd.kasko.v2+json |
| Authorization                            | String | Bearer: \<Secret-key>         |

#### Request Body

| Name                                           | Type   | Description                                                 |
| ---------------------------------------------- | ------ | ----------------------------------------------------------- |
| first\_name<mark style="color:red;">\*</mark>  | String | First name of the customer                                  |
| last\_name<mark style="color:red;">\*</mark>   | String | Last name of the customer                                   |
| email<mark style="color:red;">\*</mark>        | String | Email address of the customer                               |
| language<mark style="color:red;">\*</mark>     | String | Language code                                               |
| data<mark style="color:red;">\*</mark>         | JSON   | Product specific data                                       |
| sensitive\_data                                | JSON   | Sensitive policy data that will be encrypted at rest.       |
| quote\_token<mark style="color:red;">\*</mark> | String | Quote token                                                 |
| metadata                                       | JSON   | An object containing additional metadata about the offer    |
| media                                          | Array  | An array of media files or assets associated with the offer |
| distributor\_traffic\_source                   | String | The traffic source of the distributor                       |
| referrer\_url                                  | String | Referrer URL                                                |
| sales\_lead\_id                                | String | Sales lead ID associated with the offer                     |

{% tabs %}
{% tab title="200: OK Offer successfully created" %}

```json
{
  "id": "tpol_042659d605e1383defeeb1615380",
  "insurer_policy_id": "XXXX-12345",
  "payment_token": "<Payment-token>",
  "_links": {
    "_self": {
      "href": "https://api.eu1.kaskocloud.com/policies/tpol_042659d605e1383defeeb1615380"
    },
    "assets": {
      "offer": {
        "href": "https://api.eu1.kaskocloud.com/offers/tpol_042659d605e1383defeeb1615380/assets?token=b0765c7836b5160c5c6d185413d6efbf62d063ca85fa79cdcc0ae076a6ee91be804b353208500721463fdb816484666bd06595bff62ae5118bbe9e535cefd838"
      },
      "policy": {
        "href": "https://api.eu1.kaskocloud.com/policies/tpol_042659d605e1383defeeb1615380/assets?token=017ecc7f1da77f27c0def954557f168e43482e08f0504ce93fd95991bc75c00c6df8b364ec3b31bb0222aca6ef93a63e283c597e1f11938bc5b6c52bdfc46dcb"
      }
    }
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Bad Request" %}
Response indicates that one or more of the fields provided in payload are invalid and offer cannot be created.

The cause of the error can range from invalid provided quote token, unsupported language to failed field definition validation. The description in message property should indicate as to what exactly is not correctly set. I.e.:

```json
{
    "status": "Bad Request",
    "message": "Token hashing failed."
}
```

{% endtab %}

{% tab title="404: Not Found Resource not found" %}
This response is returned in case any of the provided resources such as the integration, subscription plan or pricing logic cannot be located within the platform.

Some examples of such cases are:

```json
{
    "status": "Not Found",
    "message": "Product with integration: 'in_979808026870abce8b812668b2d09' and item: 'ins_97980026870abce8b812668b2d09' could not be found."
}
```

{% endtab %}

{% tab title="401: Unauthorized Unauthorized" %}
The request requires authentication&#x20;
{% endtab %}
{% endtabs %}

<details>

<summary>Offer creation request example</summary>

```
curl --location 'https://api.eu1.kaskocloud.com/policies?key=pk_test_2jngq6d7GRmxQ58w0yVKW3PBrJXbEvoM' \
--header 'Accept: application/vnd.kasko.v2+json' \
--header 'Content-Type: application/json' \
--data-raw '{
    "first_name": "Test",
    "last_name": "Test",
    "email": "test@test.io",
    "data": {
        "company_name": "Test"
    },
    "quote_token": "<QUOTE-TOKEN>",
    "language": "en"
}'
```

</details>

## View offer

## View offer

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

#### Path Parameters

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

#### Headers

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

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

```json
{
  "id": "tpol_042659d605e1383defeeb1615380",
  "version_id": "tpv_29def80e59b92c8b1f433e9ec0334",
  "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-123456789",
  "first_name": "Test",
  "last_name": "Test",
  "email": "test@kasko.io",
  "currency": "eur",
  "language": "en",
  "flow": "default",
  "status": "ready",
  "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-29"
    },
    "duration_strategy": "fixed_start",
    "duration_data": {
      "policy_start_date": "2023-07-28T23:00:00+00:00"
    },
    "billing_cycles": 1,
    "issue_date": "2023-07-28T11:20:59+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": "<PAYMENT_>",
  "whitelisted_referrer_url": null,
  "linked_policy_id": null,
  "customer_id": "tcu_dfc0c13661e8c785b67378dacd4f",
  "accepted_at": null,
  "created_at": "2023-07-28T11:21:05+00:00",
  "assets": [],
  "contains_sensitive_data": false,
  "is_version_assembled": true,
  "_links": {}
}
```

{% endtab %}

{% tab title="401: Unauthorized Requester is not authorized" %}

```json
{
    "status": "Unauthorized",
    "message": "Requires authentication."
}
```

{% endtab %}

{% tab title="403: Forbidden Forbidden" %}

```json
{
    "status": "Forbidden"
}
```

{% endtab %}

{% tab title="404: Not Found Offer not found" %}

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

{% endtab %}
{% endtabs %}

<details>

<summary>View offer request example</summary>

```
curl --location 'https://api.eu1.kaskocloud.com/offers/tpol_a2c310119de5f633ca4acf9dae21' \
--header 'Accept: application/vnd.kasko.v2+json' \
--header 'Authorization: Bearer <BEARER-TOKEN>'
```

</details>
