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.
Basic Journey
- Authorize: Get an access token to authenticate all API requests.
- Get the options: Fetch the values your forms offer: goods categories, transport modes, coverages and the rest.
- Register the customer: Register the business by its commercial registration (CR) number.
- Get a decision: Quote a shipment, or apply for open cover. The answer is approved, referred or rejected.
- Issue the policy: Accept an approved quote. The policy comes back with a payment link.
- Payment: The customer pays, and the policy is issued with its certificate and tax invoice.
- Declare shipments (open cover only): Declare each shipment under the policy and get its certificate.
Prerequisites
- Account in Yasmina - See the Onboarding section for details.
- Authenticated Token - Follow the Authentication guide to generate one.
- Backend server - Required to securely call Yasmina APIs.
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 thevalue 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 registry knows the business. Its legal name and address come from the registry, and the customer’s
verification.statusisverified. You do not need to ask your user for them. - The registry has no record. The call answers
400with code40031. Ask your user for the legal name and address and send the call again withlegal_nameandaddress(streetandcityat least). The customer is kept as entered, withverification.statusunverified.
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.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 answers201. 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_dateconveyance.carrier_namereferences.invoice_number
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.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:shipmentis for a single shipment only, and carries the details that were not on the quote request. While any is missing the call answers40033, andmissing_fieldsnames them. An open cover needs onlyquote_request_id.redirect_urlis where the customer is sent after paying.policyIDanywhere in it is replaced with the policy’s id.
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’spayment_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,extensionsorvaluation_basis. Those are the policy’s. - It is covered straight away, so
departure_date,conveyance.carrier_nameandreferences.invoice_numberare required, anddeparture_datehas to fall within the policy period.
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.