{
  "openapi": "3.1.0",
  "info": {
    "title": "Clutch Partner API",
    "version": "1.0.0",
    "description": "Create matches at your Clutch venues and push live scores from your own scoring system. Clutch shows the score on the court overlay, records the match on camera courts and publishes the event on the public site.",
    "contact": {
      "name": "Clutch Sports",
      "email": "contact@theclutchsports.com",
      "url": "https://partners.theclutchsports.org"
    }
  },
  "servers": [
    {
      "url": "https://partners.theclutchsports.org/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Venues"
    },
    {
      "name": "Events"
    },
    {
      "name": "Matches"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "maxLength": 120
        },
        "description": "Required on every POST and PUT. Any unique string up to 120 characters (a UUID works). Repeating a key within 24 hours returns the first response again with the header `Idempotent-Replay: true`."
      },
      "QuickMatchId": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Stable machine-readable code"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Facility": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "type": [
              "string",
              "null"
            ]
          },
          "courts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "sport": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "QuickTournament": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "facilityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "deduped": {
            "type": "boolean",
            "description": "Present and true when an existing event was returned instead of creating a new one."
          },
          "dedupedBy": {
            "type": "string",
            "enum": [
              "externalId",
              "naturalKey"
            ]
          }
        }
      },
      "QuickTournamentListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "facilityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "facilityName": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "matchCount": {
            "type": "string",
            "description": "Number of matches, as a numeric string"
          }
        }
      },
      "CreateQuickTournament": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "facilityId": {
            "type": "string",
            "format": "uuid",
            "description": "Optional. Must be one of your venues."
          },
          "externalId": {
            "type": "string",
            "description": "Your own id for the event. Sending the same externalId again returns the existing event."
          }
        }
      },
      "CreateQuickMatch": {
        "type": "object",
        "required": [
          "sport",
          "teamAName",
          "teamBName",
          "facilityId"
        ],
        "properties": {
          "sport": {
            "type": "string",
            "enum": [
              "pickleball",
              "badminton",
              "tabletennis",
              "squash",
              "volleyball",
              "cricket"
            ]
          },
          "teamAName": {
            "type": "string"
          },
          "teamBName": {
            "type": "string"
          },
          "facilityId": {
            "type": "string",
            "format": "uuid",
            "description": "One of your venues (GET /facilities)."
          },
          "courtId": {
            "type": "string",
            "format": "uuid",
            "description": "A court at that venue. Needed for the court overlay and for recording."
          },
          "quickTournamentId": {
            "type": "string",
            "format": "uuid",
            "description": "One of your events. On a camera court this starts recording when the match is created."
          },
          "externalId": {
            "type": "string",
            "description": "Your own id for the match. Sending the same externalId again returns the existing match."
          },
          "matchFormat": {
            "type": "string",
            "enum": [
              "singles",
              "doubles"
            ]
          },
          "scoringMode": {
            "type": "string",
            "enum": [
              "self"
            ],
            "default": "self",
            "description": "Your key's scoring mode. Leave it out."
          }
        }
      },
      "CreatedQuickMatch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "scoringSource": {
            "type": "string",
            "enum": [
              "self",
              "engine"
            ]
          },
          "deduped": {
            "type": "boolean"
          }
        }
      },
      "RallyScoreboard": {
        "type": "object",
        "description": "Scoreboard for a game/set-based sport. Extra fields you send are stored and returned as-is.",
        "required": [
          "score_a",
          "score_b",
          "games_a",
          "games_b",
          "current_game_number",
          "total_games"
        ],
        "properties": {
          "score_a": {
            "type": "integer",
            "description": "Team A points in the current game"
          },
          "score_b": {
            "type": "integer",
            "description": "Team B points in the current game"
          },
          "games_a": {
            "type": "integer",
            "description": "Games (sets) won by team A"
          },
          "games_b": {
            "type": "integer",
            "description": "Games (sets) won by team B"
          },
          "current_game_number": {
            "type": "integer"
          },
          "total_games": {
            "type": "integer",
            "description": "Best-of count, e.g. 3"
          },
          "serving_team": {
            "type": "string",
            "enum": [
              "A",
              "B"
            ]
          },
          "server_number": {
            "type": "integer",
            "description": "Pickleball doubles: 1 or 2"
          },
          "points_to_win": {
            "type": "integer"
          },
          "win_by": {
            "type": "integer"
          }
        },
        "additionalProperties": true
      },
      "CricketScoreboard": {
        "type": "object",
        "required": [
          "innings_no",
          "runs",
          "wickets",
          "max_overs",
          "overs",
          "batting_team_name"
        ],
        "properties": {
          "innings_no": {
            "type": "integer"
          },
          "batting_team_name": {
            "type": "string"
          },
          "runs": {
            "type": "integer"
          },
          "wickets": {
            "type": "integer"
          },
          "overs": {
            "type": "string",
            "description": "Overs bowled, e.g. \"12.4\""
          },
          "max_overs": {
            "type": "integer"
          },
          "extras": {
            "type": "integer"
          },
          "target": {
            "type": [
              "integer",
              "null"
            ]
          },
          "crr": {
            "type": [
              "number",
              "null"
            ]
          },
          "rrr": {
            "type": [
              "number",
              "null"
            ]
          },
          "striker": {
            "type": "object",
            "additionalProperties": true
          },
          "non_striker": {
            "type": "object",
            "additionalProperties": true
          },
          "bowler": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "ScorePush": {
        "type": "object",
        "required": [
          "teamAScore",
          "teamBScore"
        ],
        "description": "Send the block named after the match's sport (for a pickleball match, `pickleball`). Exactly that block is required on every push.",
        "properties": {
          "teamAScore": {
            "type": "number",
            "description": "Headline score for team A"
          },
          "teamBScore": {
            "type": "number",
            "description": "Headline score for team B"
          },
          "scoreText": {
            "type": "string",
            "description": "Display text, e.g. \"11-7 (1-0)\". Defaults to \"<teamAScore>-<teamBScore>\"."
          },
          "status": {
            "type": "string",
            "enum": [
              "in_progress",
              "completed"
            ],
            "default": "in_progress",
            "description": "\"completed\" ends the match and stops its recording."
          },
          "pickleball": {
            "$ref": "#/components/schemas/RallyScoreboard"
          },
          "badminton": {
            "$ref": "#/components/schemas/RallyScoreboard"
          },
          "tabletennis": {
            "$ref": "#/components/schemas/RallyScoreboard"
          },
          "squash": {
            "$ref": "#/components/schemas/RallyScoreboard"
          },
          "volleyball": {
            "$ref": "#/components/schemas/RallyScoreboard"
          },
          "cricket": {
            "$ref": "#/components/schemas/CricketScoreboard"
          }
        }
      },
      "ScoreResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "in_progress",
              "completed"
            ]
          },
          "score": {
            "type": "string"
          },
          "scoringSource": {
            "type": "string"
          },
          "sport": {
            "type": "string",
            "enum": [
              "pickleball",
              "badminton",
              "tabletennis",
              "squash",
              "volleyball",
              "cricket"
            ]
          },
          "scoreboard": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "CompleteResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "completed"
            ]
          },
          "alreadyCompleted": {
            "type": "boolean"
          }
        }
      },
      "QuickMatch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "teamA": {
            "type": "string"
          },
          "teamB": {
            "type": "string"
          },
          "sport": {
            "type": "string",
            "enum": [
              "pickleball",
              "badminton",
              "tabletennis",
              "squash",
              "volleyball",
              "cricket"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "in_progress",
              "completed"
            ]
          },
          "score": {
            "type": [
              "string",
              "null"
            ]
          },
          "scoringSource": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "facilityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "courtId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "quickTournamentId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "scoreboard": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "description": "The last sport block you pushed"
          },
          "partnerScore": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "teamAScore": {
                "type": "number"
              },
              "teamBScore": {
                "type": "number"
              },
              "scoreText": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "status": {
                "type": "string"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "recording": {
            "type": [
              "object",
              "null"
            ],
            "description": "Only for keys with recording links switched on.",
            "properties": {
              "video_url": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "hls_url": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "thumbnail_url": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "status": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "share_token": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "`bad_request`, `missing_idempotency_key`, `invalid_idempotency_key`, `facility_not_in_tournament`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "`missing_api_key` or `invalid_api_key`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "`facility_required`, `facility_forbidden`, `court_forbidden`, `tournament_forbidden`, `scoring_mode_forbidden`, `match_forbidden`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "`not_found`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "`match_completed` or `mode_conflict`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "`rate_limited`: your key's per-minute limit was exceeded",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/facilities": {
      "get": {
        "tags": [
          "Venues"
        ],
        "operationId": "listFacilities",
        "summary": "List your venues and courts",
        "responses": {
          "200": {
            "description": "Your venues",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Facility"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/quick-tournaments": {
      "get": {
        "tags": [
          "Events"
        ],
        "operationId": "listQuickTournaments",
        "summary": "List your events",
        "parameters": [
          {
            "name": "facilityId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Only events at this venue"
          }
        ],
        "responses": {
          "200": {
            "description": "Your active events, newest first (up to 100)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/QuickTournamentListItem"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": [
          "Events"
        ],
        "operationId": "createQuickTournament",
        "summary": "Create an event",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateQuickTournament"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/QuickTournament"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "An existing event was returned (`deduped: true`)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/QuickTournament"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/quick-matches": {
      "post": {
        "tags": [
          "Matches"
        ],
        "operationId": "createQuickMatch",
        "summary": "Create a match",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateQuickMatch"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CreatedQuickMatch"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "A match with this externalId already exists (`deduped: true`)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CreatedQuickMatch"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/quick-matches/{id}": {
      "get": {
        "tags": [
          "Matches"
        ],
        "operationId": "getQuickMatch",
        "summary": "Read a match",
        "parameters": [
          {
            "$ref": "#/components/parameters/QuickMatchId"
          }
        ],
        "responses": {
          "200": {
            "description": "The match",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/QuickMatch"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/quick-matches/{id}/score": {
      "put": {
        "tags": [
          "Matches"
        ],
        "operationId": "pushScore",
        "summary": "Push the current score",
        "parameters": [
          {
            "$ref": "#/components/parameters/QuickMatchId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScorePush"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ScoreResult"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/quick-matches/{id}/complete": {
      "post": {
        "tags": [
          "Matches"
        ],
        "operationId": "completeQuickMatch",
        "summary": "End a match",
        "parameters": [
          {
            "$ref": "#/components/parameters/QuickMatchId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Completed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CompleteResult"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  }
}