We provide RESTful APIs to our partners for easier integration. The actions that can be performed through our APIs are:
Create a new policy
Resolve an existing policy
Get the pricing and optionally obtain a signature to create a policy onchain
Query policy details
Some of these operations are asynchronous, so partners can also set up to receive callback notifications with the results of the operations.
Quickstart Guide
Integrating with our APIs is really simple. The first step is on our end, setting up the necessary services and credentials. Once that's done you'll get four things:
A URL for the pricing API
An API key
A signing secret
The address of your risk module
You'll need all of these to properly integrate.
Your first call to our service: pricing a policy
On your first call you'll just need the URL and the API key. This endpoint will price a policy without creating or signing anything:
Notice that the specific parameters that you need to send on the call will depend on the pricing structure and settings, you should've received more specific instructions about what to include in the data object.
Some parameters will always be required:
payout is the policy's max payout in USD.
expiration is the policy's expiration. The example uses a UTC timestamp, but you can pick the timezone that's better for your business.
You can check the API reference for a detailed description of each, but the most important ones are:
ensuro_id: this will be the policy ID on our system, it identifies each policy univocally across our protocol.
loss_prob: this is the loss probability assigned to the policy. When testing out your integration you should validate that this loss probability matches the pricing set forth for the product.
premium_details : this is a breakdown of the premium as per the current pricing.
If you remove the unsigned parameter from the call to /quote you will get an additional field with the signature for the quote. With this signature you can call our smart contract to create a policy.
Creating a policy
Although you can obtain signed quotes and use those to create policies on the blockchain, it's more practical to just create the policies directly by calling our API.
To do this, you'll have to sign the body of your request using an HMAC signature.
The returned object will be the same as when calling /quote. You should take note of the ensuro_id because you'll need it to resolve policies later on.
Resolving a policy
You can resolve a policy with any payout up to the max payout established on policy creation. This transfers the payout to the policy owner and releases the rest of the locked capital for use in other policies.
Here as well you'll need to sign the body of the request.