> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yasmina.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create embed session

> Requests quotes and opens an embeddable session on them in one call, and returns a URL to put in an iframe or a WebView. Takes everything Request Quotes takes, plus where the session will run.

The customer compares quotes, chooses add-ons, gives a payout account, uploads vehicle photos and verifies by OTP inside the embed. The issued policy and its payment link are handed back to your page or your app.

To show the quotes again after the hour is up, call this again with the same payload. The quote OTP stays valid for hours, so the customer is not asked to verify twice.

Register the sites and app links a session may be opened for in API Management first.



## OpenAPI

````yaml /car-api-reference/openapi.json post /embed-sessions
openapi: 3.0.1
info:
  title: OpenAPI For Motor Insurance
  description: API's that you need to use to issue insurance policies to your clients
  license:
    name: MIT
  version: 1.0.0
servers:
  - x-fern-server-name: Sandbox
    url: https://sandbox.yasmina.ai/api/v1/car-comp
  - x-fern-server-name: Production
    url: https://production.yasmina.ai/api/v1/car-comp
security:
  - Oauth2: []
paths:
  /embed-sessions:
    post:
      tags:
        - Embed sessions
      summary: Create embed session
      description: >-
        Requests quotes and opens an embeddable session on them in one call, and
        returns a URL to put in an iframe or a WebView. Takes everything Request
        Quotes takes, plus where the session will run.


        The customer compares quotes, chooses add-ons, gives a payout account,
        uploads vehicle photos and verifies by OTP inside the embed. The issued
        policy and its payment link are handed back to your page or your app.


        To show the quotes again after the hour is up, call this again with the
        same payload. The quote OTP stays valid for hours, so the customer is
        not asked to verify twice.


        Register the sites and app links a session may be opened for in API
        Management first.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - otp
                - owner_id
                - email
                - phone
                - birthdate
                - car_estimated_cost
                - platform
              properties:
                otp:
                  type: string
                  pattern: ^\d{4}$
                  description: The OTP received by the customer from the Request OTP API
                  example: '1234'
                owner_id:
                  type: string
                  pattern: ^(1|2)\d{9}$
                  description: >-
                    The owner's national ID (starts with 1 for Saudi nationals)
                    or Iqama ID (starts with 2 for residents). Must be exactly
                    10 digits.
                email:
                  type: string
                  format: email
                  description: Email address must be valid and belongs to the customer
                phone:
                  type: string
                  pattern: ^05\d{8}$
                  description: Phone number must start with 05 and be 10 digits
                birthdate:
                  type: string
                  format: date
                  description: Birthdate in YYYY-MM-DD format
                car_sequence_number:
                  type: string
                  pattern: ^\d{8,9}$
                  description: Car sequence number must be 8 or 9 digits
                custom_number:
                  type: string
                  pattern: ^[1-9]\d{5,9}$
                  description: >-
                    Customs card number between 100000 and 9999999999 for an
                    imported vehicle. When provided, maker_code, model_code, and
                    body_type_code are required, and car_sequence_number must be
                    omitted.
                maker_code:
                  type: integer
                  description: >-
                    Required with custom_number. Use a code returned by GET
                    /vehicle-makers.
                  example: 101
                model_code:
                  type: integer
                  description: >-
                    Required with custom_number. Use a code returned by GET
                    /vehicle-models for the selected maker_code.
                  example: 1001
                body_type_code:
                  type: integer
                  description: >-
                    Required with custom_number. Use a code returned by GET
                    /vehicle-body-types.
                  example: 3
                is_ownership_transfer:
                  type: boolean
                  default: false
                  description: Indicates if the ownership is being transferred
                current_car_owner_id:
                  type: string
                  pattern: ^(1|2)\d{9}$
                  description: >-
                    Required if is_ownership_transfer is true; the current
                    owner's national ID (starts with 1) or Iqama ID (starts with
                    2). Must be exactly 10 digits.
                car_estimated_cost:
                  type: number
                  description: Estimated cost of the car
                car_model_year:
                  type: integer
                  minimum: 1950
                  maximum: 2026
                  description: Car model year between 1950 and next year
                start_date:
                  type: string
                  format: date
                  description: >-
                    Desired policy start date in YYYY-MM-DD. Must be between
                    tomorrow and 28 days from today (inclusive). The platform
                    validates this range server-side.
                  example: '2025-12-11'
                drivers:
                  type: array
                  description: >-
                    List of drivers for the vehicle. When provided, the sum of
                    all driving_percentage values must equal 100, and the owner
                    must be included among the drivers.
                  items:
                    type: object
                    required:
                      - owner_id
                      - birthdate
                      - driving_percentage
                    properties:
                      owner_id:
                        type: string
                        pattern: ^(1|2)\d{9}$
                        description: >-
                          Driver's national ID (starts with 1 for Saudi
                          nationals) or Iqama ID (starts with 2 for residents).
                          Must be exactly 10 digits.
                      birthdate:
                        type: string
                        format: date
                        description: Driver's birthdate in YYYY-MM-DD format.
                      driving_percentage:
                        type: integer
                        enum:
                          - 25
                          - 50
                          - 75
                          - 100
                        description: >-
                          Percentage of driving for this driver. Valid values
                          are 25, 50, 75, or 100. The sum of all drivers'
                          percentages must equal 100.
                  example:
                    - owner_id: '1234567890'
                      birthdate: '1990-01-15'
                      driving_percentage: 50
                    - owner_id: '2345678901'
                      birthdate: '1985-06-20'
                      driving_percentage: 50
                platform:
                  type: string
                  enum:
                    - web
                    - webview
                  description: >-
                    Where the session will run. `web` for an iframe, `webview`
                    for a mobile app. There is no default: each one requires a
                    different field below.
                parent_origin:
                  type: string
                  description: >-
                    Web only, and required there. The site the iframe will sit
                    on: scheme and domain with nothing after it. Must be one of
                    the iframe hosts registered in API Management. Prohibited
                    for a webview, which has no origin.
                  example: https://www.example.com
                deep_link:
                  type: string
                  description: >-
                    WebView only, and required there. Where your app is reopened
                    once the policy is issued, with `?yasmina_policy_id=` added.
                    Must be one of the deep links registered in API Management.
                    Prohibited for the web, which is handed the policy by
                    postMessage instead.
                  example: myapp://insurance/done
                locale:
                  type: string
                  enum:
                    - ar
                    - en
                  description: >-
                    The language the embed opens in. Defaults to the customer's
                    browser.
      responses:
        '201':
          description: The session, with the URL to embed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbedSession'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
components:
  schemas:
    EmbedSession:
      type: object
      properties:
        id:
          type: integer
          description: The session id, for reading it back later.
          example: 1
        quote_request_id:
          type: integer
          description: >-
            The quote request the embed was opened on. Yours to keep; you never
            send it back.
          example: 42
        platform:
          type: string
          enum:
            - web
            - webview
          description: What the session was opened for.
        embed_url:
          type: string
          description: >-
            Put this in an iframe or a WebView. Belongs to one customer and
            expires after an hour.
          example: https://.../embed?session=8TJLiR0YhE8ikWSH3N16br2Q4qDg0ozGu18c5c3E
        expires_at:
          type: string
          format: date-time
          description: When the URL stops working.
    Error:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
  responses:
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: '40101'
              message:
                type: string
                example: Unauthenticated
    UnprocessableEntity:
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    Oauth2:
      description: JWT Authorization header using the Bearer scheme
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /oauth/token
          scopes: {}

````