{
  "openapi": "3.1.0",
  "info": {
    "title": "crob.at API",
    "version": "1.0.0",
    "description": "Free, keyless API for Pokemon Showdown team storage, generation, and reference data. Base URL: https://crob.at. Start with https://crob.at/api.md for complete workflows. Public operations need no account. Account-tagged operations are browser session helpers. Team creation stores recognizable exports; success does not prove that a team is complete or legal for battle. Read format_status when available and check against your battle server rules.",
    "termsOfService": "https://crob.at/api#terms",
    "contact": {
      "name": "crob.at API support",
      "url": "https://crob.at/contact",
      "email": "admin@crob.at"
    }
  },
  "externalDocs": {
    "description": "Human-readable API documentation",
    "url": "https://crob.at/api"
  },
  "servers": [
    {
      "url": "https://crob.at",
      "description": "Production"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "Teams",
      "description": "Create and retrieve shareable Pokemon Showdown teams."
    },
    {
      "name": "Generation",
      "description": "Generate and optionally save competitive random teams."
    },
    {
      "name": "Reference",
      "description": "Read sample teams and Pokemon reference data."
    },
    {
      "name": "Account",
      "description": "Optional same-origin helpers that use a crob.at browser session."
    },
    {
      "name": "Feedback",
      "description": "Send product feedback to the crob.at team."
    }
  ],
  "paths": {
    "/api/team/{slug}": {
      "get": {
        "tags": [
          "Teams"
        ],
        "summary": "Retrieve a team",
        "description": "Returns a saved single-team or multi-team paste by its public slug.",
        "operationId": "getTeamBySlug",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The team's public slug.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The saved team.",
            "headers": {
              "Cache-Control": {
                "description": "Public response cache policy.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Team"
                },
                "example": {
                  "slug": "abc123",
                  "name": "Example team",
                  "author": null,
                  "description": null,
                  "public": false,
                  "provenance": null,
                  "format_status": null,
                  "tournament": null,
                  "image": "https://crob.at/og/abc123.png",
                  "source_url": null,
                  "created_at": "2026-10-18 10:00:00",
                  "views": 0,
                  "is_multi": false,
                  "teams": [
                    {
                      "name": "Example team",
                      "format": "gen9ou",
                      "paste": "Garchomp @ Choice Scarf\nAbility: Rough Skin\nEVs: 252 Atk / 4 SpD / 252 Spe\nJolly Nature\n- Earthquake\n- Dragon Claw\n- Stone Edge\n- Iron Head"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/team/{slug}/{teamSlug}": {
      "get": {
        "tags": [
          "Teams"
        ],
        "summary": "Retrieve one team from a multi-team paste",
        "description": "Returns one team from a multi-team paste. Use the child slug from its share URL; do not assume a numeric array index or invent a slug.",
        "operationId": "getTeamInPasteBySlug",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The multi-team paste's public slug.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "teamSlug",
            "in": "path",
            "required": true,
            "description": "The selected team's slug within the paste.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The selected team.",
            "headers": {
              "Cache-Control": {
                "description": "Public response cache policy.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamInPaste"
                },
                "example": {
                  "paste_slug": "abc123",
                  "slug": "example-team",
                  "format": "gen9ou",
                  "name": "Example team",
                  "paste": "Garchomp @ Choice Scarf\nAbility: Rough Skin\nEVs: 252 Atk / 4 SpD / 252 Spe\nJolly Nature\n- Earthquake\n- Dragon Claw\n- Stone Edge\n- Iron Head",
                  "url": "https://crob.at/abc123/example-team",
                  "image": "https://crob.at/og/abc123.png?team=example-team"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/team": {
      "post": {
        "tags": [
          "Teams"
        ],
        "summary": "Create a team",
        "description": "Creates a shareable team from one or more Pokemon Showdown exports. No account or API key is required. Defaults to unlisted. Anyone with the resulting URL can read it. This endpoint is not idempotent: repeating a request can create another team. Do not automatically retry after an uncertain network result.",
        "operationId": "createTeam",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTeamRequest"
              },
              "example": {
                "name": "Example team",
                "public": false,
                "teams": [
                  {
                    "name": "Example team",
                    "format": "gen9ou",
                    "paste": "Garchomp @ Choice Scarf\nAbility: Rough Skin\nEVs: 252 Atk / 4 SpD / 252 Spe\nJolly Nature\n- Earthquake\n- Dragon Claw\n- Stone Edge\n- Iron Head"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The team was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedTeam"
                },
                "example": {
                  "slug": "abc123",
                  "url": "https://crob.at/abc123",
                  "image": "https://crob.at/og/abc123.png",
                  "management_token": "000000000000000000000000000000000000000000000000"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/api/random-team/{format}": {
      "get": {
        "tags": [
          "Generation"
        ],
        "summary": "Generate a random team",
        "description": "Generates a usage-weighted competitive team without saving it. Requires a supported generator format and available data; not every Showdown format has a generator. This is usage-weighted generation, not the Showdown Random Battle format. No team is stored. Check compatibility against your own Showdown version before battle.",
        "operationId": "generateRandomTeam",
        "parameters": [
          {
            "$ref": "#/components/parameters/Format"
          },
          {
            "name": "bias",
            "in": "query",
            "description": "Usage preference.",
            "schema": {
              "type": "string",
              "enum": [
                "staples",
                "balanced",
                "surprise"
              ],
              "default": "balanced"
            }
          },
          {
            "name": "include",
            "in": "query",
            "description": "One Pokemon name to require in the generator pool. Do not send a list. The same Pokemon cannot be included and excluded.",
            "schema": {
              "type": "string",
              "maxLength": 80
            },
            "example": "Garchomp"
          },
          {
            "name": "exclude",
            "in": "query",
            "description": "One Pokemon name to avoid in the generator pool. Do not send a list. The same Pokemon cannot be included and excluded.",
            "schema": {
              "type": "string",
              "maxLength": 80
            },
            "example": "Gholdengo"
          }
        ],
        "responses": {
          "200": {
            "description": "A generated Pokemon Showdown team and its rendered card HTML.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeneratedTeam"
                },
                "example": {
                  "teamText": "Garchomp @ Choice Scarf\nAbility: Rough Skin\nEVs: 252 Atk / 4 SpD / 252 Spe\nJolly Nature\n- Earthquake\n- Dragon Claw\n- Stone Edge\n- Iron Head\n\nCorviknight @ Leftovers\nAbility: Pressure\n- Roost\n- Defog\n- U-turn\n- Brave Bird\n\nRotom-Wash @ Leftovers\nAbility: Levitate\n- Hydro Pump\n- Volt Switch\n- Will-O-Wisp\n- Protect\n\nKingambit @ Black Glasses\nAbility: Supreme Overlord\n- Kowtow Cleave\n- Sucker Punch\n- Iron Head\n- Swords Dance\n\nClefable @ Leftovers\nAbility: Magic Guard\n- Moonblast\n- Moonlight\n- Stealth Rock\n- Thunder Wave\n\nDragapult @ Choice Specs\nAbility: Infiltrator\n- Shadow Ball\n- Draco Meteor\n- Flamethrower\n- U-turn",
                  "statsDate": "2026-10",
                  "cardsHtml": "<div class=\"pokemon-grid\"></div>"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "502": {
            "description": "The upstream usage-data source could not be read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Failed to fetch usage data"
                }
              }
            }
          }
        }
      }
    },
    "/api/random-team/{format}/save": {
      "post": {
        "tags": [
          "Generation"
        ],
        "summary": "Save a generated team",
        "description": "Creates an unlisted permanent URL for a previously generated team. Reuse one idempotencyKey when a save request is retried.",
        "operationId": "saveRandomTeam",
        "parameters": [
          {
            "$ref": "#/components/parameters/Format"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveGeneratedTeamRequest"
              },
              "example": {
                "teamText": "Garchomp @ Choice Scarf\nAbility: Rough Skin\nEVs: 252 Atk / 4 SpD / 252 Spe\nJolly Nature\n- Earthquake\n- Dragon Claw\n- Stone Edge\n- Iron Head\n\nCorviknight @ Leftovers\nAbility: Pressure\n- Roost\n- Defog\n- U-turn\n- Brave Bird\n\nRotom-Wash @ Leftovers\nAbility: Levitate\n- Hydro Pump\n- Volt Switch\n- Will-O-Wisp\n- Protect\n\nKingambit @ Black Glasses\nAbility: Supreme Overlord\n- Kowtow Cleave\n- Sucker Punch\n- Iron Head\n- Swords Dance\n\nClefable @ Leftovers\nAbility: Magic Guard\n- Moonblast\n- Moonlight\n- Stealth Rock\n- Thunder Wave\n\nDragapult @ Choice Specs\nAbility: Infiltrator\n- Shadow Ball\n- Draco Meteor\n- Flamethrower\n- U-turn",
                "idempotencyKey": "example-0123456789abcdef"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A retry returned the team that was already saved with this idempotency key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedTeam"
                },
                "example": {
                  "slug": "abc123",
                  "url": "https://crob.at/abc123",
                  "image": "https://crob.at/og/abc123.png"
                }
              }
            }
          },
          "201": {
            "description": "The generated team was saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedTeam"
                },
                "example": {
                  "slug": "abc123",
                  "url": "https://crob.at/abc123",
                  "image": "https://crob.at/og/abc123.png"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "409": {
            "description": "The idempotency key was already used for different team text or input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Idempotency key already used for different input"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/api/samples/{tier}": {
      "get": {
        "tags": [
          "Reference"
        ],
        "summary": "List sample teams",
        "description": "Returns the available Smogon sample teams for a competitive tier.",
        "operationId": "listSampleTeams",
        "parameters": [
          {
            "name": "tier",
            "in": "path",
            "required": true,
            "description": "An alphanumeric Showdown format identifier, such as gen9ou.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sample teams, or an empty array when none are available.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SampleTeam"
                  }
                },
                "example": [
                  {
                    "slug": "abc123",
                    "name": "Example team",
                    "author": "Smogon",
                    "tier": "gen9ou",
                    "views": 0,
                    "created_at": "2026-10-18 10:00:00",
                    "url": "https://crob.at/abc123",
                    "image": "https://crob.at/og/abc123.png",
                    "source_url": "https://www.smogon.com/forums/"
                  }
                ]
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/api/type-chart-data": {
      "get": {
        "tags": [
          "Reference"
        ],
        "summary": "Read Pokemon type data",
        "description": "Returns Pokemon names and their types for the interactive type chart.",
        "operationId": "getTypeChartData",
        "responses": {
          "200": {
            "description": "Pokemon names paired with one or two types.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TypeChartResponse"
                },
                "example": [
                  [
                    "Garchomp",
                    [
                      "Dragon",
                      "Ground"
                    ]
                  ]
                ]
              }
            }
          }
        }
      }
    },
    "/api/me": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Read the current user",
        "description": "Returns the current crob.at user when a valid browser session cookie is present, otherwise returns a null user.",
        "operationId": "getCurrentUser",
        "security": [
          {
            "cookieSession": []
          },
          {}
        ],
        "responses": {
          "200": {
            "description": "The current user or null.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrentUserResponse"
                },
                "example": {
                  "user": null
                }
              }
            }
          }
        }
      }
    },
    "/api/feedback": {
      "post": {
        "tags": [
          "Feedback"
        ],
        "summary": "Send feedback",
        "description": "Sends a feedback message with optional contact details.",
        "operationId": "sendFeedback",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackRequest"
              },
              "example": {
                "message": "The team API guide is useful."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Feedback was accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeedbackResponse"
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/RetryAfterRateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/api/showdown/assertion": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Start browser-side Showdown assertion generation",
        "description": "Redirects the signed-in user's browser to Pokemon Showdown so the challstr-specific assertion is generated from the user's network rather than crob.at's server.",
        "operationId": "createShowdownAssertion",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShowdownAssertionRequest"
              },
              "example": {
                "challstr": "12345|abcdefghijklmnopqrstuvwxyz"
              }
            }
          }
        },
        "responses": {
          "303": {
            "description": "Redirect to Pokemon Showdown's OAuth assertion endpoint.",
            "headers": {
              "Location": {
                "required": true,
                "schema": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "A linked, authenticated Showdown account is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Log into crob.at with Showdown first"
                }
              }
            }
          },
          "503": {
            "description": "Showdown OAuth is not configured.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Showdown OAuth is not configured"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "cookieSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "session",
        "description": "Optional crob.at browser session cookie. Public endpoints do not require it."
      }
    },
    "parameters": {
      "Format": {
        "name": "format",
        "in": "path",
        "required": true,
        "description": "An alphanumeric Showdown format identifier, such as gen9ou.",
        "schema": {
          "type": "string",
          "pattern": "^[a-z0-9]+$"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request body or route parameter is invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Invalid JSON request body"
            }
          }
        }
      },
      "NotFound": {
        "description": "The requested resource was not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Team not found"
            }
          }
        }
      },
      "RateLimited": {
        "description": "The per-client write limit was exceeded.",
        "headers": {
          "Retry-After": {
            "description": "Seconds until the request may be retried.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          "X-RateLimit-Limit": {
            "description": "Requests permitted in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests remaining in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "ISO 8601 timestamp when the window resets.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Rate limit exceeded",
              "retryAfter": 60
            }
          }
        }
      },
      "RetryAfterRateLimited": {
        "description": "The per-client write limit was exceeded.",
        "headers": {
          "Retry-After": {
            "description": "Seconds until the request may be retried.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Rate limit exceeded",
              "retryAfter": 60
            }
          }
        }
      },
      "ServerError": {
        "description": "The request could not be completed because of a server error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Error creating team"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retryAfter": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "TeamPaste": {
        "type": "object",
        "required": [
          "format",
          "name",
          "paste"
        ],
        "properties": {
          "format": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "paste": {
            "type": "string"
          }
        }
      },
      "Team": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "author",
          "description",
          "public",
          "image",
          "source_url",
          "created_at",
          "views",
          "is_multi",
          "teams",
          "provenance",
          "format_status",
          "tournament"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "author": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "public": {
            "type": "boolean",
            "description": "Whether the team may appear in the public gallery and search. False means unlisted, not private: anyone with the URL can read the team."
          },
          "image": {
            "type": "string",
            "format": "uri"
          },
          "source_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "created_at": {
            "type": "string",
            "description": "UTC SQLite timestamp in YYYY-MM-DD HH:MM:SS form; not an RFC 3339 date-time."
          },
          "views": {
            "type": "integer",
            "minimum": 0
          },
          "is_multi": {
            "type": "boolean"
          },
          "teams": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/TeamPaste"
            }
          },
          "provenance": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TeamProvenance"
              },
              {
                "type": "null"
              }
            ]
          },
          "format_status": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TeamFormatStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "tournament": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TournamentTeamContext"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "description": "A saved paste. Nullable metadata can be absent in the underlying data and is returned as null. A successful read does not prove battle legality. Clients must accept additional response fields."
      },
      "TeamInPaste": {
        "type": "object",
        "required": [
          "paste_slug",
          "slug",
          "format",
          "name",
          "paste",
          "url",
          "image"
        ],
        "properties": {
          "paste_slug": {
            "type": "string",
            "description": "The parent multi-team paste's public slug."
          },
          "slug": {
            "type": "string",
            "description": "The selected team's slug within the parent paste."
          },
          "format": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "paste": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "image": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "CreateTeamRequest": {
        "type": "object",
        "required": [
          "teams"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Optional team name. Values longer than 100 characters are truncated."
          },
          "author": {
            "type": "string",
            "description": "Optional author. Values longer than 50 characters are truncated."
          },
          "description": {
            "type": "string",
            "description": "Optional description. The trimmed value is truncated to 1,000 characters."
          },
          "public": {
            "type": "boolean",
            "default": false,
            "description": "Whether the team may appear in the public gallery. Defaults to false. Unlisted teams remain readable by anyone with the link."
          },
          "teams": {
            "type": "array",
            "minItems": 1,
            "description": "One or more teams. The combined normalized Showdown export must not exceed 500,000 characters.",
            "items": {
              "type": "object",
              "required": [
                "paste"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Optional team name. Values longer than 100 characters are truncated."
                },
                "format": {
                  "type": "string",
                  "description": "A supported Pokemon Showdown format ID or name. The server normalizes names to IDs."
                },
                "paste": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 500000,
                  "description": "Showdown export text with real newline characters after JSON decoding. Use JSON.stringify or a JSON library. Do not send a PokePaste URL in this field."
                }
              }
            }
          }
        },
        "description": "Stores one or more recognizable Showdown exports. This schema checks JSON shape, not Pokemon legality, completeness, blocked language, or the combined normalized text limit."
      },
      "CreatedTeam": {
        "type": "object",
        "required": [
          "slug",
          "url",
          "image"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "image": {
            "type": "string",
            "format": "uri"
          },
          "management_token": {
            "type": "string",
            "minLength": 48,
            "maxLength": 48,
            "description": "Private creator capability returned only by POST /api/team. Keep it secret; share url and image only. Generated-team saves do not return it."
          }
        }
      },
      "GeneratedTeam": {
        "type": "object",
        "required": [
          "teamText",
          "statsDate",
          "cardsHtml"
        ],
        "properties": {
          "teamText": {
            "type": "string",
            "description": "Showdown export for the bot or teambuilder. Each generation request produces a new result; retain this text for reproducible runs."
          },
          "statsDate": {
            "type": "string",
            "pattern": "^[0-9]{4}-[0-9]{2}$",
            "description": "Usage-data month, not the current date or a validator version."
          },
          "cardsHtml": {
            "type": "string",
            "description": "Rendered presentation HTML. Agents that need team data should read teamText."
          }
        }
      },
      "SampleTeam": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "author",
          "tier",
          "views",
          "created_at",
          "url",
          "image",
          "source_url"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "author": {
            "type": [
              "string",
              "null"
            ]
          },
          "tier": {
            "type": [
              "string",
              "null"
            ]
          },
          "views": {
            "type": "integer",
            "minimum": 0
          },
          "created_at": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "image": {
            "type": "string",
            "format": "uri"
          },
          "source_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          }
        }
      },
      "CurrentUser": {
        "type": "object",
        "required": [
          "username",
          "email",
          "ps_username",
          "team_count",
          "favorite_count"
        ],
        "properties": {
          "username": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email"
          },
          "ps_username": {
            "type": [
              "string",
              "null"
            ]
          },
          "team_count": {
            "type": "integer",
            "minimum": 0
          },
          "favorite_count": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "SaveGeneratedTeamRequest": {
        "type": "object",
        "required": [
          "teamText"
        ],
        "properties": {
          "teamText": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500000,
            "description": "A Pokemon Showdown team export returned by the generation endpoint.",
            "pattern": "\\S"
          },
          "idempotencyKey": {
            "type": "string",
            "minLength": 16,
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9_-]+$",
            "description": "Optional stable retry key. Reuse the same key and identical teamText for the same format. A key used for different input returns 409. Keys are shared across clients, so generate a random UUID for each new save."
          }
        }
      },
      "FeedbackRequest": {
        "type": "object",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "pattern": "\\S",
            "description": "The trimmed message must contain a non-whitespace character and be at most 2,000 characters."
          },
          "contact": {
            "type": "string",
            "description": "Optional contact details. Values longer than 100 characters are truncated."
          }
        }
      },
      "ShowdownAssertionRequest": {
        "type": "object",
        "required": [
          "challstr"
        ],
        "properties": {
          "challstr": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048,
            "pattern": "^[^\\r\\n]+$",
            "description": "A Pokemon Showdown challenge string without line breaks."
          }
        }
      },
      "TypeChartResponse": {
        "type": "array",
        "items": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "prefixItems": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "minItems": 1,
              "maxItems": 2,
              "items": {
                "type": "string"
              }
            }
          ],
          "items": {}
        }
      },
      "CurrentUserResponse": {
        "type": "object",
        "required": [
          "user"
        ],
        "properties": {
          "user": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CurrentUser"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "FeedbackResponse": {
        "type": "object",
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "const": true
          }
        }
      },
      "TeamProvenance": {
        "type": "object",
        "required": [
          "sourceType",
          "eventName",
          "eventDate",
          "placement",
          "fieldSize",
          "sourceUrl",
          "refreshedAt"
        ],
        "properties": {
          "sourceType": {
            "type": "string",
            "enum": [
              "tournament",
              "smogon_sample",
              "verified_author",
              "community"
            ]
          },
          "eventName": {
            "type": [
              "string",
              "null"
            ]
          },
          "eventDate": {
            "type": [
              "string",
              "null"
            ]
          },
          "placement": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "fieldSize": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "sourceUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "refreshedAt": {
            "type": "string"
          }
        }
      },
      "TeamFormatStatus": {
        "type": "object",
        "required": [
          "formatId",
          "status",
          "reasonCode",
          "reason",
          "validatedRevision",
          "validatedAt"
        ],
        "properties": {
          "formatId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "current",
              "valid",
              "review",
              "invalid",
              "unknown"
            ]
          },
          "reasonCode": {
            "type": "string",
            "enum": [
              "validated_after_snapshot",
              "validated_without_review_date",
              "date_unavailable",
              "format_changed_after_review",
              "validator_rejected",
              "format_unavailable",
              "format_unspecified",
              "multi_team",
              "team_unreadable",
              "team_incomplete"
            ]
          },
          "reason": {
            "type": "string"
          },
          "validatedRevision": {
            "type": "string"
          },
          "validatedAt": {
            "type": "string"
          }
        }
      },
      "TournamentTeamContext": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "startsAt",
          "placement",
          "playerCount"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "startsAt": {
            "type": "string"
          },
          "placement": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "playerCount": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    }
  },
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema"
}
