{
  "openapi": "3.1.0",
  "info": {
    "title": "Parksby integration API",
    "version": "1",
    "description": "Search car parks (for AI agents and apps), publish car parks and live occupancy, handle reservations from your own system, and receive booking webhooks. Guides: https://parksby.io/developers (Markdown: https://parksby.io/developers/<guide>.md).",
    "contact": {
      "email": "contact@parksby.io",
      "url": "https://parksby.io/developers"
    }
  },
  "externalDocs": {
    "url": "https://parksby.io/developers"
  },
  "servers": [
    {
      "url": "https://api.parksby.io"
    }
  ],
  "paths": {
    "/v1/occupancy": {
      "post": {
        "operationId": "publishOccupancy",
        "summary": "Send occupancy readings, or a publisher's sites and readings",
        "description": "Occupancy keys (Spaces → API keys) send readings for their car parks. Publisher keys (from contact@parksby.io) may also send sites in their own ids, FIWARE NGSI v2/LD entities or Orion notifications, or DATEX II XML (Content-Type: application/xml). Limits: 500 sites and 500 readings per request, 2 MB per body; up to 100 readings per batch for occupancy keys.",
        "externalDocs": {
          "url": "https://parksby.io/developers/publish-parking-data#contribute-occupancy-api"
        },
        "security": [
          {
            "parksbyKey": []
          }
        ],
        "servers": [
          {
            "url": "https://api.parksby.io"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "description": "One occupancy reading. Give free_spaces (with a known capacity), a band, or both; a count with no capacity is rejected.",
                    "properties": {
                      "site_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Which car park (keys created in Spaces; listed on the API keys page)."
                      },
                      "external_id": {
                        "type": "string",
                        "description": "Publisher keys: your own id for the car park."
                      },
                      "free_spaces": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "total_spaces": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Capacity; omit if Parksby already has it."
                      },
                      "band": {
                        "type": "string",
                        "enum": [
                          "open",
                          "busy",
                          "nearly_full",
                          "full",
                          "closed"
                        ]
                      },
                      "observed_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Your clock. Each reading is shown as live for one hour."
                      }
                    },
                    "title": "One reading"
                  },
                  {
                    "type": "object",
                    "title": "Batch",
                    "properties": {
                      "readings": {
                        "type": "array",
                        "maxItems": 500,
                        "items": {
                          "type": "object",
                          "description": "One occupancy reading. Give free_spaces (with a known capacity), a band, or both; a count with no capacity is rejected.",
                          "properties": {
                            "site_id": {
                              "type": "string",
                              "format": "uuid",
                              "description": "Which car park (keys created in Spaces; listed on the API keys page)."
                            },
                            "external_id": {
                              "type": "string",
                              "description": "Publisher keys: your own id for the car park."
                            },
                            "free_spaces": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "total_spaces": {
                              "type": "integer",
                              "minimum": 0,
                              "description": "Capacity; omit if Parksby already has it."
                            },
                            "band": {
                              "type": "string",
                              "enum": [
                                "open",
                                "busy",
                                "nearly_full",
                                "full",
                                "closed"
                              ]
                            },
                            "observed_at": {
                              "type": "string",
                              "format": "date-time",
                              "description": "Your clock. Each reading is shown as live for one hour."
                            }
                          }
                        }
                      },
                      "sites": {
                        "type": "array",
                        "maxItems": 500,
                        "items": {
                          "type": "object",
                          "required": [
                            "external_id",
                            "name",
                            "latitude",
                            "longitude"
                          ],
                          "properties": {
                            "external_id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "latitude": {
                              "type": "number"
                            },
                            "longitude": {
                              "type": "number"
                            },
                            "site_type": {
                              "type": "string",
                              "enum": [
                                "garage",
                                "surface_lot",
                                "onstreet_zone"
                              ]
                            },
                            "capacity": {
                              "type": "integer"
                            },
                            "address": {
                              "type": "string"
                            },
                            "operator_label": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              },
              "examples": {
                "reading": {
                  "value": {
                    "site_id": "8f0c…",
                    "free_spaces": 142,
                    "total_spaces": 200,
                    "observed_at": "2026-09-22T09:14:00Z"
                  }
                },
                "publisher": {
                  "value": {
                    "sites": [
                      {
                        "external_id": "P-0042",
                        "name": "Station Garage",
                        "latitude": 50.8466,
                        "longitude": 4.3528,
                        "site_type": "garage",
                        "capacity": 400
                      }
                    ],
                    "readings": [
                      {
                        "external_id": "P-0042",
                        "free_spaces": 120,
                        "total_spaces": 400,
                        "observed_at": "2026-10-08T15:00:00Z"
                      }
                    ]
                  }
                }
              }
            },
            "application/xml": {
              "schema": {
                "type": "string",
                "description": "DATEX II ParkingTablePublication and/or ParkingStatusPublication (v2 or v3)."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Processed. Each reading has its own result: accepted, or error with a reason (for example a count with no capacity). Publisher readings for ids not yet sent as sites come back as unresolved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "const": true
                    },
                    "accepted": {
                      "type": "integer"
                    },
                    "errors": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "site_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "accepted",
                              "error"
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, no readings, too many rows, or a FIWARE / DATEX II document sent with an occupancy key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "const": false
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown or revoked key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "const": false
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The publisher is not active.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "const": false
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Body over 2 MB.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "const": false
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/search": {
      "get": {
        "operationId": "searchCarParks",
        "summary": "Car parks near a point (or one by id), with prices, hours, live availability where known and reservability",
        "externalDocs": {
          "url": "https://parksby.io/developers/search"
        },
        "servers": [
          {
            "url": "https://api.parksby.io"
          }
        ],
        "security": [],
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": -90,
              "maximum": 90
            },
            "description": "Required unless id is given."
          },
          {
            "name": "lng",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            },
            "description": "Required unless id is given."
          },
          {
            "name": "radius_m",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 50,
              "maximum": 5000,
              "default": 1000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 10
            }
          },
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "One car park instead of a search."
          }
        ],
        "responses": {
          "200": {
            "description": "{ results: [...] } for a search, { result } for an id. Show each result's attribution wherever you show the result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "bad_request: lat and lng missing or out of range, or a malformed id."
          },
          "404": {
            "description": "not_found: no public car park with that id."
          },
          "429": {
            "description": "rate_limited: about 60 requests a minute per address."
          }
        }
      }
    },
    "/v1/reservations": {
      "post": {
        "operationId": "reservations",
        "summary": "List a car park's reservations, or accept, decline, cancel, record a no-show or mark one paid",
        "externalDocs": {
          "url": "https://parksby.io/developers/webhooks#webhooks-reservations-api"
        },
        "servers": [
          {
            "url": "https://api.parksby.io"
          }
        ],
        "security": [
          {
            "parksbyHmac": []
          }
        ],
        "parameters": [
          {
            "name": "X-Parksby-Integration-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The car park's connection id (Spaces → Developers → Reservations API)."
          },
          {
            "name": "X-Parksby-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Within ±5 minutes of server time."
          },
          {
            "name": "X-Parksby-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Lowercase hex HMAC-SHA256(signing_secret, raw_body + \".\" + timestamp)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "properties": {
                      "action": {
                        "const": "list"
                      },
                      "from": {
                        "type": "string",
                        "format": "date"
                      },
                      "to": {
                        "type": "string",
                        "format": "date"
                      }
                    },
                    "description": "Next 7 days by default; at most 31."
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "booking_id"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "accept",
                          "decline",
                          "cancel",
                          "no_show",
                          "mark_paid"
                        ]
                      },
                      "booking_id": {
                        "type": "string",
                        "format": "uuid"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The list ({ parking_id, reservations }) or the updated reservation. state is pending, confirmed, lapsed, arrived, no_show, completed or cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "missing_headers, invalid_timestamp, timestamp_skew, invalid_json, invalid_range, invalid_action or invalid_booking_id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "unknown_integration, integration_disabled or invalid_signature.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found: no such reservation at this car park.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed: only POST.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "refused (the reservation cannot change that way) or no_parking.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "bookingEvent": {
      "post": {
        "summary": "A booking event at one of your car parks, sent to your endpoint",
        "description": "Add endpoints in Spaces → Developers → Webhooks. Verify X-Parksby-Signature (hex HMAC-SHA256 of the raw body + '.' + X-Parksby-Timestamp with the endpoint's secret, the same rule as the inbound APIs), drop deliveries older than ~5 minutes by X-Parksby-Timestamp, and deduplicate by event_id. Answer 2xx quickly; failures are retried.",
        "externalDocs": {
          "url": "https://parksby.io/developers/webhooks"
        },
        "parameters": [
          {
            "name": "X-Parksby-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Parksby-Event-ID",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Parksby-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "ISO 8601 UTC; part of the signature."
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "event_id",
                  "event_type",
                  "occurred_at",
                  "data"
                ],
                "properties": {
                  "event_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "event_type": {
                    "type": "string",
                    "enum": [
                      "booking.activated",
                      "payment.confirmed",
                      "booking.checked_in",
                      "booking.checked_out",
                      "booking.extended",
                      "booking.expiring_soon",
                      "booking.overdue",
                      "booking.completed",
                      "booking.cancelled",
                      "booking.requested",
                      "booking.no_show",
                      "booking.marked_paid"
                    ]
                  },
                  "occurred_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "required": [
                      "booking_id",
                      "parking_id"
                    ],
                    "properties": {
                      "booking_id": {
                        "type": "string"
                      },
                      "parking_id": {
                        "type": "string"
                      },
                      "tenant_id": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "parksbyKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "pbk_… key: occupancy keys from Spaces → API keys; publisher keys from contact@parksby.io."
      },
      "parksbyHmac": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Parksby-Signature",
        "description": "HMAC-SHA256 request signing; see the Reservations API guide."
      }
    }
  }
}
