openapi: 3.1.0
info:
  title: Wunder Fleet Hardware API
  version: 0.97.0
  description: |
    Wunder Fleet supports the implementation of custom hardware. This is done by using the Wunder Fleet hardware API.
    It allows to connect third party hardware which needs the specifications described in this document.
    Whenever Wunder Fleet needs to take advantage of the hardware capabilities it will call the methods described in this documents against the third party server.
  contact:
    name: Wunder Mobility GmbH
    url: 'https://wundermobility.com'
    email: info@wundermobility.com
servers:
  - url: https://api.wunderfleet.com
    description: Wunder Fleet API Server
paths:
  /devices/{deviceId}:
    get:
      summary: Get State
      description: Fetches the current device state from the device.
      operationId: getState
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StateResponse'
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device is offline
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
    post:
      summary: Push State
      description: |
        The Push State request changes the state of the device. The device can be unlocked / locked and / or mobilised / immobilised by using the parameters provided further down.

        If everything worked the current state of the vehicle will be returned.

        If the vehicle is offline or the a state could not be changed the error 409 should be returned instead of the device data.
      operationId: pushState
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
        - name: immobilised
          in: query
          required: false
          schema:
            type: boolean
          description: define if the immobiliser should be engaged
        - name: locked
          in: query
          required: false
          schema:
            type: boolean
          description: define if the lock should be engaged
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StateResponse'
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device is offline
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/locate:
    post:
      summary: Honk
      description: Make the vehicle honk.
      operationId: honk
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/reboot:
    post:
      summary: Reboot
      description: Reboot the vehicle's IoT.
      operationId: reboot
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/lock_battery_door:
    post:
      summary: Lock Battery Door
      description: Locks the vehicle's battery compartment.
      operationId: lockBatteryDoor
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/unlock_battery_door:
    post:
      summary: Unlock Battery Door
      description: Unlocks the vehicle's battery compartment.
      operationId: unlockBatteryDoor
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/set_lights_on:
    post:
      summary: Turn Lights On
      description: Turns the vehicle's lights on.
      operationId: setLightsOn
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/set_lights_off:
    post:
      summary: Turn Lights Off
      description: Turns the vehicle's lights off.
      operationId: setLightsOff
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/set_max_speed:
    post:
      summary: Set Max Speed
      description: Sets the vehicle's maximum speed.
      operationId: setMaxSpeed
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                value:
                  type: number
                  description: The maximum speed value
              required:
                - value
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/set_speed_unit:
    post:
      summary: Toggle Speed Unit
      description: Sets the vehicle's speed unit, which is displayed on the vehicle dashboard.
      operationId: setSpeedUnit
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                value:
                  type: number
                  description: The speed unit value
              required:
                - value
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/tailbox:
    post:
      summary: Set tailbox lock
      description: Sets the vehicle's tailbox lock.
      operationId: lockTailbox
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
        - name: lock
          in: query
          required: true
          schema:
            type: boolean
          description: The lock state of the tailbox
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/saddle:
    post:
      summary: Set saddle lock
      description: Sets the vehicle's saddle lock.
      operationId: lockSaddle
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
        - name: lock
          in: query
          required: true
          schema:
            type: boolean
          description: The lock state of the saddle
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/cable:
    post:
      summary: Set cable lock
      description: Sets the vehicle's cable lock.
      operationId: lockCable
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
        - name: lock
          in: query
          required: true
          schema:
            type: boolean
          description: The lock state of the cable lock
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/throttle_speed_on:
    post:
      summary: Throttle Speed On
      description: Throttle vehicle speed on.
      operationId: throttleSpeedOn
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
  /devices/{deviceId}/actions/throttle_speed_off:
    post:
      summary: Throttle Speed Off
      description: Throttle vehicle speed off.
      operationId: throttleSpeedOff
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the device
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "404":
          description: Device action unsupported
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
        "409":
          description: Conflict - Device state could not be changed
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  error:
                    type: string
                  key:
                    type: string
components:
  schemas:
    StateResponse:
      type: object
      properties:
        deviceId:
          type: string
        eventId:
          type: integer
        timestamp:
          type: integer
        lat:
          type: number
          format: float
        lon:
          type: number
          format: float
        position_accuracy:
          type: integer
        energy_level:
          type: number
          format: float
        locked:
          type: boolean
        immobilised:
          type: boolean
        ignition_on:
          type: boolean
        mileage:
          type: number
          format: float
        box_closed:
          type: boolean
        key_inserted:
          type: boolean
        on_stand:
          type: boolean
        lights:
          type: string
          enum: [ on, off ]
        doors:
          type: string
          enum: [ open, closed ]
        windows:
          type: string
          enum: [ open, closed ]
        sunroof:
          type: string
          enum: [ open, closed ]
        gear:
          type: string
          enum: [ P, R, N, D, U ]
        cable_lock:
          type: boolean
        saddle:
          type: string
          enum: [ open, closed ]
        tailbox:
          type: string
          enum: [ open, closed ]
        electric_vehicle_state:
          type: object
          properties:
            charge:
              type: string
              enum: [ on, off ]
        in_station:
          type: boolean
        iot_battery_level:
          type: integer
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: FLEETBIRD-API-KEY
security:
  - ApiKeyAuth: []