{
  "openapi": "3.1.0",
  "info": {
    "title": "travelball tournament API",
    "version": "v1",
    "description": "Send and change your organization's tournaments on travelball from your own system. Each one shows on the travelball app with \"Posted by\" your organization's name. The human documents are at https://travelball.gg/docs/tournaments.",
    "contact": {
      "email": "hello@travelball.gg"
    }
  },
  "externalDocs": {
    "description": "Post tournaments",
    "url": "https://travelball.gg/docs/tournaments"
  },
  "servers": [
    {
      "url": "https://api.travelball.gg/tournaments/v1"
    }
  ],
  "security": [
    {
      "tournamentKey": []
    }
  ],
  "paths": {
    "/tournaments": {
      "get": {
        "operationId": "listTournaments",
        "summary": "List your tournaments that have not ended, soonest first.",
        "responses": {
          "200": {
            "description": "Your open tournaments.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TournamentList"
                },
                "example": {
                  "tournaments": [
                    {
                      "id": "spring-classic-2027",
                      "travelballId": "k17bq0x9m3d2tz8w6c4n5r1y7s2a3f4h",
                      "status": "listed",
                      "postedBy": "Lone Star Fastpitch Events",
                      "name": "Lone Star Spring Classic",
                      "sport": "fastpitch",
                      "firstDay": "2027-03-06",
                      "lastDay": "2027-03-07",
                      "city": "Round Rock",
                      "state": "TX",
                      "divisions": [
                        {
                          "ageGroup": "10U",
                          "name": "AA",
                          "feeDollars": null,
                          "capacity": null,
                          "teams": []
                        },
                        {
                          "ageGroup": "10U",
                          "name": "Open",
                          "feeDollars": 595,
                          "capacity": 24,
                          "teams": [
                            {
                              "name": "Round Rock Rattlers 10U",
                              "confirmed": true
                            },
                            {
                              "name": "Hutto Heat",
                              "confirmed": false
                            }
                          ]
                        },
                        {
                          "ageGroup": "12U",
                          "name": "",
                          "feeDollars": null,
                          "capacity": null,
                          "teams": []
                        }
                      ],
                      "ballparks": [
                        {
                          "name": "Old Settlers Park",
                          "city": "Round Rock",
                          "state": "TX",
                          "lat": 30.5233,
                          "lng": -97.6456
                        }
                      ],
                      "feeDollars": 550,
                      "gamesGuaranteed": 4,
                      "contactName": "Tournament desk",
                      "contactEmail": "desk@example.com",
                      "contactPhone": "(512) 555-0142",
                      "website": "https://example.com/events/spring-classic",
                      "note": "Pool play Saturday, bracket Sunday.",
                      "addedAt": "2026-11-27T21:04:11.000Z",
                      "updatedAt": "2026-11-27T21:04:11.000Z"
                    }
                  ],
                  "version": "v1",
                  "generatedAt": 1795813451000
                }
              }
            }
          },
          "400": {
            "description": "`key-in-url`: The key was in the address. Send it in the header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "401": {
            "description": "`not-authenticated`: No key, or a key we do not know.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "403": {
            "description": "`access-stopped`: We stopped this organization's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "`rate-limited`: Too many requests this minute. Wait and send again.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "500": {
            "description": "`internal`: Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "sendTournaments",
        "summary": "Add or change up to 100 tournaments at once.",
        "description": "Each tournament is answered alone. One that fails a check is refused with its code and one sentence; the others are saved. The same id twice in one send is refused the second time.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TournamentSend"
              },
              "example": {
                "tournaments": [
                  {
                    "id": "spring-classic-2027",
                    "name": "Lone Star Spring Classic",
                    "sport": "fastpitch",
                    "firstDay": "2027-03-06",
                    "lastDay": "2027-03-07",
                    "city": "Round Rock",
                    "state": "TX",
                    "divisions": [
                      {
                        "ageGroup": "10U",
                        "name": "Open",
                        "feeDollars": 595
                      },
                      {
                        "ageGroup": "10U",
                        "name": "AA"
                      },
                      {
                        "ageGroup": "12U"
                      }
                    ],
                    "ballparks": [
                      {
                        "name": "Old Settlers Park",
                        "city": "Round Rock",
                        "state": "TX",
                        "lat": 30.5233,
                        "lng": -97.6456
                      }
                    ],
                    "feeDollars": 550,
                    "gamesGuaranteed": 4,
                    "contactName": "Tournament desk",
                    "contactEmail": "desk@example.com",
                    "contactPhone": "(512) 555-0142",
                    "website": "https://example.com/events/spring-classic",
                    "note": "Pool play Saturday, bracket Sunday."
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One line for each tournament, in the order sent.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendResults"
                },
                "example": {
                  "results": [
                    {
                      "id": "spring-classic-2027",
                      "result": "unchanged"
                    },
                    {
                      "id": "summer-slam-2027",
                      "result": "refused",
                      "code": "bad-tournament",
                      "message": "Send the city and its two-letter state."
                    }
                  ],
                  "version": "v1",
                  "generatedAt": 1795813540000
                }
              }
            }
          },
          "400": {
            "description": "`key-in-url`: The key was in the address. Send it in the header. `bad-request`: The body is not JSON, or is too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "401": {
            "description": "`not-authenticated`: No key, or a key we do not know.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "403": {
            "description": "`access-stopped`: We stopped this organization's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "`rate-limited`: Too many requests this minute. Wait and send again.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "500": {
            "description": "`internal`: Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          }
        }
      }
    },
    "/tournaments/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Your own id for the tournament.",
          "schema": {
            "$ref": "#/components/schemas/TournamentId"
          },
          "example": "spring-classic-2027"
        }
      ],
      "get": {
        "operationId": "getTournament",
        "summary": "Read one of your tournaments, with each division's capacity and teams.",
        "responses": {
          "200": {
            "description": "The tournament.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TournamentOne"
                },
                "example": {
                  "tournament": {
                    "id": "spring-classic-2027",
                    "travelballId": "k17bq0x9m3d2tz8w6c4n5r1y7s2a3f4h",
                    "status": "listed",
                    "postedBy": "Lone Star Fastpitch Events",
                    "name": "Lone Star Spring Classic",
                    "sport": "fastpitch",
                    "firstDay": "2027-03-06",
                    "lastDay": "2027-03-07",
                    "city": "Round Rock",
                    "state": "TX",
                    "divisions": [
                      {
                        "ageGroup": "10U",
                        "name": "AA",
                        "feeDollars": null,
                        "capacity": null,
                        "teams": []
                      },
                      {
                        "ageGroup": "10U",
                        "name": "Open",
                        "feeDollars": 595,
                        "capacity": 24,
                        "teams": [
                          {
                            "name": "Round Rock Rattlers 10U",
                            "confirmed": true
                          },
                          {
                            "name": "Hutto Heat",
                            "confirmed": false
                          }
                        ]
                      },
                      {
                        "ageGroup": "12U",
                        "name": "",
                        "feeDollars": null,
                        "capacity": null,
                        "teams": []
                      }
                    ],
                    "ballparks": [
                      {
                        "name": "Old Settlers Park",
                        "city": "Round Rock",
                        "state": "TX",
                        "lat": 30.5233,
                        "lng": -97.6456
                      }
                    ],
                    "feeDollars": 550,
                    "gamesGuaranteed": 4,
                    "contactName": "Tournament desk",
                    "contactEmail": "desk@example.com",
                    "contactPhone": "(512) 555-0142",
                    "website": "https://example.com/events/spring-classic",
                    "note": "Pool play Saturday, bracket Sunday.",
                    "addedAt": "2026-11-27T21:04:11.000Z",
                    "updatedAt": "2026-11-27T21:04:11.000Z"
                  },
                  "version": "v1",
                  "generatedAt": 1795813451000
                }
              }
            }
          },
          "400": {
            "description": "`key-in-url`: The key was in the address. Send it in the header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "401": {
            "description": "`not-authenticated`: No key, or a key we do not know.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "403": {
            "description": "`access-stopped`: We stopped this organization's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "404": {
            "description": "`not-found`: None of your tournaments has that id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "`rate-limited`: Too many requests this minute. Wait and send again.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "500": {
            "description": "`internal`: Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putTournament",
        "summary": "Add the tournament, or change it when that id is already yours.",
        "description": "An id in the body must be the id in the address.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TournamentInput"
              },
              "example": {
                "id": "spring-classic-2027",
                "name": "Lone Star Spring Classic",
                "sport": "fastpitch",
                "firstDay": "2027-03-06",
                "lastDay": "2027-03-07",
                "city": "Round Rock",
                "state": "TX",
                "divisions": [
                  {
                    "ageGroup": "10U",
                    "name": "Open",
                    "feeDollars": 595
                  },
                  {
                    "ageGroup": "10U",
                    "name": "AA"
                  },
                  {
                    "ageGroup": "12U"
                  }
                ],
                "ballparks": [
                  {
                    "name": "Old Settlers Park",
                    "city": "Round Rock",
                    "state": "TX",
                    "lat": 30.5233,
                    "lng": -97.6456
                  }
                ],
                "feeDollars": 550,
                "gamesGuaranteed": 4,
                "contactName": "Tournament desk",
                "contactEmail": "desk@example.com",
                "contactPhone": "(512) 555-0142",
                "website": "https://example.com/events/spring-classic",
                "note": "Pool play Saturday, bracket Sunday."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed, or nothing changed.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PutResult"
                }
              }
            }
          },
          "201": {
            "description": "Added.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PutResult"
                },
                "example": {
                  "result": "added",
                  "tournament": {
                    "id": "spring-classic-2027",
                    "travelballId": "k17bq0x9m3d2tz8w6c4n5r1y7s2a3f4h",
                    "status": "listed",
                    "postedBy": "Lone Star Fastpitch Events",
                    "name": "Lone Star Spring Classic",
                    "sport": "fastpitch",
                    "firstDay": "2027-03-06",
                    "lastDay": "2027-03-07",
                    "city": "Round Rock",
                    "state": "TX",
                    "divisions": [
                      {
                        "ageGroup": "10U",
                        "name": "AA",
                        "feeDollars": null,
                        "capacity": null,
                        "teams": []
                      },
                      {
                        "ageGroup": "10U",
                        "name": "Open",
                        "feeDollars": 595,
                        "capacity": 24,
                        "teams": [
                          {
                            "name": "Round Rock Rattlers 10U",
                            "confirmed": true
                          },
                          {
                            "name": "Hutto Heat",
                            "confirmed": false
                          }
                        ]
                      },
                      {
                        "ageGroup": "12U",
                        "name": "",
                        "feeDollars": null,
                        "capacity": null,
                        "teams": []
                      }
                    ],
                    "ballparks": [
                      {
                        "name": "Old Settlers Park",
                        "city": "Round Rock",
                        "state": "TX",
                        "lat": 30.5233,
                        "lng": -97.6456
                      }
                    ],
                    "feeDollars": 550,
                    "gamesGuaranteed": 4,
                    "contactName": "Tournament desk",
                    "contactEmail": "desk@example.com",
                    "contactPhone": "(512) 555-0142",
                    "website": "https://example.com/events/spring-classic",
                    "note": "Pool play Saturday, bracket Sunday.",
                    "addedAt": "2026-11-27T21:04:11.000Z",
                    "updatedAt": "2026-11-27T21:04:11.000Z"
                  },
                  "version": "v1",
                  "generatedAt": 1795813451000
                }
              }
            }
          },
          "400": {
            "description": "`key-in-url`: The key was in the address. Send it in the header. `bad-request`: The body is not JSON, or is too large. `bad-tournament`: A tournament or a division failed a check. The message says which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "401": {
            "description": "`not-authenticated`: No key, or a key we do not know.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "403": {
            "description": "`access-stopped`: We stopped this organization's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "409": {
            "description": "`too-many-tournaments`: Your open tournaments are at the limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "`rate-limited`: Too many requests this minute. Wait and send again.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "500": {
            "description": "`internal`: Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "503": {
            "description": "`map-down`: We could not look up the city just now. Send again later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTournament",
        "summary": "Take the tournament off for everybody, with its team lists.",
        "responses": {
          "200": {
            "description": "Deleted.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "example": {
                  "id": "spring-classic-2027",
                  "result": "deleted",
                  "version": "v1",
                  "generatedAt": 1795813635000
                }
              }
            }
          },
          "400": {
            "description": "`key-in-url`: The key was in the address. Send it in the header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "401": {
            "description": "`not-authenticated`: No key, or a key we do not know.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "403": {
            "description": "`access-stopped`: We stopped this organization's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "404": {
            "description": "`not-found`: None of your tournaments has that id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "`rate-limited`: Too many requests this minute. Wait and send again.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "500": {
            "description": "`internal`: Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          }
        }
      }
    },
    "/tournaments/{id}/teams": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Your own id for the tournament.",
          "schema": {
            "$ref": "#/components/schemas/TournamentId"
          },
          "example": "spring-classic-2027"
        }
      ],
      "put": {
        "operationId": "putDivisionTeams",
        "summary": "Set who is coming in one division, and how many teams it allows.",
        "description": "Replaces that division's whole team list. ageGroup and name pick the division; a division the tournament does not have is refused with bad-tournament. Team names are plain words from you and are never linked to a team in the app.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DivisionTeamsInput"
              },
              "example": {
                "ageGroup": "10U",
                "name": "Open",
                "capacity": 24,
                "teams": [
                  {
                    "name": "Round Rock Rattlers 10U",
                    "confirmed": true
                  },
                  {
                    "name": "Hutto Heat",
                    "confirmed": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The division's new count.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamsResult"
                },
                "example": {
                  "id": "spring-classic-2027",
                  "result": "changed",
                  "division": {
                    "ageGroup": "10U",
                    "name": "Open",
                    "capacity": 24,
                    "registered": 2,
                    "confirmed": 1
                  },
                  "version": "v1",
                  "generatedAt": 1795813562000
                }
              }
            }
          },
          "400": {
            "description": "`key-in-url`: The key was in the address. Send it in the header. `bad-request`: The body is not JSON, or is too large. `bad-tournament`: A tournament or a division failed a check. The message says which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "401": {
            "description": "`not-authenticated`: No key, or a key we do not know.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "403": {
            "description": "`access-stopped`: We stopped this organization's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "404": {
            "description": "`not-found`: None of your tournaments has that id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "`rate-limited`: Too many requests this minute. Wait and send again.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "500": {
            "description": "`internal`: Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "tournamentKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your tournament key: `tb_org_` and 32 letters and digits, in `Authorization: Bearer tb_org_…`. A key in the address is refused. A Data API key does not open this door."
      }
    },
    "headers": {
      "X-RateLimit-Limit": {
        "description": "Requests each minute for your key.",
        "schema": {
          "type": "integer",
          "example": 60
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Requests left this minute.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "description": "When the minute's count is full again, in seconds since 1 January 1970.",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before you send again.",
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "schemas": {
      "TournamentId": {
        "type": "string",
        "pattern": "^[A-Za-z0-9._:-]{1,100}$",
        "minLength": 1,
        "maxLength": 100,
        "description": "Your own id for a tournament: 1 to 100 letters, digits, dots, dashes, underlines or colons."
      },
      "AgeGroup": {
        "type": "string",
        "enum": [
          "6U",
          "7U",
          "8U",
          "9U",
          "10U",
          "11U",
          "12U",
          "13U",
          "14U",
          "15U",
          "16U",
          "17U",
          "18U"
        ]
      },
      "Division": {
        "type": "object",
        "required": [
          "ageGroup"
        ],
        "properties": {
          "ageGroup": {
            "$ref": "#/components/schemas/AgeGroup"
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 30,
            "description": "Leave it out for an age group's only division."
          },
          "feeDollars": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 20000,
            "description": "This division's fee, when it differs from the tournament's."
          }
        }
      },
      "Ballpark": {
        "type": "object",
        "required": [
          "name",
          "city",
          "state",
          "lat",
          "lng"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "city": {
            "type": "string",
            "minLength": 1
          },
          "state": {
            "type": "string",
            "pattern": "^[A-Za-z]{2}$"
          },
          "lat": {
            "type": "number"
          },
          "lng": {
            "type": "number"
          }
        }
      },
      "TournamentInput": {
        "type": "object",
        "required": [
          "name",
          "sport",
          "firstDay",
          "lastDay",
          "city",
          "state",
          "divisions"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/TournamentId"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "The tournament's name, up to 80 characters after spaces are trimmed."
          },
          "sport": {
            "type": "string",
            "enum": [
              "baseball",
              "fastpitch"
            ]
          },
          "firstDay": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD. Not in the past, and within 18 months. A tournament already under way keeps its first day on a change."
          },
          "lastDay": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD. On or after the first day, and at most 14 days after it."
          },
          "city": {
            "type": "string",
            "minLength": 1,
            "description": "The city as words. The server finds it on the map in that state; a city the map does not know there is refused."
          },
          "state": {
            "type": "string",
            "pattern": "^[A-Za-z]{2}$",
            "description": "The two-letter state."
          },
          "divisions": {
            "type": "array",
            "minItems": 1,
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/Division"
            },
            "description": "The same age group and name twice is refused."
          },
          "ballparks": {
            "type": [
              "array",
              "null"
            ],
            "maxItems": 5,
            "items": {
              "$ref": "#/components/schemas/Ballpark"
            }
          },
          "feeDollars": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 20000,
            "description": "The team entry fee, in whole dollars."
          },
          "gamesGuaranteed": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 20
          },
          "contactName": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 60,
            "description": "Needs a contactPhone or a contactEmail with it."
          },
          "contactEmail": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "maxLength": 120
          },
          "contactPhone": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9+\\-(). ]{7,25}$"
          },
          "website": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "pattern": "^[Hh][Tt][Tt][Pp][Ss]://",
            "maxLength": 200,
            "description": "Starts with https://. Families press it to sign up."
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500,
            "description": "Never a child's name."
          }
        }
      },
      "TournamentSend": {
        "type": "object",
        "required": [
          "tournaments"
        ],
        "properties": {
          "tournaments": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/TournamentInput"
                },
                {
                  "required": [
                    "id"
                  ]
                }
              ]
            }
          }
        }
      },
      "DivisionOut": {
        "type": "object",
        "required": [
          "ageGroup",
          "name",
          "feeDollars",
          "capacity",
          "teams"
        ],
        "properties": {
          "ageGroup": {
            "$ref": "#/components/schemas/AgeGroup"
          },
          "name": {
            "type": "string",
            "description": "\"\" for an age group's only division."
          },
          "feeDollars": {
            "type": [
              "integer",
              "null"
            ]
          },
          "capacity": {
            "type": [
              "integer",
              "null"
            ],
            "description": "How many teams it allows; null for no limit or not sent."
          },
          "teams": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DivisionTeam"
            }
          }
        }
      },
      "Tournament": {
        "type": "object",
        "required": [
          "id",
          "travelballId",
          "status",
          "postedBy",
          "name",
          "sport",
          "firstDay",
          "lastDay",
          "city",
          "state",
          "divisions",
          "ballparks",
          "feeDollars",
          "gamesGuaranteed",
          "contactName",
          "contactEmail",
          "contactPhone",
          "website",
          "note",
          "addedAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/TournamentId"
          },
          "travelballId": {
            "type": "string",
            "description": "Our id for the tournament."
          },
          "status": {
            "type": "string",
            "enum": [
              "listed",
              "hidden"
            ],
            "description": "\"hidden\" when we took it off the lists."
          },
          "postedBy": {
            "type": "string",
            "description": "Your organization's name, as families see it."
          },
          "name": {
            "type": "string"
          },
          "sport": {
            "type": "string",
            "enum": [
              "baseball",
              "fastpitch"
            ]
          },
          "firstDay": {
            "type": "string",
            "format": "date"
          },
          "lastDay": {
            "type": "string",
            "format": "date"
          },
          "city": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "divisions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DivisionOut"
            }
          },
          "ballparks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ballpark"
            }
          },
          "feeDollars": {
            "type": [
              "integer",
              "null"
            ]
          },
          "gamesGuaranteed": {
            "type": [
              "integer",
              "null"
            ]
          },
          "contactName": {
            "type": [
              "string",
              "null"
            ]
          },
          "contactEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "contactPhone": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "addedAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TournamentList": {
        "type": "object",
        "required": [
          "tournaments",
          "version",
          "generatedAt"
        ],
        "properties": {
          "tournaments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Tournament"
            }
          },
          "version": {
            "type": "string",
            "const": "v1"
          },
          "generatedAt": {
            "type": "integer",
            "description": "When this answer was built, in milliseconds since 1 January 1970.",
            "example": 1795813451000
          }
        }
      },
      "TournamentOne": {
        "type": "object",
        "required": [
          "tournament",
          "version",
          "generatedAt"
        ],
        "properties": {
          "tournament": {
            "$ref": "#/components/schemas/Tournament"
          },
          "version": {
            "type": "string",
            "const": "v1"
          },
          "generatedAt": {
            "type": "integer",
            "description": "When this answer was built, in milliseconds since 1 January 1970.",
            "example": 1795813451000
          }
        }
      },
      "PutResult": {
        "type": "object",
        "required": [
          "result",
          "tournament",
          "version",
          "generatedAt"
        ],
        "properties": {
          "result": {
            "type": "string",
            "enum": [
              "added",
              "changed",
              "unchanged"
            ]
          },
          "tournament": {
            "$ref": "#/components/schemas/Tournament"
          },
          "version": {
            "type": "string",
            "const": "v1"
          },
          "generatedAt": {
            "type": "integer",
            "description": "When this answer was built, in milliseconds since 1 January 1970.",
            "example": 1795813451000
          }
        }
      },
      "SendResult": {
        "type": "object",
        "required": [
          "id",
          "result"
        ],
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ],
            "description": "null when a refused tournament carried no id we could read."
          },
          "result": {
            "type": "string",
            "enum": [
              "added",
              "changed",
              "unchanged",
              "refused"
            ]
          },
          "code": {
            "type": "string",
            "enum": [
              "bad-tournament",
              "too-many-tournaments",
              "map-down"
            ],
            "description": "Only on a refused line."
          },
          "message": {
            "type": "string",
            "description": "Only on a refused line: one sentence you can show a person."
          }
        }
      },
      "SendResults": {
        "type": "object",
        "required": [
          "results",
          "version",
          "generatedAt"
        ],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SendResult"
            }
          },
          "version": {
            "type": "string",
            "const": "v1"
          },
          "generatedAt": {
            "type": "integer",
            "description": "When this answer was built, in milliseconds since 1 January 1970.",
            "example": 1795813451000
          }
        }
      },
      "Deleted": {
        "type": "object",
        "required": [
          "id",
          "result",
          "version",
          "generatedAt"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/TournamentId"
          },
          "result": {
            "type": "string",
            "const": "deleted"
          },
          "version": {
            "type": "string",
            "const": "v1"
          },
          "generatedAt": {
            "type": "integer",
            "description": "When this answer was built, in milliseconds since 1 January 1970.",
            "example": 1795813451000
          }
        }
      },
      "DivisionTeam": {
        "type": "object",
        "required": [
          "name",
          "confirmed"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "confirmed": {
            "type": "boolean"
          }
        }
      },
      "DivisionTeamsInput": {
        "type": "object",
        "required": [
          "ageGroup",
          "teams"
        ],
        "properties": {
          "ageGroup": {
            "$ref": "#/components/schemas/AgeGroup"
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Leave it out for an age group's only division."
          },
          "capacity": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 128,
            "description": "How many teams the division allows; null for no limit."
          },
          "teams": {
            "type": "array",
            "maxItems": 128,
            "items": {
              "$ref": "#/components/schemas/DivisionTeam"
            },
            "description": "The whole list. The same name twice is refused; an empty list clears it."
          }
        }
      },
      "TeamsResult": {
        "type": "object",
        "required": [
          "id",
          "result",
          "division",
          "version",
          "generatedAt"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/TournamentId"
          },
          "result": {
            "type": "string",
            "const": "changed"
          },
          "division": {
            "type": "object",
            "required": [
              "ageGroup",
              "name",
              "capacity",
              "registered",
              "confirmed"
            ],
            "properties": {
              "ageGroup": {
                "$ref": "#/components/schemas/AgeGroup"
              },
              "name": {
                "type": "string"
              },
              "capacity": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "registered": {
                "type": "integer",
                "minimum": 0
              },
              "confirmed": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "version": {
            "type": "string",
            "const": "v1"
          },
          "generatedAt": {
            "type": "integer",
            "description": "When this answer was built, in milliseconds since 1 January 1970.",
            "example": 1795813451000
          }
        }
      },
      "Refusal": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "not-authenticated",
                  "key-in-url",
                  "access-stopped",
                  "not-found",
                  "bad-request",
                  "bad-tournament",
                  "too-many-tournaments",
                  "rate-limited",
                  "map-down",
                  "internal"
                ]
              },
              "message": {
                "type": "string",
                "description": "One sentence you can show a person."
              }
            }
          }
        },
        "example": {
          "error": {
            "code": "not-found",
            "message": "Nothing with that id."
          }
        }
      }
    }
  }
}
