Перейти к содержимому
Открыта пилотная программа: 14 дней бесплатно для автопарка до 5 грузовиковПодать заявку
Preview

The Rigsight API, webhooks and embed agent are in private beta. Request access at hello@rigsight.uz or book a demo.

Embed agent

The <rigsight-pti> web component

A drop-in inspection UI for your TMS, fleet portal or driver web app. Drivers upload photos and videos, dispatchers see defects on a 3D truck model and record decisions — all without exposing your secret key.

Install

Add the script once per page. It registers the custom element and loads nothing else until the element is used.

HTML
<script src="https://embed.rigsight.uz/v1/agent.js" defer></script>

Then place the element where the inspection should appear. It is a standard custom element, so it works with plain HTML, React, Vue, Angular or server-rendered templates.

Attributes

tokenstringRequired
A 15-minute rs_pub_… token from POST /v1/embed-tokens, created by your backend for this page view.
truckstringOptional
Unit number or truck id. Must match the truck the token was issued for; defaults to it.
localeenumOptional
en, ru or uz. UI and report language. Defaults to the token's locale.
viewenumOptional
3d (default) shows defects on a truck model; list shows a compact list.
themeenumOptional
light (default) or dark.

Full example

inspect.html · HTML
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Truck 1045 · Inspection</title>
    <script src="https://embed.rigsight.uz/v1/agent.js" defer></script>
  </head>
  <body>
    <!-- token: 15-minute rs_pub_… token printed by your backend for this page view -->
    <rigsight-pti
      token="rs_pub_Zx81…"
      truck="1045"
      locale="en"
      view="3d"
      theme="light">
    </rigsight-pti>

    <script>
      const pti = document.querySelector("rigsight-pti");

      pti.addEventListener("rigsight:completed", (event) => {
        const { ptiId, status, defects } = event.detail;
        if (status === "OUT_OF_SERVICE") {
          showBanner("Truck 1045 needs a safety review before dispatch");
        }
      });

      pti.addEventListener("rigsight:reviewed", (event) => {
        const { ptiId, decision, user } = event.detail;
        refreshDispatchBoard();
      });
    </script>
  </body>
</html>

Issuing tokens on your backend

Your server authenticates the user with your own login, decides which scopes they get, and requests a token with your secret key. Issue a fresh token for every page view; when it expires the component asks the page to reload.

ScopeLets the browser
uploadCreate a PTI for the token's truck, upload media and submit.
readView results, defects and photos of that truck.
reviewRecord approved / repair / oos decisions (audit-logged with the user).
Node.js (Express) · JavaScript
import express from "express";

const app = express();

// Your own auth middleware decides who may inspect or review which truck.
app.get("/trucks/:unit/inspect", requireLogin, async (req, res) => {
  const r = await fetch("https://api.rigsight.uz/v1/embed-tokens", {
    method: "POST",
    headers: {
      Authorization: "Bearer " + process.env.RIGSIGHT_SECRET_KEY, // rs_live_…, server only
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      truck: req.params.unit,
      scopes: req.user.isDispatcher ? ["read", "review"] : ["upload", "read"],
      locale: req.user.locale ?? "en",
      user: req.user.email, // recorded with review decisions
    }),
  });
  if (!r.ok) return res.status(502).send("Could not start inspection");

  const { token } = await r.json(); // rs_pub_…, valid 15 minutes
  res.render("inspect", { token, unit: req.params.unit });
});
PHP · PHP
<?php
// Called by your page controller after your own login and permission checks.
function rigsight_embed_token(string $truck, array $scopes, string $locale = "en"): string
{
    $ch = curl_init("https://api.rigsight.uz/v1/embed-tokens");
    curl_setopt_array($ch, [
        CURLOPT_POST           => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER     => [
            "Authorization: Bearer " . getenv("RIGSIGHT_SECRET_KEY"), // server only
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS     => json_encode([
            "truck"  => $truck,
            "scopes" => $scopes,
            "locale" => $locale,
            "user"   => $_SESSION["email"] ?? null, // recorded with review decisions
        ]),
    ]);
    $body   = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($status !== 201) {
        throw new RuntimeException("Rigsight token request failed: " . $status);
    }
    return json_decode($body, true)["token"]; // rs_pub_…
}

$token = rigsight_embed_token("1045", ["upload", "read"], "uz");
?>
<rigsight-pti token="<?= htmlspecialchars($token) ?>" truck="1045" locale="uz"></rigsight-pti>

DOM events

The element dispatches CustomEvents that bubble and cross the shadow DOM boundary. Treat them as UI signals; for anything that matters (billing, dispatch blocking) confirm via webhooks or the API.

rigsight:completed

Fired when the analysis of a PTI started or shown in this element finishes.

JavaScript
// event.detail for "rigsight:completed"
{
  ptiId: "pti_9f2c41d7",
  truck: { id: "trk_12", unitNumber: "1045" },
  status: "OUT_OF_SERVICE",            // "PASS" | "NEEDS_REPAIR" | "OUT_OF_SERVICE"
  defects: [
    {
      id: "def_7781",
      component: "left front tire",
      severity: "critical",            // "critical" | "major" | "minor"
      description: "Tread below 4/32\"",
      recurring: false
    }
  ],
  unclearComponents: [],
  requiresHumanReview: true
}

rigsight:reviewed

Fired when a user records a review decision inside the element.

JavaScript
// event.detail for "rigsight:reviewed"
{
  ptiId: "pti_9f2c41d7",
  truck: { id: "trk_12", unitNumber: "1045" },
  decision: "oos",                     // "approved" | "repair" | "oos"
  user: "safety@fleet.example",
  comment: "Confirmed with tread gauge.",
  createdAt: "2026-11-28T09:21:30Z"
}

Listening

JavaScript
document.addEventListener("rigsight:completed", (event) => {
  // Events bubble and are composed, so you can listen on document.
  const { ptiId, status } = event.detail;
  fetch("/api/inspections/" + ptiId + "/sync", { method: "POST" }); // re-fetch from your backend
});

3D view

  • The truck (and trailer, if inspected) is shown as a 3D model. Each defect is a coloured marker at its location: red for critical, orange for major and grey for minor. Recurring defects have a ring.
  • Clicking a marker opens the photo or video frame that shows the defect, with the AI's description.
  • Drag to rotate, pinch or scroll to zoom. Keyboard users can tab through markers in severity order.
  • On low-end devices or without WebGL, the component falls back to view="list" automatically.

Security

Never put your secret key in the browser

Only rs_pub_… tokens belong in HTML. They expire after 15 minutes, are bound to one truck and carry only the scopes you granted. Your rs_live_… key stays on your server.

If your site uses a Content Security Policy, allow these sources:

HTTP
Content-Security-Policy:
  script-src  'self' https://embed.rigsight.uz;
  connect-src 'self' https://api.rigsight.uz;
  img-src     'self' https://media.rigsight.uz;

Uploads go from the browser straight to signed storage URLs on media.rigsight.uz; add it to connect-src as well if your policy restricts uploads.

Size and browser support

  • About 150 KB gzipped, loaded with defer and cached for a long time. The 3D model loads only when view="3d" is shown.
  • Latest two versions of Chrome, Edge, Firefox and Safari, including Safari on iOS 16+ and Chrome on Android 10+.
  • Camera capture on phones uses the native file picker, so drivers can take photos without installing an app.