{
  "openapi": "3.1.0",
  "info": {
    "title": "PackWise API",
    "version": "1",
    "description": "A packing check grounded in what is actually in the bag. Authenticate with an API key (Authorization: Bearer <key> or X-API-Key). Only starting a bag check is billed, after it succeeds; the rules plan, trips and history are free. PackWise never asserts airline, security or visa rules and never states weather without fresh licensed data: weather is a forecast, typical conditions (not a forecast) or unavailable, and says which."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/api/v1/meta": {
      "get": {
        "summary": "Vocabularies",
        "operationId": "getMeta",
        "tags": [
          "Reference"
        ],
        "description": "Categories, bags, activities, transports, bag plans and the item catalogue the checks are drawn from.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meta"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/plan": {
      "post": {
        "summary": "Plan a trip (free)",
        "operationId": "planTrip",
        "tags": [
          "Trip"
        ],
        "description": "The rules checklist for a trip: weather from licensed sources, activities, duration, transport. No photo, no AI, no charge. Every entry's status is `unknown`: nothing has been observed.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Invalid trip"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "trip"
                ],
                "properties": {
                  "trip": {
                    "$ref": "#/components/schemas/Trip"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analyses": {
      "post": {
        "summary": "Check a bag (billed on success)",
        "operationId": "startAnalysis",
        "tags": [
          "Bag check"
        ],
        "description": "Queues one bag check and returns 202 with a job to poll. It is billed only when delivered; unusable photos, no visible bag and any failure bill nothing. Send JSON with `trip` and one to three base64 `photos`, or multipart with `photo` files, a `trip` JSON field and `language`.",
        "responses": {
          "202": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "Empty wallet"
          },
          "403": {
            "description": "No active subscription"
          },
          "415": {
            "description": "Not a JPEG or PNG"
          },
          "422": {
            "description": "Invalid trip, language or unreadable photos"
          },
          "429": {
            "description": "Hourly quota reached"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartRequest"
              }
            }
          }
        }
      },
      "get": {
        "summary": "List analyses",
        "operationId": "listAnalyses",
        "tags": [
          "Bag check"
        ],
        "description": "Newest first.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AnalysisSummary"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ]
      }
    },
    "/api/v1/analyses/{id}": {
      "get": {
        "summary": "Get one analysis",
        "operationId": "getAnalysis",
        "tags": [
          "Bag check"
        ],
        "description": "The delivered report with every check.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Analysis"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Not found or no longer retained"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "delete": {
        "summary": "Delete an analysis",
        "operationId": "deleteAnalysis",
        "tags": [
          "Bag check"
        ],
        "description": "Removes it and its history row.",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Not found"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/jobs/{id}": {
      "get": {
        "summary": "Poll a job",
        "operationId": "getJob",
        "tags": [
          "Bag check"
        ],
        "description": "`queued`, `running`, `succeeded` or `failed`; `analysis_id` is set on success.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Not found"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid API key",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "Trip": {
        "type": "object",
        "required": [
          "name",
          "destination",
          "lat",
          "lon",
          "start",
          "end",
          "transport",
          "bag_plan",
          "adults"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "destination": {
            "type": "string",
            "description": "Label, e.g. Lisbon, Portugal"
          },
          "lat": {
            "type": "number"
          },
          "lon": {
            "type": "number"
          },
          "country": {
            "type": "string"
          },
          "start": {
            "type": "string",
            "format": "date"
          },
          "end": {
            "type": "string",
            "format": "date"
          },
          "transport": {
            "type": "string",
            "enum": [
              "flight",
              "train",
              "car",
              "bus",
              "ship"
            ]
          },
          "bag_plan": {
            "type": "string",
            "enum": [
              "carry_on",
              "checked",
              "backpack"
            ]
          },
          "activities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "adults": {
            "type": "integer"
          },
          "children": {
            "type": "integer"
          },
          "laundry": {
            "type": "boolean"
          },
          "light": {
            "type": "boolean"
          },
          "weight_limit_kg": {
            "type": "number",
            "description": "Your own stated allowance; PackWise never looks up airline rules."
          },
          "confirmed_restrictions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "type": "string"
          }
        }
      },
      "Entry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "bag": {
            "type": "string",
            "enum": [
              "carry_on",
              "checked",
              "personal"
            ]
          },
          "needed": {
            "type": "integer"
          },
          "seen": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "packed",
              "partial",
              "missing",
              "extra",
              "optional",
              "unknown"
            ]
          },
          "required": {
            "type": "boolean"
          },
          "evidence": {
            "type": "string",
            "enum": [
              "observed",
              "possible",
              "confirmed",
              "not_verifiable"
            ]
          },
          "confidence": {
            "type": "string"
          },
          "weight_g": {
            "type": "integer"
          },
          "reasons": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rule": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "source": {
            "type": "string"
          },
          "checked": {
            "type": "boolean"
          }
        }
      },
      "Report": {
        "type": "object",
        "description": "The reconciled checklist: every quantity, status, weight and readiness is computed and independently re-verified (checks).",
        "properties": {
          "trip": {
            "$ref": "#/components/schemas/Trip"
          },
          "weather": {
            "type": "object",
            "description": "kind is forecast, typical (climate normals, not a forecast) or unavailable; attribution is required wherever shown."
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Entry"
            }
          },
          "unverified": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "photos": {
            "type": "integer"
          },
          "inventory": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "other_seen": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "counts": {
            "type": "object"
          },
          "readiness": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "weight": {
            "type": "object",
            "description": "An estimate with a stated band, never a weighing."
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "ok": {
                  "type": "boolean"
                },
                "detail": {
                  "type": "string"
                }
              }
            }
          },
          "checks_passed": {
            "type": "boolean"
          }
        }
      },
      "Meta": {
        "type": "object",
        "properties": {
          "categories": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "bags": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "activities": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "transports": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "bag_plans": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "languages": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "limits": {
            "type": "object"
          },
          "units_per_analysis": {
            "type": "integer"
          },
          "attribution": {
            "type": "object"
          }
        }
      },
      "PlanResult": {
        "type": "object",
        "properties": {
          "report": {
            "$ref": "#/components/schemas/Report"
          },
          "attribution": {
            "type": "object"
          }
        }
      },
      "StartRequest": {
        "type": "object",
        "required": [
          "trip",
          "photos"
        ],
        "properties": {
          "trip": {
            "$ref": "#/components/schemas/Trip"
          },
          "photos": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "items": {
              "type": "string",
              "description": "base64 JPEG/PNG, optionally a data: URL"
            }
          },
          "language": {
            "type": "string",
            "enum": [
              "en",
              "nl",
              "fr",
              "de",
              "es"
            ]
          }
        }
      },
      "Accepted": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "poll": {
            "type": "string"
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "analysis_id": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AnalysisSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "trip_name": {
            "type": "string"
          },
          "destination": {
            "type": "string"
          },
          "days": {
            "type": "integer"
          },
          "readiness": {
            "type": "integer"
          },
          "missing": {
            "type": "integer"
          },
          "extra": {
            "type": "integer"
          },
          "photos": {
            "type": "integer"
          },
          "units": {
            "type": "integer"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "Analysis": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "report": {
            "$ref": "#/components/schemas/Report"
          },
          "summary": {
            "type": "string"
          },
          "summary_by_ai": {
            "type": "boolean"
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "prompt": {
            "type": "string"
          }
        }
      }
    }
  }
}