{
  "openapi": "3.1.1",
  "info": {
    "title": "Scan Yer Van API",
    "description": "Read your own Scan Yer Van data: vehicles, stickers, and what people did after scanning. Create a key in your dashboard and send it as 'Authorization: Bearer syv_…'. Shows what people did, never who. 120 requests a minute per key.",
    "version": "v1"
  },
  "servers": [
    {
      "url": "http://api.scanyervan.co.uk/"
    }
  ],
  "paths": {
    "/v1/scans/summary": {
      "get": {
        "tags": [
          "Scans"
        ],
        "summary": "Scan summary",
        "description": "Totals over the period you ask for: scans, which buttons were pressed, each vehicle's activity,\nand — from scans where the person chose to share their location — areas, area types and weather. Never who.",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "description": "How many days back, 1–3650. Defaults to 30. Capped at what your plan's history includes;\n    `fromUtc` in the response says where the period really starts.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanSummaryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/stickers": {
      "get": {
        "tags": [
          "Stickers"
        ],
        "summary": "List stickers",
        "description": "Your live stickers — which vehicle and panel each is on, and how often it has been scanned.",
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponseOfStickerResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/vehicles": {
      "get": {
        "tags": [
          "Vehicles"
        ],
        "summary": "List vehicles",
        "description": "Your vehicles, with how many live stickers each has.",
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponseOfVehicleResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CountResponse": {
        "required": [
          "name",
          "count"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "What was counted."
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "How many.",
            "format": "int32"
          }
        },
        "description": "A named count."
      },
      "ListResponseOfStickerResponse": {
        "required": [
          "data"
        ],
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StickerResponse"
            },
            "description": "The items."
          }
        },
        "description": "A list of items. Wrapped so fields such as paging can be added later without breaking callers."
      },
      "ListResponseOfVehicleResponse": {
        "required": [
          "data"
        ],
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VehicleResponse"
            },
            "description": "The items."
          }
        },
        "description": "A list of items. Wrapped so fields such as paging can be added later without breaking callers."
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "ScanSummaryResponse": {
        "required": [
          "fromUtc",
          "toUtc",
          "totalScans",
          "buttonsPressed",
          "vehicles",
          "areas",
          "areaTypes",
          "weather",
          "dayOrNight",
          "whenScanned"
        ],
        "type": "object",
        "properties": {
          "fromUtc": {
            "type": "string",
            "description": "Start of the period (UTC). Never earlier than the plan's history allows.",
            "format": "date-time"
          },
          "toUtc": {
            "type": "string",
            "description": "End of the period (UTC): now.",
            "format": "date-time"
          },
          "totalScans": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Scans in the period.",
            "format": "int32"
          },
          "buttonsPressed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CountResponse"
            },
            "description": "Which contact buttons were tapped, and how often (Call, Text, WhatsApp, Email, Website, socials)."
          },
          "vehicles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VehicleActivityResponse"
            },
            "description": "Scans and taps per vehicle, busiest first."
          },
          "areas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CountResponse"
            },
            "description": "Scans by postcode district. Districts with only a few scans are grouped, so no one scan can be placed."
          },
          "areaTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CountResponse"
            },
            "description": "Scans by kind of area (e.g. urban, rural)."
          },
          "weather": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CountResponse"
            },
            "description": "Scans by the weather at the time."
          },
          "dayOrNight": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CountResponse"
            },
            "description": "Scans in daylight and in the dark."
          },
          "whenScanned": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WhenScannedResponse"
            },
            "description": "Scans by day of the week and time of day, in UK time."
          }
        },
        "description": "What people did over a period — the same totals the dashboard shows. Never who: no scan is linked to a person.\nArea, area type and weather come only from scans where the person chose to share their location."
      },
      "StickerResponse": {
        "required": [
          "code",
          "vehicleRegistration",
          "panel",
          "scans",
          "lastScanUtc"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The code printed in the sticker's QR (the last part of its scan link)."
          },
          "vehicleRegistration": {
            "type": [
              "null",
              "string"
            ],
            "description": "The vehicle it is on."
          },
          "panel": {
            "type": [
              "null",
              "string"
            ],
            "description": "Where on the vehicle, e.g. Rear, Nearside, Offside, Front."
          },
          "scans": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Scans since the sticker went live.",
            "format": "int32"
          },
          "lastScanUtc": {
            "type": [
              "null",
              "string"
            ],
            "description": "When it was last scanned (UTC), if ever.",
            "format": "date-time"
          }
        },
        "description": "A live sticker and how often it has been scanned, all time."
      },
      "VehicleActivityResponse": {
        "required": [
          "vehicleId",
          "registration",
          "scans",
          "taps",
          "lastScanUtc"
        ],
        "type": "object",
        "properties": {
          "vehicleId": {
            "type": "string",
            "description": "The vehicle's Guid VehicleResponse.Id.",
            "format": "uuid"
          },
          "registration": {
            "type": "string",
            "description": "The number plate."
          },
          "scans": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Scans in the period.",
            "format": "int32"
          },
          "taps": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Contact buttons tapped after those scans.",
            "format": "int32"
          },
          "lastScanUtc": {
            "type": [
              "null",
              "string"
            ],
            "description": "Its most recent scan in the period (UTC).",
            "format": "date-time"
          }
        },
        "description": "One vehicle's activity in the period."
      },
      "VehicleResponse": {
        "required": [
          "id",
          "registration",
          "make",
          "colour",
          "activeStickers",
          "retired"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable identifier for the vehicle.",
            "format": "uuid"
          },
          "registration": {
            "type": "string",
            "description": "The number plate."
          },
          "make": {
            "type": [
              "null",
              "string"
            ],
            "description": "Make, from DVLA, when known."
          },
          "colour": {
            "type": [
              "null",
              "string"
            ],
            "description": "Body colour, from DVLA, when known."
          },
          "activeStickers": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "How many of its stickers are live.",
            "format": "int32"
          },
          "retired": {
            "type": "boolean",
            "description": "True when the vehicle has been retired from the account."
          }
        },
        "description": "A vehicle on the business's account."
      },
      "WhenScannedResponse": {
        "required": [
          "day",
          "timeOfDay",
          "count"
        ],
        "type": "object",
        "properties": {
          "day": {
            "type": "string",
            "description": "Monday … Sunday."
          },
          "timeOfDay": {
            "type": "string",
            "description": "Night (00–06), Morning (06–12), Afternoon (12–18) or Evening (18–24)."
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Scans.",
            "format": "int32"
          }
        },
        "description": "Scans on one day of the week in one part of the day, in UK time."
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "description": "Your API key, starting syv_.",
        "scheme": "bearer"
      }
    }
  },
  "security": [
    {
      "ApiKey": [ ]
    }
  ],
  "tags": [
    {
      "name": "Scans"
    },
    {
      "name": "Stickers"
    },
    {
      "name": "Vehicles"
    }
  ]
}