Build it with AI — an AI coding assistant can scaffold this entire integration for you straight from these docs. See Build with AI to get started.
Introduction
This guide walks you through integrating Yasmina’s SME Medical Insurance Price Comparison APIs into your platform (for the single-provider version, click here). These APIs let you retrieve and compare medical insurance packages from several insurance providers before issuing policies to a company’s employees. Using our secure and reliable endpoints, you’ll be able to request and manage policies, and issue claims. Everything you need to deliver insurance services seamlessly within your application.Basic Journey
- Authorize: Get an access token to authenticate all API requests.
- Create a Company: Register the SME that will provide medical insurance for its employees.
- Fetch the Employees: Get the employees registered under the company.
- Edit the Employees: Change the list as needed, each employee with the tier they want.
- Health Declarations: Get the declaration questions, download a printable form, and submit every employee’s answers under one consent.
- Get Prices: One request prices those employees with every insurance provider at once.
- Issue the Policy: Pick a quote and issue the company’s policy from it.
- Payment: Read the policy for its payment link, share it, and get the policy document once it clears.
Authorization
To access any of our API’s. You need to authorize yourself using the Generate Token API. We are using the standard OAuth 2.0 client credentials.The Generate Token API requires
client_id and client_secret. You can get these from your portal.After making the request, you will get access_token in the response. The
access_token must be used on all future Yasmina APIs and be supplied in the Authorization Header in the following form
Authorization: Bearer {access_token}
Companies
Create a Company record
After acquiring an access_token, you can begin using the APIs. Before you produce policies for a company, you must create a company record. After creating the company record, you can request to issue policies to the employees of that company. The The Create Company API, will require a few fields that define details of the company such as Email, Phone, the company’s unified national number and a 10-digit sponsor number. It will return a response with a unique identifier (id). Here is an example of the response from the POST companies API.Prices
Compare the packages
Every insurance provider sells the same four tiers, so an employee’s choice can be priced by all of them:basic, standard, premium and executive. What each provider puts inside a tier, and what it charges for it, is its own. The Categories API shows one provider’s tiers at a time; call it once per provider, passing insurance_provider as one of the values below, or omit it for MedGulf.
Each response carries the provider as
insurance_provider and its display name as insurance_provider_name, then:
- The Insurance provider PDF
- Contains an overview picture of what is provided by the Insurance provider
- The translations
- The translations includes keys that map to the instructional text in Arabic and English that were provided by the insurance provider.
- The categories
- One entry per tier, with the coverage values and the yearly
priceper person
- One entry per tier, with the coverage values and the yearly
Fetch the employees
The Fetch employees API fills the company’s employee list with the employees registered under the company, each on thebasic tier. It replaces the list, so fetch first and edit afterwards.
Edit the employees
The Employees API holds the company’s employee list: who is covered, their dependents, and the tier each has picked. It prices nothing. Send the whole list; each call replaces the one before, and you can read it back at any time.John is Saudi (
nationality_iso is SA), so we supply his nationality_id. Richard is not Saudi, so we supply his iqama_id instead. The API rejects the request if a Saudi employee has no nationality_id or a non-Saudi employee has no iqama_id. Every identifier, for employees and dependents alike, must be exactly 10 digits, and every employee needs a mobile_number.category is one of the four tiers. Employees can be on different tiers.
Employees can also carry sponsor_id (10 digits) and is_married (true or false), both optional. A non-Saudi whose iqama has not been issued yet sends a 10-digit border_number in place of iqama_id.
Dependents
An employee can bring family members onto the policy through thedependents array. Each dependent needs a name, a relationship to the employee (spouse, child or parent), a nationality_iso, a date_of_birth, and the same identifier rule as the employee: a 10-digit nationality_id for Saudis, a 10-digit iqama_id for everyone else. Dependents do not carry their own mobile number. Dependents are covered under the employee’s tier; they cannot have one of their own. Leave the array out, or send it empty, for an employee with no dependents.
Dates of birth
Send everydate_of_birth as YYYY-MM-DD. Saudi nationals whose national id starts with 1 give the Hijri (Umm al-Qura) date printed on their id, as John and his family do above; everyone else gives a Gregorian date. Employees must be between 18 and 110 years old; dependents can be any age.
Health declaration forms
Insurers require a past medical history from every employee before they will price them, so every employee declares before you ask for prices. Yasmina publishes the questions and prints the form; each employee answers for themselves, on paper or inside your own platform.- The questions: the Medical form API returns every question, grouped the way the insurers ask them, so you can build your own screen for it.
-
The printable form: the Download declaration form API returns the same declaration as a PDF. Pass the
policy_idand the file carries one page per employee on the policy, with their name, id and package filled in, ready to print or email. Leavepolicy_idout for a single blank form. -
Submitting the declarations: send every employee’s answers in one call with the Submit the declarations API. Each entry names an employee by their
nationality_id,iqama_idorborder_numberasemployee_id, and carries that employee’s own answers. Oneconsentcovers the whole submission and must betrue, confirming the employees have stated that their answers are true and complete and agreed to share them with the insurance provider. Show that statement before submitting. The declarations are kept by employee id, apart from the employee list, so editing the list leaves them alone; each call replaces them, so send everyone each time. The response tells you who is still inpending_declarations, and prices are refused (40023) until everyone on the list has declared.
Get prices from every provider
Call the Quote request API with thecompany_id and you get one response with a quote from every insurance provider, each priced for the employees saved above at the tiers they picked. Every quote carries a quote_price_id; the response itself carries an id, the quote_request_id. Keep both for the next step.
total_price is what the company pays for a year of cover with that provider, price_per_employee is that total divided by the number of employees, and the employees lines show where it comes from. packages has one entry per tier the employees picked, with its benefits (the coverage values from the Categories API) and its network. A quote prices the employees as they stood when it was asked for; change the list and ask again.
Benefits and networks differ by tier, not just by provider: a higher tier reaches more facilities and buys a better room, a higher copayment cap and higher pregnancy and vision limits. Show them side by side so the company can see what each tier adds. The network gives the facility counts by type for a comparison table; its provider_list_url is the Networks API call that lists every facility in that tier with its status, included or referral, and the cities to filter by.
Policies
Issue the policy
A company buys one policy, and its employees are the members on it, which is how the insurer issues it and how the policy document reads. Call the Issue policy API with thequote_request_id and the quote_price_id of the quote the company chose, and you get that one policy back: the provider that priced it, the quoted total as price, and every employee inside meta_data.insured.
Payment
Everything needed to take payment is on the policy object. Read the policy and you get:price: what the company pays for a year of cover.pending_declarations: the employees who still have to declare their medical history. Everyone declared before the prices, so it is empty.payment_link: where the company pays, oncepending_declarationsis empty. It opens Yasmina’s secure card page, where the company pays for all of its employees in one go. It is a fresh signed link on every read and expires after 15 minutes, so read the policy when the buyer is ready to pay rather than storing the link. It is null while anyone still has to declare, and again once the policy is issued.
Payment and Policy activation
When you first issue the policy, it is not yet activated and thestatus is 0 (which means pending).
Also the provider_policy and provider_policy_id will both be null.
In order for the policy to be activated, the customer needs to make the purchase from the payment link. Once the customer successfully pays. The policy will be activated and the status becomes 1, and the policy schedule listing every member becomes available through the List policies API.
Although the payment page is provided by Yasmina, it does not display the Yasmina logo or have any mention of Yasmina.
Yasmina does not receive credit card information, instead the payment page sends card information directly to the payment vendor.
Yasmina does not receive credit card information, instead the payment page sends card information directly to the payment vendor.
Redirect URL
You can supply the payload aredirect_url. This is used to redirect the customer to any page or deep link you need. You can also include a query string with policyID and it will automatically replace it with the actual id of the policy object.
Example for policy id 123