{
  "openapi": "3.1.0",
  "info": {
    "title": "Passport Guestbook API",
    "version": "0.1.0",
    "description": "Turn a travel history into a world map. Agent instructions: https://passportguestbook.com/llms.txt"
  },
  "servers": [
    {
      "url": "https://passportguestbook.com"
    }
  ],
  "paths": {
    "/api/drafts": {
      "post": {
        "summary": "Prepare a list for the user to review and publish at the returned review_url (with map_key: adds to their existing map)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "trips"
                ],
                "properties": {
                  "display_name": {
                    "type": "string",
                    "description": "Suggested public handle; the user can change it."
                  },
                  "trips": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "country"
                      ],
                      "properties": {
                        "country": {
                          "type": "string",
                          "example": "JP",
                          "description": "ISO 3166-1 alpha-2 or English name, plus XK for Kosovo."
                        },
                        "year": {
                          "type": "string",
                          "example": "2019",
                          "description": "The year they went. Omit if unknown. Years only."
                        },
                        "lived": {
                          "type": "boolean",
                          "description": "True if the traveler lived there."
                        }
                      }
                    }
                  },
                  "wishlist": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "citizenships": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Countries the user is a citizen of (names or codes). Private, anonymous stats only."
                  },
                  "map_key": {
                    "type": "string",
                    "description": "Secret Map Key (PGB-XXXX-XXXX-XXXX-XXXX) returned when the map was created. Not a real passport number."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this address, try again in an hour"
          }
        }
      }
    },
    "/api/trips": {
      "post": {
        "summary": "Used by the /new page when the user presses Make My Map! Agents: use /api/drafts",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "display_name": {
                    "type": "string",
                    "description": "Public handle, required for a new map."
                  },
                  "trips": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "country"
                      ],
                      "properties": {
                        "country": {
                          "type": "string",
                          "example": "JP",
                          "description": "ISO 3166-1 alpha-2 or English name, plus XK for Kosovo."
                        },
                        "year": {
                          "type": "string",
                          "example": "2019",
                          "description": "The year they went. Omit if unknown. Years only."
                        },
                        "lived": {
                          "type": "boolean",
                          "description": "True if the traveler lived there."
                        }
                      }
                    }
                  },
                  "wishlist": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "citizenships": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Countries the user is a citizen of (names or codes). Private, anonymous stats only."
                  },
                  "listed": {
                    "type": "boolean"
                  },
                  "date_precision": {
                    "type": "string",
                    "enum": [
                      "year",
                      "none"
                    ]
                  },
                  "map_key": {
                    "type": "string",
                    "description": "Secret Map Key (PGB-XXXX-XXXX-XXXX-XXXX) returned when the map was created. Not a real passport number."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this address, try again in an hour"
          }
        }
      }
    },
    "/api/my-map": {
      "post": {
        "summary": "Read your own map, with every trip and setting",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "map_key"
                ],
                "properties": {
                  "map_key": {
                    "type": "string",
                    "description": "Secret Map Key (PGB-XXXX-XXXX-XXXX-XXXX) returned when the map was created. Not a real passport number."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this address, try again in an hour"
          }
        }
      }
    },
    "/api/trips/remove": {
      "post": {
        "summary": "Remove visits (country + year, or every visit to a country) or wishlist entries",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "map_key"
                ],
                "properties": {
                  "map_key": {
                    "type": "string",
                    "description": "Secret Map Key (PGB-XXXX-XXXX-XXXX-XXXX) returned when the map was created. Not a real passport number."
                  },
                  "trips": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "country"
                      ],
                      "properties": {
                        "country": {
                          "type": "string"
                        },
                        "year": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "wishlist": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this address, try again in an hour"
          }
        }
      }
    },
    "/api/note": {
      "post": {
        "summary": "Put your own GO!/SKIP verdict and/or a short note on a country on your map (neither clears it)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "map_key",
                  "country"
                ],
                "properties": {
                  "map_key": {
                    "type": "string",
                    "description": "Secret Map Key (PGB-XXXX-XXXX-XXXX-XXXX) returned when the map was created. Not a real passport number."
                  },
                  "country": {
                    "type": "string"
                  },
                  "verdict": {
                    "type": "string",
                    "enum": [
                      "go",
                      "skip"
                    ]
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 280
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this address, try again in an hour"
          }
        }
      }
    },
    "/api/guestbook/delete": {
      "post": {
        "summary": "Delete an entry from your own map's guestbook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "map_key",
                  "id"
                ],
                "properties": {
                  "map_key": {
                    "type": "string",
                    "description": "Secret Map Key (PGB-XXXX-XXXX-XXXX-XXXX) returned when the map was created. Not a real passport number."
                  },
                  "id": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this address, try again in an hour"
          }
        }
      }
    },
    "/api/delete": {
      "post": {
        "summary": "Permanently delete your map",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "map_key",
                  "confirm"
                ],
                "properties": {
                  "map_key": {
                    "type": "string",
                    "description": "Secret Map Key (PGB-XXXX-XXXX-XXXX-XXXX) returned when the map was created. Not a real passport number."
                  },
                  "confirm": {
                    "type": "string",
                    "enum": [
                      "DELETE"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this address, try again in an hour"
          }
        }
      }
    },
    "/api/map/{slug}": {
      "get": {
        "summary": "Public view of a map",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "No such map"
          }
        }
      }
    },
    "/api/handles": {
      "get": {
        "summary": "Suggest travel handles from a first name",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}