# Policy

## Initiate Group Life Policy

## This endpoint initiates a group life policy with a post request

<mark style="color:green;">`POST`</mark> `https://sandbox.insurpass.com/api/merchant/group-life/policy/initiate-group-life-policy` &#x20;

**Successful initiation of policy generates a token that would be used to verify a transaction**

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {$secret-key}/{$api-key} |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |

#### Request Body

| Name                                                      | Type                                 | Description                                                                        |
| --------------------------------------------------------- | ------------------------------------ | ---------------------------------------------------------------------------------- |
| email<mark style="color:red;">\*</mark>                   | Email                                | Principal Customer's email address -**<email@domain.com>**                         |
| first\_name<mark style="color:red;">\*</mark>             | String                               | Principal Customer's first name - **Favour**                                       |
| surname<mark style="color:red;">\*</mark>                 | String                               | Principal Customer's surname - Ezedibia                                            |
| phone\_no<mark style="color:red;">\*</mark>               | numeric\|digits:11numeric\|digits:11 | Principal Customer's phone number - 08102223475 (**digits:11)**                    |
| gender<mark style="color:red;">\*</mark>                  | String                               | Principal Customer's gender - female, male                                         |
| dob<mark style="color:red;">\*</mark>                     | String                               | Principal Customer's date of birth. yy-mm-dd                                       |
| product\_id<mark style="color:red;">\*</mark>             | String                               | The unique number that identifies Group insurance product you're purchasig - **3** |
| group\_name<mark style="color:red;">\*</mark>             | String                               | Name of the group purchasing the plan                                              |
| group\_type<mark style="color:red;">\*</mark>             | String                               | Type of group purchasing the plan                                                  |
| first\_person\_name<mark style="color:red;">\*</mark>     | String                               | The name of the first person of contact for the group                              |
| group\_contact\_address<mark style="color:red;">\*</mark> | String                               | The address information of the group                                               |
| first\_person\_phone<mark style="color:red;">\*</mark>    | numeric\|digits:11                   | The phone number of the first person of contact for the group                      |
| second\_person\_name<mark style="color:red;">\*</mark>    | String                               | The name of the second person of contact for the group                             |
| second\_person\_phone<mark style="color:red;">\*</mark>   | numeric\|digits:11                   | The phone number of the second person of contact for the group                     |
| status<mark style="color:red;">\*</mark>                  | String                               |                                                                                    |
| members<mark style="color:red;">\*</mark>                 | String                               | the details of each group member                                                   |

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

```javascript
{
   "success": true,
   "response_message": "Group life policy verified successfully",
   "response_code": 200,
   "data": {
       "token": "GLP163879198612409044"
   }
}

```

{% endtab %}
{% endtabs %}

## Verify Group Life Policy

## This endpoint verifies the token which was generated during the initiation of the policy.

<mark style="color:green;">`POST`</mark> `https://sandbox.insurpass.com/api/merchant/group-life/policy/verify-group-life-policy` &#x20;

**Note that the token expires after a certain duration**

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {$secret-key}/{$api-key} |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |

#### Request Body

| Name                                    | Type   | Description                                                                   |
| --------------------------------------- | ------ | ----------------------------------------------------------------------------- |
| token<mark style="color:red;">\*</mark> | String | Note that after 15 minutes, the token expires and you will need to reinitiate |

{% tabs %}
{% tab title="400: Bad Request " %}

```javascript
{
   "success": false,
   "response_message": "Token has expired",
   "response_code": 400,
   "data": {
       "error": [
           "Token has expired"
       ]
   }
}

```

{% endtab %}

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

```javascript
{
   "success": false,
   "response_message": "Invalid Token",
   "response_code": 400,
   "data": {
       "error": [
           "Invalid Token"
       ]
   }

```

{% endtab %}

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

```javascript
{
   "success": true,
   "response_message": "Group life Policy initiated successfully",
   "response_code": 200,
   "data": {
       "id": 57,
       "user_id": 12,
       "product_id": 2,
       "merchant_id": 1,
       "policy_number": "IN93809537",
       "group_name": "group life policy group",
       "group_type": "User",
       "group_contact_address": "rojojo store makurdi",
       "first_person_name": "John",
       "first_person_phone": "2636373737",
       "second_person_name": "Peter",
       "second_person_phone": null,
       "start_date": null,
       "end_date": null,
       "status": true,
       "deleted_at": null,
       "created_at": "2021-12-03T22:24:44.000000Z",
       "updated_at": "2021-12-03T22:24:44.000000Z",
       "user": {
           "id": 12,
           "first_name": "John",
           "middle_name": null,
           "surname": "Doe",
           "phone_no": "08135540787",
           "email": "johndoed21393@gmail.com",
           "address": null,
           "gender": "Male",
           "date_of_birth": "2021-02-12T00:00:00.00000,
           "created_at": "2021-11-26T15:48:01.000000Z",
           "updated_at": "2021-11-26T15:48:01.000000Z",
                       },
       "product": {
           "id": 2,
           "name": "Malaria Care Plan Plus",
           "details": "some details",
           "beneficiaries": true,
           "max_beneficiaries": 3,
           "provider_id": 1,
           "logo_url": "logo.png",
           "enable": true,
           "created_at": "2021-11-23T17:20:38.000000Z",
           "updated_at": "2021-11-23T17:20:38.000000Z",
           "service_id": 2,
           "product_class_id": 2
       },
       "members": [
           {
               "id": 15,
               "policy_id": 57,
               "full_name": "Lasisi Modupela",
               "gender": "male",
               "occupation": "software Engineer",
               "date_of_birth": "2021-01-12T00:00:00.000000Z",
               "next_of_kiln": "Oson",
               "phone_number": "08135540787",
               "policy_type": "group-life",
               "deleted_at": null,
               "created_at": "2021-12-03T22:24:44.000000Z",
               "updated_at": "2021-12-03T22:24:44.000000Z"
           },
           {
               "id": 16,
               "policy_id": 57,
               "full_name": "Adebayo Ademola",
               "gender": "male",
               "occupation": "software Engineer",
               "date_of_birth": "2021-01-12T00:00:00.000000Z",
               "next_of_kiln": "shimi",
               "phone_number": "08135540787",
               "policy_type": "group-life",
               "deleted_at": null,
               "created_at": "2021-12-03T22:24:44.000000Z",
               "updated_at": "2021-12-03T22:24:44.000000Z"
           }
       ]
   }
}

```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Initiate token expires in 15 minutes, and if a user does not verify his/her subscription after 15 minutes of initiation, the details of the subscription will be deleted.
{% endhint %}

## Get Merchant Group Life Policy

## This endpoint returns all the policies created by the merchant

<mark style="color:blue;">`GET`</mark> `https://sandbox.insurpass.com/api/merchant/group-life/policy/merchant-group-life-policies`

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {$secret-key}/{$api-key} |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |

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

```javascript
{
   "success": true,
   "response_message": "Group Life Policies retrieved successfully",
   "response_code": 200,
   "data": {
       "current_page": 5,
       "data": [
           {
               "id": 55,
               "user_id": 12,
               "product_id": 2,
               "merchant_id": 1,
               "policy_number": "IN32349098",
               "group_name": "group life policy group",
               "group_type": "User",
               "group_contact_address": "rojojo store makurdi",
               "first_person_name": "John",
               "first_person_phone": "2636373737",
               "second_person_name": "Peter",
               "second_person_phone": null,
               "start_date": null,
               "end_date": null,
               "status": true,
               "deleted_at": null,
               "created_at": "2021-12-03T22:13:02.000000Z",
               "updated_at": "2021-12-03T22:13:02.000000Z",
               "user": {
                   "id": 12,
                   "first_name": "John",
                   "middle_name": null,
                   "surname": "Doe",
                   "phone_no": "08135540787",
                   "email": "johndoed21393@gmail.com",
                   "address": null,
                   "gender": "Male",
                     "created_at": "2021-11-26T15:48:01.000000Z",
                   "updated_at": "2021-11-26T15:48:01.000000Z",
                                                   },
               "product": {
                   "id": 2,
                   "name": "Malaria Care Plan Plus",
                   "details": "some details",
                   "beneficiaries": true,
                   "max_beneficiaries": 3,
                     "created_at": "2021-11-23T17:20:38.000000Z",
                   "updated_at": "2021-11-23T17:20:38.000000Z",
                   "service_id": 2,
                   "product_class_id": 2
               },
               "group_life_members": [
                   {
                       "id": 11,
                       "policy_id": 55,
                       "full_name": "Lasisi Modupela",
                       "gender": "male",
                       "occupation": "software Engineer",
                       "date_of_birth": "2021-01-12T00:00:00.000000Z",
                       "next_of_kiln": "Oson",
                       "phone_number": "08135540787",
                       "policy_type": "group-life",
                       "deleted_at": null,
                       "created_at": "2021-12-03T22:13:02.000000Z",
                       "updated_at": "2021-12-03T22:13:02.000000Z"
                   },
                   {
                       "id": 12,
                       "policy_id": 55,
                       "full_name": "Adebayo Ademola",
                       "gender": "male",
                       "occupation": "software Engineer",
                       "date_of_birth": "2021-01-12T00:00:00.000000Z",
                       "next_of_kiln": "shimi",
                       "phone_number": "08135540787",
                       "policy_type": "group-life",
                       "deleted_at": null,
                       "created_at": "2021-12-03T22:13:02.000000Z",
                       "updated_at": "2021-12-03T22:13:02.000000Z"
                   }
               ]
           },

```

{% endtab %}
{% endtabs %}

## Group Life Policy Details

## This endpoint returns the merchant policy details.

<mark style="color:green;">`POST`</mark> `https://sandbox.insurpass.com/api/merchant/group-life/policy/group-life-policy-details`

**The developer needs to provide the policy number for the policy details to display.**

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {$secret-key}/{$api-key} |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json                |

#### Request Body

| Name                                             | Type   | Description                                                                        |
| ------------------------------------------------ | ------ | ---------------------------------------------------------------------------------- |
| Policy\_number<mark style="color:red;">\*</mark> | String | The unique number that identifies the purchased  insurance policy - **IN98570819** |

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

```javascript
{
   "success": true,
   "response_message": "Group life Policy initiated successfully",
   "response_code": 200,
   "data": {
       "id": 57,
       "user_id": 12,
       "product_id": 2,
       "merchant_id": 1,
       "policy_number": "IN93809537",
       "group_name": "group life policy group",
       "group_type": "User",
       "group_contact_address": "rojojo store makurdi",
       "first_person_name": "John",
       "first_person_phone": "2636373737",
       "second_person_name": "Peter",
       "second_person_phone": null,
       "start_date": null,
       "end_date": null,
       "status": true,
       "deleted_at": null,
       "created_at": "2021-12-03T22:24:44.000000Z",
       "updated_at": "2021-12-03T22:24:44.000000Z",
       "user": {
           "id": 12,
           "first_name": "John",
           "middle_name": null,
           "surname": "Doe",
           "phone_no": "08135540787",
           "email": "johndoed21393@gmail.com",
           "address": null,
           "gender": "Male",
           "date_of_birth": "2021-02-12T00:00:00.000000Z",
           "password": null,
           "policy_no": "1234567",
           "have_beneficiaries": false,
           "enable": true,
           "next_of_kin_full_name": null,
           "merchant_user_id": null,
           "user_type": "user",
           "created_at": "2021-11-26T15:48:01.000000Z",
           "updated_at": "2021-11-26T15:48:01.000000Z",
           "principal_policy_no": null,
           "nin_number": null,
           "id_url": null,
           "profile_url": null,
           "company_id": null,
           "verify_phone": 0,
           "verify_email": 0,
           "town": null,
           "state_of_residence": null,
           "transaction_pin": null,
           "occupation": null
       },
       "product": {
           "id": 2,
           "name": "Malaria Care Plan Plus",
           "details": "some details",
           "beneficiaries": true,
           "max_beneficiaries": 3,
           "provider_id": 1,
           "logo_url": "logo.png",
           "enable": true,
           "created_at": "2021-11-23T17:20:38.000000Z",
           "updated_at": "2021-11-23T17:20:38.000000Z",
           "service_id": 2,
           "product_class_id": 2
       },
       "group_life_members": [
           {
               "id": 15,
               "policy_id": 57,
               "full_name": "Lasisi Modupela",
               "gender": "male",
               "occupation": "software Engineer",
               "date_of_birth": "2021-01-12T00:00:00.000000Z",
               "next_of_kiln": "Oson",
               "phone_number": "08135540787",
               "policy_type": "group-life",
               "deleted_at": null,
               "created_at": "2021-12-03T22:24:44.000000Z",
               "updated_at": "2021-12-03T22:24:44.000000Z"
           },
           {
               "id": 16,
               "policy_id": 57,
               "full_name": "Adebayo Ademola",
               "gender": "male",
               "occupation": "software Engineer",
               "date_of_birth": "2021-01-12T00:00:00.000000Z",
               "next_of_kiln": "shimi",
               "phone_number": "08135540787",
               "policy_type": "group-life",
               "deleted_at": null,
               "created_at": "2021-12-03T22:24:44.000000Z",
               "updated_at": "2021-12-03T22:24:44.000000Z"
           }
       ]
   }
}

```

{% endtab %}
{% endtabs %}
