{
  "openapi": "3.0.0",
  "info": {
    "version": "0.0.1",
    "title": "Autoliv_Safety REST API - OEM / Partner (B2B)",
    "description": "The Autoliv Safety Platform connects in-vehicle safety hardware to the people and systems that need to act when something goes wrong.\n\n## The Business Case\n\nA safety device fitted to a vehicle watches continuously for crash and airbag-deployment events. The moment one happens, the device reports it here \u2014 with its location and the binary event-data recording it captured \u2014 so the event is preserved, the right people are alerted, and the device itself is kept up to date in the field. This API is the single interface behind that flow: it is what the device talks to, what an operator's back-end integrates with, and what the companion mobile experience is built on.\n\n### What you can do\n\n- **Identity & accounts** \u2014 authenticate against a trusted identity provider, rotate refresh tokens, and manage the account record that a device belongs to.\n- **Devices & components** \u2014 register a safety device, keep its record current, and validate or associate the inflator components fitted to it.\n- **Crash & deployment events** \u2014 report an event, upload the binary event-data recording, and follow the outcome of the alerting that the event triggers.\n- **Firmware over-the-air (FOTA)** \u2014 ask whether a newer firmware build applies to a device and download the signed binary to install it.\n\nThe exact set of operations you can see and call depends on the credentials you have been issued. Anything visible in this reference is available to you; operations outside your entitlement are simply not listed.\n\n### Access & isolation\n\nEvery request other than sign-in must carry `Authorization: Bearer <token>`. A token identifies both *who* is calling and *which organization* they belong to, and the platform resolves that organization on every request.\n\nData is isolated by organization end to end. Devices, events, and firmware are stamped with the organization that owns them, and a caller only ever reads or writes rows belonging to their own organization \u2014 a resource owned by another organization is reported as forbidden or simply not found. There is no cross-organization access, by design.\n\n### Conventions\n\n- **Versioning** \u2014 every route is prefixed with its major version (`/v1/`, `/v2/`). A published version's contract never changes; breaking changes ship as a new version alongside the old one.\n- **Payloads** \u2014 requests and responses are `application/json`, except binary transfers such as firmware images and event-data recordings, which use `application/octet-stream`.\n- **Errors** \u2014 failures return a JSON body with `error` and `message`. Expect `400` for invalid input, `401` for a missing or invalid token, `403` when the token is valid but not entitled to the resource, `404` when it does not exist, and `409` for a conflict such as re-reporting an event that has already been recorded.\n- **Idempotency** \u2014 events are keyed by the identifier you supply, so a retried report is rejected as a duplicate rather than recorded twice."
  },
  "servers": [
    {
      "url": "http://127.0.0.1"
    }
  ],
  "paths": {
    "/v1/devices/{deviceId}": {
      "put": {
        "tags": [
          "Device"
        ],
        "summary": "Update device information",
        "x-audience": "partner",
        "description": "Creates the device if it does not exist, otherwise updates it, so the\nrecorded state matches the physical device. Call it on registration,\nafter a deployment, after a firmware update, or as a periodic sync.\nThe call is idempotent.\n",
        "security": [
          {
            "Autoliv_Safety-OpenIDC": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "deviceId",
            "required": true,
            "description": "Device id",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrgDeviceUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Device information updated or created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Access Forbidden"
          },
          "404": {
            "description": "Device not found"
          },
          "500": {
            "description": "Failed to update or create device information"
          }
        }
      }
    },
    "/v1/events": {
      "post": {
        "tags": [
          "Event"
        ],
        "summary": "Create event",
        "x-audience": "partner",
        "description": "Records a deployment or near-deployment event reported by a device.\nThe event is the reference for any subsequent EDR data upload and\ndevice state update.\n",
        "security": [
          {
            "Autoliv_Safety-OpenIDC": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrgCrashEventRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Event created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrgCrashEventResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (e.g. malformed eventId)"
          },
          "403": {
            "description": "Access Forbidden"
          },
          "404": {
            "description": "Device not found"
          },
          "409": {
            "description": "An event with the same eventId already exists"
          }
        }
      }
    },
    "/v1/events/{eventId}/data": {
      "post": {
        "tags": [
          "Event"
        ],
        "summary": "Upload event data",
        "x-audience": "partner",
        "description": "Stores the binary EDR payload recorded by the device so the event can be\nanalysed. The event must be the same sent previously from [post] /v1/events request.\n",
        "security": [
          {
            "Autoliv_Safety-OpenIDC": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "eventId",
            "required": true,
            "description": "Event id",
            "schema": {
              "type": "string",
              "format": "UUID"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary",
                "description": "Binary event data payload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event data uploaded successfully"
          },
          "400": {
            "description": "Invalid event id format or empty request body"
          },
          "403": {
            "description": "Access Forbidden"
          },
          "404": {
            "description": "Event not found"
          },
          "500": {
            "description": "Failed to upload event data"
          }
        }
      }
    },
    "/v1/firmware/check": {
      "get": {
        "tags": [
          "FotaService"
        ],
        "summary": "Check firmware update",
        "x-audience": "partner",
        "description": "Returns whether a firmware update is available, based on the device's\ncurrent firmware version.\nOEM partners only see released firmware flagged isOemAvailable;\ndeviceId is ignored for them. Internal test-device targeting does not\nrestrict OEM availability.\nOther principals see any released firmware, or, when deviceId is given,\nonly what the rollout policy offers that device.\n",
        "security": [
          {
            "Autoliv_Safety-OpenIDC": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "firmwareVersion",
            "description": "Current firmware version on device",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "deviceId",
            "description": "Device for rollout evaluation, non-OEM only (optional)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Check executed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FotaUpdateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request"
          },
          "403": {
            "description": "Access Forbidden"
          }
        }
      }
    },
    "/v1/firmware/download": {
      "get": {
        "tags": [
          "FotaService"
        ],
        "summary": "Download firmware by version",
        "x-audience": "partner",
        "description": "Downloads firmware binary for organization principals using a strict\ncontract based on `firmwareVersion`.\nOEM partners only receive released firmware flagged isOemAvailable;\ndeviceId is ignored for them. Internal test-device targeting does not\nrestrict OEM availability.\nOther principals receive any released firmware, or, when deviceId is\ngiven, only a version the rollout policy offers that device.\n",
        "security": [
          {
            "Autoliv_Safety-OpenIDC": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "firmwareVersion",
            "description": "Firmware version to download",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "deviceId",
            "description": "Device for rollout evaluation, non-OEM only (optional)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Firmware binary returned",
            "headers": {
              "Content-Length": {
                "description": "The length of the binary content",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "403": {
            "description": "Access Forbidden"
          },
          "404": {
            "description": "Firmware version not found or not offered to the device"
          }
        }
      }
    },
    "/v1/inflator/{inflatorId}": {
      "get": {
        "tags": [
          "Device"
        ],
        "summary": "Get inflator validation information",
        "x-audience": "partner",
        "description": "Validates inflator ID format and checks if it exists in the database.\n",
        "security": [
          {
            "Autoliv_Safety-OpenIDC": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "inflatorId",
            "required": true,
            "description": "Inflator ID to validate",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inflator validation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InflatorValidationResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/v1/inflators": {
      "post": {
        "tags": [
          "Device"
        ],
        "summary": "Associate inflator with device",
        "x-audience": "partner",
        "description": "Links a validated inflator to a device, typically after an inflator is\nreplaced during servicing, so the component history stays accurate.\nAssociating the same inflator with the same device is idempotent.\n",
        "security": [
          {
            "Autoliv_Safety-OpenIDC": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrgAddInflatorRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inflator added successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddInflatorResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid inflator ID format"
          },
          "403": {
            "description": "Access Forbidden"
          },
          "404": {
            "description": "Device not found"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "Autoliv_Safety-OpenIDC": {
        "type": "openIdConnect",
        "openIdConnectUrl": "http://139.144.79.251:9011/.well-known/openid-configuration"
      }
    },
    "schemas": {
      "AddInflatorResponse": {
        "description": "Response for add inflator operation",
        "properties": {
          "message": {
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "message"
        ],
        "title": "AddInflatorResponse",
        "type": "object"
      },
      "DeployedState": {
        "description": "Enumeration of possible deployed states for the device",
        "enum": [
          "deployed",
          "not_deployed"
        ],
        "title": "DeployedState",
        "type": "string"
      },
      "DeviceResponse": {
        "description": "Generic response object for device operations",
        "properties": {
          "success": {
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "data": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DeviceResponseData"
              },
              {
                "type": "string",
                "nullable": true
              }
            ],
            "default": null
          }
        },
        "required": [
          "success",
          "message"
        ],
        "title": "DeviceResponse",
        "type": "object"
      },
      "DeviceResponseData": {
        "description": "Data structure for device response",
        "properties": {
          "deviceId": {
            "title": "Deviceid",
            "type": "string"
          },
          "hardwareVersion": {
            "title": "Hardwareversion",
            "type": "string"
          },
          "firmwareVersion": {
            "title": "Firmwareversion",
            "type": "string"
          },
          "numberOfInflations": {
            "title": "Numberofinflations",
            "type": "integer"
          },
          "numberOfMaxInflations": {
            "title": "Numberofmaxinflations",
            "type": "integer"
          },
          "productActivationState": {
            "$ref": "#/components/schemas/ProductActivationState"
          },
          "minutesOfUsage": {
            "title": "Minutesofusage",
            "type": "integer"
          },
          "deployedState": {
            "$ref": "#/components/schemas/DeployedState"
          }
        },
        "required": [
          "deviceId",
          "hardwareVersion",
          "firmwareVersion",
          "numberOfInflations",
          "numberOfMaxInflations",
          "productActivationState",
          "minutesOfUsage",
          "deployedState"
        ],
        "title": "DeviceResponseData",
        "type": "object"
      },
      "EventType": {
        "description": "Enumeration of possible event types for crash notifications.",
        "enum": [
          "DEPLOY",
          "OFFLINE_DEPLOY",
          "NEAR_DEPLOY",
          "NEAR_OTHER_EVENT",
          "OTHER_EVENT"
        ],
        "title": "EventType",
        "type": "string"
      },
      "FotaUpdateResponse": {
        "description": "Response for FOTA update information",
        "properties": {
          "nextVersion": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "string",
                "nullable": true
              }
            ],
            "default": null,
            "title": "Nextversion"
          },
          "isUpdateAvailable": {
            "title": "Isupdateavailable",
            "type": "boolean"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "string",
                "nullable": true
              }
            ],
            "default": null,
            "title": "Description"
          }
        },
        "required": [
          "isUpdateAvailable"
        ],
        "title": "FotaUpdateResponse",
        "type": "object"
      },
      "InflatorValidationResponse": {
        "description": "Response object for inflator validation",
        "properties": {
          "isValid": {
            "title": "Isvalid",
            "type": "boolean"
          },
          "isUsed": {
            "$ref": "#/components/schemas/UsageStatus"
          }
        },
        "required": [
          "isValid",
          "isUsed"
        ],
        "title": "InflatorValidationResponse",
        "type": "object"
      },
      "OrgAddInflatorRequest": {
        "description": "Organization-scoped request to add an inflator to a specific device.",
        "properties": {
          "inflatorId": {
            "title": "Inflatorid",
            "type": "string"
          },
          "deviceId": {
            "title": "Deviceid",
            "type": "string"
          }
        },
        "required": [
          "inflatorId",
          "deviceId"
        ],
        "title": "OrgAddInflatorRequest",
        "type": "object"
      },
      "OrgCrashEventRequest": {
        "description": "Org-scoped event creation payload.",
        "properties": {
          "eventId": {
            "title": "Eventid",
            "type": "string"
          },
          "deviceId": {
            "title": "Deviceid",
            "type": "string"
          },
          "eventType": {
            "$ref": "#/components/schemas/EventType",
            "description": "Type of the event"
          },
          "gpsLocation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "string",
                "nullable": true
              }
            ],
            "default": null,
            "description": "GPS location as 'latitude,longitude'",
            "title": "Gpslocation"
          }
        },
        "required": [
          "eventId",
          "deviceId",
          "eventType"
        ],
        "title": "OrgCrashEventRequest",
        "type": "object"
      },
      "OrgCrashEventResponse": {
        "description": "Org-scoped event creation response.\n\nThe grace-period fields are populated only when the caller is a consumer or\nPTW principal reporting a DEPLOY event, which schedules emergency SMS.",
        "properties": {
          "success": {
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "gracePeriodStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "string",
                "nullable": true
              }
            ],
            "default": null,
            "description": "Grace period status when emergency SMS was scheduled",
            "title": "Graceperiodstatus"
          },
          "gracePeriodStartTimeUnix": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "string",
                "nullable": true
              }
            ],
            "default": null,
            "description": "Unix timestamp when the grace period started",
            "title": "Graceperiodstarttimeunix"
          },
          "gracePeriodDuration": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "string",
                "nullable": true
              }
            ],
            "default": null,
            "description": "Grace period duration in seconds",
            "title": "Graceperiodduration"
          }
        },
        "required": [
          "success",
          "message"
        ],
        "title": "OrgCrashEventResponse",
        "type": "object"
      },
      "OrgDeviceUpdateRequest": {
        "description": "Organization-scoped device update.\n\nShares the consumer update contract; ownership is derived from the caller's\norganization rather than the request body.",
        "properties": {
          "numberOfInflations": {
            "title": "Numberofinflations",
            "type": "integer"
          },
          "numberOfMaxInflations": {
            "title": "Numberofmaxinflations",
            "type": "integer"
          },
          "productActivationState": {
            "$ref": "#/components/schemas/ProductActivationState"
          },
          "minutesOfUsage": {
            "title": "Minutesofusage",
            "type": "integer"
          },
          "deployedState": {
            "$ref": "#/components/schemas/DeployedState"
          },
          "firmwareVersion": {
            "title": "Firmwareversion",
            "type": "string"
          }
        },
        "required": [
          "numberOfInflations",
          "numberOfMaxInflations",
          "productActivationState",
          "minutesOfUsage",
          "deployedState",
          "firmwareVersion"
        ],
        "title": "OrgDeviceUpdateRequest",
        "type": "object"
      },
      "ProductActivationState": {
        "description": "Enumeration of possible product activation states",
        "enum": [
          "active",
          "inactive"
        ],
        "title": "ProductActivationState",
        "type": "string"
      },
      "UsageStatus": {
        "description": "Enumeration of component usage status",
        "enum": [
          "true",
          "false",
          "unknown"
        ],
        "title": "UsageStatus",
        "type": "string"
      }
    }
  }
}