Insurance Purchase Endpoint

Endpoint

URL: /api/insureapi

Methods: POST, GET

Description

This API endpoint allows users to purchase third party insurance.

Authentication

To access this endpoint, users must include their API key and secret key in the request headers.

Request Headers

  • api-key (string, required): The API key of the user.
  • secret-key (string, required): The secret key of the user.

Request Body (POST)

  • firstLevel (string, required): The insurance product to purchase.
  • secondLevel (string, required): The insurance package to purchase.
  • phone (string, required): The phone number of the recipient.
  • number (string, required): The plate number of the vehicle.
  • Insured_Name (string, required): The name of the recipient.
  • Engine_Number (string, required): The engine number of the vehicle.
  • Chasis_Number (string, required): The chassis number of the vehicle.
  • Vehicle_Make (string, required): The make of the vehicle.
  • Vehicle_Color (string, required): The color of the vehicle.
  • Vehicle_Model (string, required): The model of the vehicle.
  • Year_of_Make (string, required): The year of manufacture of the vehicle.
  • Contact_Address (string, required): The contact address of the insured.

Usage Example

See usage example in the code snippets below:

Example: Purchase Insurance

POST request to purchase insurance:


Content-Type: application/json
api-key: your-api-key
secret-key: your-secret-key

{
"firstLevel": "3rd party insurance",
"secondLevel": "Private",
"phone": "08032566178",
"number": "ABC123",
"Insured_Name": "John Doe",
"Engine_Number": "1234567890",
"Chasis_Number": "ABCDEFGHIJKL12345",
"Vehicle_Make": "Toyota",
"Vehicle_Color": "Blue",
"Vehicle_Model": "Camry",
"Year_of_Make": "2020",
"Contact_Address": "123 Main St, City",
}
      

Response:


- Status Code: 200

{
"message": "Transaction successful",
"insureHistory": {
"transactionId": "1234567890",
"email": "user@example.com",
"activity": "3rd party insurance",
"message": "Order Submitted Successfully",
"recipient": "08032566178",
"amount": 15000,
"initialBalance": 20000,
"finalBalance": 5000,
"number": "ABC123",
"Insured_Name": "John Doe",
"Engine_Number": "1234567890",
"Chasis_Number": "ABCDEFGHIJKL12345",
"Vehicle_Make": "Toyota",
"Vehicle_Color": "Blue",
"Vehicle_Model": "Camry",
"Year_of_Make": "2020",
"Contact_Address": "123 Main St, City",
"Method": API,
}
}
      

Failed Response Format



{
"error": "Transaction failed",
"insureHistory": {
"transactionId": "1234567890",
"email": "user@example.com",
"activity": "3rd party insurance",
"message": "Order Failed",
"recipient": "08032566178",
"amount": 15000,
"initialBalance": 20000,
"finalBalance": 20000,
"number": "ABC123",
"Insured_Name": "John Doe",
"Engine_Number": "1234567890",
"Chasis_Number": "ABCDEFGHIJKL12345",
"Vehicle_Make": "Toyota",
"Vehicle_Color": "Blue",
"Vehicle_Model": "Camry",
"Year_of_Make": "2020",
"Contact_Address": "123 Main St, City",
"Method": API,
}
}
    

GET request

See usage example in the code snippets below:

Get the list of available firstLevel and secondLevel

GET request for available firstLevel and secondLevel:


Content-Type: application/json
api-key: your-api-key
secret-key: your-secret-key

      

Response:


- Status Code: 200

{
    "3rd party insurance": {
        "available": true,
        "secondLevel": [
            "Private",
            "Commercial",
            "Tricycles",
            "Motorcycle"
        ],
        "amount": [
            15000,
            20000,
            5000,
            3000
        ]
    }
}
            

Other Error Responses

  • 401 Unauthorized: Invalid API key or secret key.
  • 404 Not Found: User not found or data not available.
  • 500 Internal Server Error: Internal server error occurred.