Skip to main content
Sandbox only for now. The Cargo Insurance APIs are available on https://sandbox.yasmina.ai so you can build and test the whole journey. In Sandbox the insurance company’s decisions, prices and documents are simulated; see Testing in Sandbox. Ask your account manager to enable Cargo Insurance for your sandbox client.

Introduction

This guide walks you through the Cargo Insurance APIs. They cover goods in transit by sea, air or road for a business, in two ways:
  • Single shipment: quote one shipment, pay for it, and get its certificate.
  • Open cover: a one-year policy for a business that ships regularly. The business pays a deposit once, then declares each shipment under the policy and gets a certificate for it straight away.
Both start from the same customer record and end on the same policy object.

Basic Journey

  1. Authorize: Get an access token to authenticate all API requests.
  2. Get the options: Fetch the values your forms offer: goods categories, transport modes, coverages and the rest.
  3. Register the customer: Register the business by its commercial registration (CR) number.
  4. Get a decision: Quote a shipment, or apply for open cover. The answer is approved, referred or rejected.
  5. Issue the policy: Accept an approved quote. The policy comes back with a payment link.
  6. Payment: The customer pays, and the policy is issued with its certificate and tax invoice.
  7. Declare shipments (open cover only): Declare each shipment under the policy and get its certificate.

Prerequisites

  1. Account in Yasmina - See the Onboarding section for details.
  2. Authenticated Token - Follow the Authentication guide to generate one.
  3. Backend server - Required to securely call Yasmina APIs.
Every path below is under https://sandbox.yasmina.ai/api/v1/cargo.

Options

The Get the options API returns every list of values the other endpoints accept, each entry with the value to send and a label to show: customer_roles, transport_modes, goods_categories, packaging, conditions, characteristics, coverages, extensions, valuation_bases, incoterms, insurance_arranged_by, currencies and countries. Build your dropdowns from this response instead of hard-coding them, so a new value reaches your users without a release on your side.

Customers

Register a customer

The customer is the business the cargo is insured for. The Register a customer API takes its 10-digit CR number, its role in the trade and a contact person:
The CR number is checked against the commercial registry:
  • The registry knows the business. Its legal name and address come from the registry, and the customer’s verification.status is verified. You do not need to ask your user for them.
  • The registry has no record. The call answers 400 with code 40031. Ask your user for the legal name and address and send the call again with legal_name and address (street and city at least). The customer is kept as entered, with verification.status unverified.
Registering a CR number you already registered updates that customer and answers 200 instead of 201. Keep the customer’s id: every quote and application names it as customer_id.

Single shipment

Quote a shipment

The Quote a shipment API prices one shipment. It needs what sets the price: the goods, the route, the value and the cover wanted.
The insured amount. Leave insured_amount out and the shipment is insured for its value on the valuation_basis: The invoice can be in any of the currencies. The price is always in SAR.

Approved, referred or rejected

The call always answers 201. What happened is in status: reasons are plain sentences you can show as they are. A referral that ends well turns approved and its quote is filled; its reasons stay, so you can still say why it was reviewed. An approved quote looks like this:
total_price is what the customer pays, VAT included.

What is needed to issue

A shipment can be quoted before everything about it is known. Three details are needed before its policy can be issued, though none of them changes the price:
  • departure_date
  • conveyance.carrier_name
  • references.invoice_number
Send them with the quote request if you have them, or later with Issue a policy. missing_to_issue on the quote request lists the ones still missing.

Open cover

Apply for open cover

The Apply for open cover API asks for a one-year policy. Instead of one shipment, the application describes the business’s trade: the goods it ships, its routes, the value it expects to ship in the year and the most any one shipment will be worth.
The answer has the same three statuses as a single shipment; follow a referral with Read an open-cover application. When it is approved, quote holds the terms of the cover:

Issue the policy

The Issue a policy API accepts an approved quote, for a single shipment or for open cover:
  • shipment is for a single shipment only, and carries the details that were not on the quote request. While any is missing the call answers 40033, and missing_fields names them. An open cover needs only quote_request_id.
  • redirect_url is where the customer is sent after paying. policyID anywhere in it is replaced with the policy’s id.
The policy comes back unpaid: status is 0, coverage_confirmed is false and payment_link is where the customer pays. Nothing is covered yet. Calling Issue a policy again for the same quote before it is paid returns the same policy, updated. Once it is paid, the call answers 40026 with that policy_id.

Payment

Send the customer to the policy’s payment_link. It opens Yasmina’s secure card page, which shows the premium, the VAT and the total.
  • The link is valid for 24 hours. Read the policy to get the current one; it is renewed when it is about to expire.
  • When the payment succeeds, the policy is issued and the customer is sent to your redirect_url.
  • A failed or abandoned payment is never an API error. The policy stays unpaid until a payment succeeds.

The issued policy

After payment, Read the policy:
The List policies API returns all your cargo policies, and filters by type (single_shipment or open_cover) and customer_id.

Declare shipments under an open cover

Once an open-cover policy is paid for and issued, the business declares each shipment with the Declare a shipment API (POST /policies/{id}/declarations). A declared shipment looks like the shipment of a quote request, with two differences:
  • It does not name coverage, extensions or valuation_basis. Those are the policy’s.
  • It is covered straight away, so departure_date, conveyance.carrier_name and references.invoice_number are required, and departure_date has to fall within the policy period.
The declaration’s status says what happened: premium is what the shipment costs at the policy’s declaration_rate_percent. Declared premiums are reported on each declaration and totalled on the policy under declarations (count, insured_amount_sar, premium); they are not paid through a payment link. Declaring under a policy that is not paid for yet, or is past its last day, answers 40027.

Testing in Sandbox

In Sandbox the commercial registry and the insurance company are simulated, so you can reach every branch of the journey on purpose. Prices, exchange rates and documents are samples and carry no cover. A referral is decided about 20 seconds after it was made: read the request or the declaration again after that and it is approved.

Errors

A field that is missing or not valid answers 422 with code 42201, and details names each field. The Errors page has every code.