curl --request POST \
--url https://sandbox.yasmina.ai/api/v2/car/policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form [email protected] \
--form 'vin=<string>' \
--form 'car_sequence_number=<string>' \
--form 'current_car_owner=<string>' \
--form 'new_owner_id=<string>' \
--form istimarah='@example-file'import requests
url = "https://sandbox.yasmina.ai/api/v2/car/policies"
files = { "istimarah": ("example-file", open("example-file", "rb")) }
payload = {
"email": "[email protected]",
"vin": "<string>",
"car_sequence_number": "<string>",
"current_car_owner": "<string>",
"new_owner_id": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('email', '[email protected]');
form.append('vin', '<string>');
form.append('car_sequence_number', '<string>');
form.append('current_car_owner', '<string>');
form.append('new_owner_id', '<string>');
form.append('istimarah', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://sandbox.yasmina.ai/api/v2/car/policies', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.yasmina.ai/api/v2/car/policies",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"vin\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"car_sequence_number\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"current_car_owner\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"new_owner_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"istimarah\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.yasmina.ai/api/v2/car/policies"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"vin\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"car_sequence_number\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"current_car_owner\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"new_owner_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"istimarah\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.yasmina.ai/api/v2/car/policies")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"vin\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"car_sequence_number\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"current_car_owner\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"new_owner_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"istimarah\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.yasmina.ai/api/v2/car/policies")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"vin\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"car_sequence_number\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"current_car_owner\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"new_owner_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"istimarah\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": 123,
"meta_data": {
"extra_fields": {},
"incorrect_info_message": "<string>"
},
"status": 0,
"client_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"product_id": 123,
"insurance_company_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"provider_policy_id": "<string>",
"provider_policy": "<string>",
"policy_url": "<string>",
"invoice": "<string>",
"invoice_url": "<string>",
"payment_link": "<string>",
"price": 123,
"redirect_url": "<string>",
"start_date": "2023-12-25",
"uploaded_at": "2023-11-07T05:31:56Z",
"purchased_at": "2023-11-07T05:31:56Z",
"transfer_date_at": "2023-11-07T05:31:56Z",
"cancellation_request_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"cancellation_confirmed_at": "2023-11-07T05:31:56Z",
"cancellation_document": "<string>",
"is_old_policy": 123,
"pdf_parsed": 123,
"has_sent_cancellation_email": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}{
"code": "40101",
"message": "Unauthenticated"
}{
"code": "42201",
"message": "The vin must be 17 characters. (and 3 more errors)",
"details": {
"email": [
"The email must be a valid email address."
],
"vin": [
"The vin must be 17 characters."
],
"car_sequence_number": [
"The car sequence number must be between 8 and 9 digits."
],
"new_owner_id": [
"The new owner id must be 10 digits."
],
"current_car_owner": [
"The current owner id must be 10 digits."
],
"istimarah": [
"The istimarah field is required."
]
}
}Issue policy
For issuing a new policy. This version requires an email field and an istimarah document upload.
curl --request POST \
--url https://sandbox.yasmina.ai/api/v2/car/policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form [email protected] \
--form 'vin=<string>' \
--form 'car_sequence_number=<string>' \
--form 'current_car_owner=<string>' \
--form 'new_owner_id=<string>' \
--form istimarah='@example-file'import requests
url = "https://sandbox.yasmina.ai/api/v2/car/policies"
files = { "istimarah": ("example-file", open("example-file", "rb")) }
payload = {
"email": "[email protected]",
"vin": "<string>",
"car_sequence_number": "<string>",
"current_car_owner": "<string>",
"new_owner_id": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('email', '[email protected]');
form.append('vin', '<string>');
form.append('car_sequence_number', '<string>');
form.append('current_car_owner', '<string>');
form.append('new_owner_id', '<string>');
form.append('istimarah', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://sandbox.yasmina.ai/api/v2/car/policies', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.yasmina.ai/api/v2/car/policies",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"vin\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"car_sequence_number\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"current_car_owner\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"new_owner_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"istimarah\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.yasmina.ai/api/v2/car/policies"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"vin\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"car_sequence_number\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"current_car_owner\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"new_owner_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"istimarah\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.yasmina.ai/api/v2/car/policies")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"vin\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"car_sequence_number\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"current_car_owner\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"new_owner_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"istimarah\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.yasmina.ai/api/v2/car/policies")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"vin\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"car_sequence_number\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"current_car_owner\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"new_owner_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"istimarah\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": 123,
"meta_data": {
"extra_fields": {},
"incorrect_info_message": "<string>"
},
"status": 0,
"client_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"product_id": 123,
"insurance_company_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"provider_policy_id": "<string>",
"provider_policy": "<string>",
"policy_url": "<string>",
"invoice": "<string>",
"invoice_url": "<string>",
"payment_link": "<string>",
"price": 123,
"redirect_url": "<string>",
"start_date": "2023-12-25",
"uploaded_at": "2023-11-07T05:31:56Z",
"purchased_at": "2023-11-07T05:31:56Z",
"transfer_date_at": "2023-11-07T05:31:56Z",
"cancellation_request_at": "2023-11-07T05:31:56Z",
"canceled_at": "2023-11-07T05:31:56Z",
"cancellation_confirmed_at": "2023-11-07T05:31:56Z",
"cancellation_document": "<string>",
"is_old_policy": 123,
"pdf_parsed": 123,
"has_sent_cancellation_email": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}{
"code": "40101",
"message": "Unauthenticated"
}{
"code": "42201",
"message": "The vin must be 17 characters. (and 3 more errors)",
"details": {
"email": [
"The email must be a valid email address."
],
"vin": [
"The vin must be 17 characters."
],
"car_sequence_number": [
"The car sequence number must be between 8 and 9 digits."
],
"new_owner_id": [
"The new owner id must be 10 digits."
],
"current_car_owner": [
"The current owner id must be 10 digits."
],
"istimarah": [
"The istimarah field is required."
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Email address. It must use the domain approved for your client account.
Vehicle Identification Number (17 characters, must be unique)
Car sequence number (8-9 digits, must be unique)
The current owner's national ID (starts with 1 for Saudi nationals) or Iqama ID (starts with 2 for residents). Must be exactly 10 digits.
The new owner's national ID (starts with 1 for Saudi nationals) or Iqama ID (starts with 2 for residents). Must be exactly 10 digits.
Vehicle registration document (PDF, JPEG, JPG, or PNG, max 10MB)
Optional free-form object with additional fields. Total JSON-encoded size must not exceed 255 characters.
{
"some_key": "some value",
"another_key": 123
}
Response
Created
Yasmina's unique identifier for the policy. Use it to correlate webhook payloads with your records.
The information the policy was requested with: vin, email, car_sequence_number, current_car_owner, new_owner_id, the stored istimarah document path, and the extra_fields object you submitted (echoed back unchanged, useful for carrying your own reference IDs). When the policy is placed on hold (status = 3), incorrect_info_message explains what needs to be corrected.
Policy lifecycle status:
0— Pending issuance: the request was received and the policy has not been issued yet.1— Issued: the policy has been issued;policy_urlandinvoice_urlpoint to the policy and invoice documents.2— Canceled: cancellation was requested or completed (cancellation_request_at/canceled_atare set).3— On hold, correction required: Yasmina flagged the submitted information as incorrect (for example an unreadable istimarah). The reason is provided inmeta_data.incorrect_info_message. This status is not final: once a corrected document is provided, the status returns to0(pending) and the policy can still be issued (1).
Every status change triggers the Status Update webhook, so your webhook endpoint should accept any transition between these values.
0, 1, 2, 3 Identifier of your client account.
Identifier of the Yasmina product this policy belongs to.
Identifier of the insurance company issuing the policy.
The policy number assigned by the policy provider. null until assigned.
Storage path of the issued policy document. Use policy_url for a downloadable link. null until the policy is issued.
Download URL of the issued policy document. null until the policy is issued.
Storage path of the invoice document. Use invoice_url for a downloadable link. null until available.
Download URL of the invoice document. null until available.
Secure payment link generated by Yasmina, when payment is required.
Price of the policy in Saudi Riyal.
URL the customer is redirected to after payment, when configured.
Start date of the policy coverage.
When the issued policy document was uploaded.
When the policy was purchased.
When the vehicle ownership transfer took place.
When cancellation was requested. Non-null implies status = 2.
When the policy was canceled. Non-null implies status = 2.
When the cancellation was confirmed by the insurance company.
Storage path of the cancellation document submitted with a cancellation request.
Internal flag; 0 for policies issued through this API.
Internal flag indicating whether the issued policy PDF has been parsed.
Internal flag indicating whether a cancellation email has been sent.
When the policy request was created.
When the policy was last updated.
When the policy was deleted, if ever.