curl --request POST \
--url https://sandbox.yasmina.ai/api/v2/car/policies/{carPolicy}/cancellation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form cancellation_document='@example-file'import requests
url = "https://sandbox.yasmina.ai/api/v2/car/policies/{carPolicy}/cancellation"
files = { "cancellation_document": ("example-file", open("example-file", "rb")) }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('cancellation_document', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://sandbox.yasmina.ai/api/v2/car/policies/{carPolicy}/cancellation', 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/{carPolicy}/cancellation",
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=\"cancellation_document\"; 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/{carPolicy}/cancellation"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cancellation_document\"; 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/{carPolicy}/cancellation")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cancellation_document\"; 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/{carPolicy}/cancellation")
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=\"cancellation_document\"; 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": "40010",
"message": "Policy is already canceled"
}{
"code": "40101",
"message": "Unauthenticated"
}{
"code": "40401",
"message": "Not found"
}{
"code": 42201,
"message": "The cancellation document is incorrect. Please upload a new one.",
"details": {
"vin": [
"The VIN in the cancellation document does not match this policy."
],
"car_sequence_number": [
"The sequence number in the cancellation document does not match this policy."
],
"owner_id": [
"The owner ID in the cancellation document is still the same as the policy owner. Upload the document after ownership transfer is complete."
]
}
}Cancel policy
Cancel a policy
curl --request POST \
--url https://sandbox.yasmina.ai/api/v2/car/policies/{carPolicy}/cancellation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form cancellation_document='@example-file'import requests
url = "https://sandbox.yasmina.ai/api/v2/car/policies/{carPolicy}/cancellation"
files = { "cancellation_document": ("example-file", open("example-file", "rb")) }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('cancellation_document', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://sandbox.yasmina.ai/api/v2/car/policies/{carPolicy}/cancellation', 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/{carPolicy}/cancellation",
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=\"cancellation_document\"; 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/{carPolicy}/cancellation"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cancellation_document\"; 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/{carPolicy}/cancellation")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cancellation_document\"; 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/{carPolicy}/cancellation")
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=\"cancellation_document\"; 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": "40010",
"message": "Policy is already canceled"
}{
"code": "40101",
"message": "Unauthenticated"
}{
"code": "40401",
"message": "Not found"
}{
"code": 42201,
"message": "The cancellation document is incorrect. Please upload a new one.",
"details": {
"vin": [
"The VIN in the cancellation document does not match this policy."
],
"car_sequence_number": [
"The sequence number in the cancellation document does not match this policy."
],
"owner_id": [
"The owner ID in the cancellation document is still the same as the policy owner. Upload the document after ownership transfer is complete."
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
Updated vehicle information document after ownership transfer. Upload a PDF, JPG, JPEG, or PNG file. The document must include the same VIN and sequence number as the policy, and the owner ID must be different from the policy owner.
Response
Cancellation success
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.