{
  "openapi" : "3.1.0",
  "info" : {
    "title" : "MinecraftAuth.me API",
    "version" : "2",
    "description" : "Look up a player's linked Minecraft, Discord, Twitch, Patreon and YouTube accounts, and check whether they follow, subscribe to or support you.\n\nEvery request **must** send a non-empty `User-Agent` header naming your integration (e.g. `MyPlugin/1.4`), or it's rejected with `403`.\n\nPlatform ids are `minecraft`, `discord`, `twitch`, `patreon` and `google` (YouTube), case-insensitive. Errors are real HTTP statuses with an `ErrorBody`; branch on the status, not the text. Within v2, responses only change in backwards-compatible ways, so ignore fields you don't know.\n\nGuides: https://minecraftauth.me/developers/docs"
  },
  "servers" : [ {
    "url" : "https://minecraftauth.me",
    "description" : "Production",
    "variables" : { }
  } ],
  "components" : {
    "securitySchemes" : {
      "ServerToken" : {
        "scheme" : "bearer",
        "type" : "http",
        "description" : "**Deprecated**: a server token, `Authorization: Bearer <token>`. No longer issued, and only accepted until the date in the `Sunset` header. Use application credentials."
      },
      "ServerTokenBasic" : {
        "scheme" : "basic",
        "type" : "http",
        "description" : "**Deprecated**: a server token in its Basic form, `uid:token` as the username and password. No longer issued, and only accepted until the date in the `Sunset` header. Use application credentials."
      },
      "ApplicationCredentials" : {
        "scheme" : "basic",
        "type" : "http",
        "description" : "An application's ID and secret from the Developers page: `applicationId:secret` as the username and password. Membership checks run as the application's owner."
      }
    },
    "schemas" : {
      "ErrorBody" : {
        "type" : "object",
        "description" : "The body of every error response. Branch on `status`, not on the `error` text.",
        "properties" : {
          "error" : {
            "type" : "string",
            "description" : "What went wrong, for logs and people",
            "example" : "No identity is linked to that Minecraft account"
          },
          "status" : {
            "type" : "integer",
            "format" : "int32",
            "description" : "The HTTP status, repeated",
            "example" : 404
          }
        },
        "required" : [ "error", "status" ]
      },
      "GrantRequestBody" : {
        "type" : "object",
        "description" : "What to ask the player for. The whole body is optional.",
        "properties" : {
          "scopes" : {
            "items" : {
              "type" : "string"
            },
            "description" : "Platform ids to request access to, as a list or a space-separated string. `minecraft` is always included.",
            "example" : [ "discord", "twitch" ],
            "type" : "array"
          },
          "persist" : {
            "description" : "Whether approving stores a lasting grant (default `true`). `false` makes a one-off check that only hands over the signed token.",
            "example" : true,
            "type" : "boolean"
          }
        }
      },
      "GrantRequestCreated" : {
        "type" : "object",
        "description" : "A new access request, waiting for the player",
        "properties" : {
          "id" : {
            "type" : "string",
            "description" : "Poll `GET /grant-requests/{id}` with this",
            "example" : "9f2c1e7a4b8d4c0e9a1b2c3d4e5f6a7b"
          },
          "code" : {
            "type" : "string",
            "description" : "The code the player enters at `verificationUrl`",
            "example" : "ABCD-EFGH"
          },
          "url" : {
            "type" : "string",
            "description" : "A link that opens the request with the code filled in",
            "example" : "https://minecraftauth.me/grant?code=ABCD-EFGH"
          },
          "verificationUrl" : {
            "type" : "string",
            "description" : "Where the player enters the code themselves",
            "example" : "https://minecraftauth.me/grant"
          },
          "scopes" : {
            "type" : "array",
            "items" : {
              "type" : "string"
            },
            "description" : "The platforms requested, always including `minecraft`",
            "example" : [ "minecraft", "discord" ]
          },
          "persist" : {
            "type" : "boolean",
            "description" : "Whether approving stores a lasting grant",
            "example" : true
          },
          "expiresAt" : {
            "type" : "integer",
            "format" : "int64",
            "description" : "When the request expires, in epoch milliseconds",
            "example" : 1767225600000
          },
          "interval" : {
            "type" : "integer",
            "format" : "int32",
            "description" : "How often to poll, in seconds",
            "example" : 5
          }
        },
        "required" : [ "id", "code", "url", "verificationUrl", "scopes", "persist", "expiresAt", "interval" ]
      },
      "GrantRequestStatus" : {
        "type" : "object",
        "description" : "Where an access request stands",
        "properties" : {
          "status" : {
            "type" : "string",
            "description" : "`pending` until the player answers, then `accepted` or `denied`; `expired` if they never did",
            "example" : "accepted"
          },
          "expiresAt" : {
            "type" : "integer",
            "format" : "int64",
            "description" : "When the request expires, in epoch milliseconds",
            "example" : 1767225600000
          },
          "token" : {
            "description" : "Once `accepted`: the signed token naming the player and what they granted",
            "type" : "string"
          }
        },
        "required" : [ "status", "expiresAt" ]
      },
      "LinkedAccount" : {
        "type" : "object",
        "description" : "A linked account: `{\"identifier\": \"...\"}` when you may see it, or `{\"hint\": true}` when the player only lets you know it exists. Exactly one of the two fields is present.",
        "properties" : {
          "identifier" : {
            "description" : "The account's identifier on its platform, always a string",
            "example" : "069a79f4-44e9-4726-a5be-fca90e38aaf5",
            "type" : "string"
          },
          "hint" : {
            "description" : "Present (true) when the account exists but its identifier is hidden from you",
            "example" : true,
            "type" : "boolean"
          }
        }
      },
      "LinkedAccounts" : {
        "type" : "object",
        "description" : "The identity's linked accounts by platform id. A platform is missing when it isn't linked, the player hides it from you, or it wasn't in `include`.",
        "properties" : {
          "minecraft" : {
            "description" : "Minecraft UUID, with dashes",
            "$ref" : "#/components/schemas/LinkedAccount"
          },
          "discord" : {
            "description" : "Discord user ID",
            "$ref" : "#/components/schemas/LinkedAccount"
          },
          "patreon" : {
            "description" : "Patreon user ID",
            "$ref" : "#/components/schemas/LinkedAccount"
          },
          "twitch" : {
            "description" : "Twitch user ID",
            "$ref" : "#/components/schemas/LinkedAccount"
          },
          "google" : {
            "description" : "YouTube channel ID",
            "$ref" : "#/components/schemas/LinkedAccount"
          }
        }
      },
      "LookupResponse" : {
        "type" : "object",
        "description" : "A player's linked accounts, as far as their privacy settings let you see them",
        "properties" : {
          "accounts" : {
            "$ref" : "#/components/schemas/LinkedAccounts"
          }
        },
        "required" : [ "accounts" ]
      },
      "MembershipResult" : {
        "type" : "object",
        "description" : "The answer of a membership check that could be made",
        "properties" : {
          "result" : {
            "type" : "boolean",
            "description" : "Whether the player is a member",
            "example" : true
          }
        },
        "required" : [ "result" ]
      },
      "PlatformId" : {
        "type" : "string",
        "enum" : [ "minecraft", "discord", "patreon", "twitch", "google" ],
        "description" : "A platform id (case-insensitive). `google` is YouTube."
      }
    }
  },
  "paths" : {
    "/api/v2/discord/present" : {
      "get" : {
        "tags" : [ "Membership" ],
        "summary" : "Is in a Discord server",
        "description" : "Whether the player's linked Discord account is a member of the given Discord server. The MinecraftAuth bot must be in that server, and your linked Discord account must be its owner or have the Administrator or Manage Messages permission there. See https://minecraftauth.me/developers/docs/membership-checks",
        "operationId" : "discordPresent",
        "parameters" : [ {
          "name" : "minecraft",
          "in" : "query",
          "description" : "The player's Minecraft UUID, with or without dashes",
          "required" : true,
          "schema" : {
            "type" : "string"
          },
          "example" : "069a79f4-44e9-4726-a5be-fca90e38aaf5"
        }, {
          "name" : "server",
          "in" : "query",
          "description" : "The Discord server (guild) ID",
          "required" : true,
          "schema" : {
            "type" : "string"
          },
          "example" : "123456789012345678"
        } ],
        "responses" : {
          "200" : {
            "description" : "The check ran",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/MembershipResult"
                }
              }
            }
          },
          "400" : {
            "description" : "Missing or malformed `minecraft` or `server`",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401" : {
            "description" : "No credentials",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403" : {
            "description" : "Wrong or retired credentials, you have no linked Discord account, or you aren't a member or moderator of the server",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404" : {
            "description" : "No player linked that Minecraft account, or they have no usable Discord account",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409" : {
            "description" : "The MinecraftAuth bot isn't in that Discord server",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429" : {
            "description" : "Rate limited: retry after `Retry-After` seconds",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502" : {
            "description" : "Discord couldn't be asked; try again later",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security" : [ {
          "ApplicationCredentials" : [ ]
        }, {
          "ServerToken" : [ ]
        }, {
          "ServerTokenBasic" : [ ]
        } ]
      }
    },
    "/api/v2/following" : {
      "get" : {
        "tags" : [ "Membership" ],
        "summary" : "Is following",
        "description" : "Whether the player follows you on `platform`: `twitch` (follows your channel) or `google` (subscribed to your YouTube channel). You must have that platform linked. See https://minecraftauth.me/developers/docs/membership-checks",
        "operationId" : "following",
        "parameters" : [ {
          "name" : "minecraft",
          "in" : "query",
          "description" : "The player's Minecraft UUID, with or without dashes",
          "required" : true,
          "schema" : {
            "type" : "string"
          },
          "example" : "069a79f4-44e9-4726-a5be-fca90e38aaf5"
        }, {
          "name" : "platform",
          "in" : "query",
          "description" : "`twitch` or `google`",
          "required" : true,
          "example" : "twitch",
          "schema" : {
            "$ref" : "#/components/schemas/PlatformId"
          }
        } ],
        "responses" : {
          "200" : {
            "description" : "The check ran",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/MembershipResult"
                }
              }
            }
          },
          "400" : {
            "description" : "Missing or malformed `minecraft`, or a missing, unknown or unsupported `platform`",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401" : {
            "description" : "No credentials",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403" : {
            "description" : "Wrong or retired credentials, or you have no linked account on the platform",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404" : {
            "description" : "No player linked that Minecraft account, or they have no usable account on the platform",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429" : {
            "description" : "Rate limited: retry after `Retry-After` seconds",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502" : {
            "description" : "The platform couldn't be asked; try again later",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security" : [ {
          "ApplicationCredentials" : [ ]
        }, {
          "ServerToken" : [ ]
        }, {
          "ServerTokenBasic" : [ ]
        } ]
      }
    },
    "/api/v2/grant-requests" : {
      "post" : {
        "tags" : [ "Access requests" ],
        "summary" : "Start an access request",
        "description" : "Asks a player for access to their private accounts, for applications without a website to redirect players back to. Show the player the returned `url`, or `code` and `verificationUrl`, then poll `GET /grant-requests/{id}` every `interval` seconds until they answer. Requests expire after 10 minutes, and at most 100 can wait at once. Needs application credentials. See https://minecraftauth.me/developers/docs/access-requests",
        "operationId" : "createGrantRequest",
        "requestBody" : {
          "content" : {
            "application/json" : {
              "schema" : {
                "$ref" : "#/components/schemas/GrantRequestBody"
              }
            }
          }
        },
        "responses" : {
          "201" : {
            "description" : "The request was started",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/GrantRequestCreated"
                }
              }
            }
          },
          "400" : {
            "description" : "Malformed body, or an unknown platform in `scopes`",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401" : {
            "description" : "No credentials",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403" : {
            "description" : "Wrong credentials, or a server token instead of application credentials",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429" : {
            "description" : "Too many unanswered requests at once, or rate limited (see `Retry-After`)",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security" : [ {
          "ApplicationCredentials" : [ ]
        } ]
      }
    },
    "/api/v2/grant-requests/{id}" : {
      "get" : {
        "tags" : [ "Access requests" ],
        "summary" : "Poll an access request",
        "description" : "Where an access request stands. Poll every `interval` seconds until `status` isn't `pending`. Once `accepted`, `token` is a token signed with the key at https://minecraftauth.me/rsa, naming the player and what they granted. Needs the credentials of the application that started it. See https://minecraftauth.me/developers/docs/access-requests",
        "operationId" : "getGrantRequest",
        "parameters" : [ {
          "name" : "id",
          "in" : "path",
          "description" : "The `id` from starting the request",
          "required" : true,
          "schema" : {
            "type" : "string"
          },
          "example" : "9f2c1e7a4b8d4c0e9a1b2c3d4e5f6a7b"
        } ],
        "responses" : {
          "200" : {
            "description" : "The request's status",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/GrantRequestStatus"
                }
              }
            }
          },
          "401" : {
            "description" : "No credentials",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403" : {
            "description" : "Wrong credentials, or a server token instead of application credentials",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404" : {
            "description" : "No request with that ID was started by this application",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429" : {
            "description" : "Rate limited: retry after `Retry-After` seconds",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security" : [ {
          "ApplicationCredentials" : [ ]
        } ]
      }
    },
    "/api/v2/lookup/{platform}/{identifier}" : {
      "get" : {
        "tags" : [ "Lookup" ],
        "summary" : "Look up linked accounts",
        "description" : "Finds the player who linked the given account, and returns their other linked accounts as far as their privacy settings let you see them: `{\"identifier\": \"...\"}` when visible, `{\"hint\": true}` when only its existence is, or left out.\n\nCredentials are optional. Application credentials also reveal what players granted the application. A player who hides the account you looked up by answers `404`, exactly like one who never linked it. See https://minecraftauth.me/developers/docs/lookup",
        "operationId" : "lookup",
        "parameters" : [ {
          "name" : "platform",
          "in" : "path",
          "description" : "The platform of the account to look up by",
          "required" : true,
          "example" : "minecraft",
          "schema" : {
            "$ref" : "#/components/schemas/PlatformId"
          }
        }, {
          "name" : "identifier",
          "in" : "path",
          "description" : "The account's identifier on that platform. A Minecraft UUID is accepted with or without dashes.",
          "required" : true,
          "schema" : {
            "type" : "string"
          },
          "example" : "069a79f4-44e9-4726-a5be-fca90e38aaf5"
        }, {
          "name" : "include",
          "in" : "query",
          "description" : "Comma-separated platform ids to return; default all",
          "schema" : {
            "type" : "string"
          },
          "example" : "discord,twitch"
        } ],
        "responses" : {
          "200" : {
            "description" : "The player's visible accounts",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/LookupResponse"
                }
              }
            }
          },
          "400" : {
            "description" : "Unknown platform, malformed identifier, or unsupported Authorization scheme",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403" : {
            "description" : "Wrong credentials, or no User-Agent",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404" : {
            "description" : "No player linked that account, or they hide it from you",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429" : {
            "description" : "Rate limited: retry after `Retry-After` seconds",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security" : [ {
          "ApplicationCredentials" : [ ]
        }, {
          "ServerToken" : [ ]
        }, {
          "ServerTokenBasic" : [ ]
        }, { } ]
      }
    },
    "/api/v2/subscribed" : {
      "get" : {
        "tags" : [ "Membership" ],
        "summary" : "Is subscribed",
        "description" : "Whether the player subscribes to or supports you on `platform`:\n\n| `platform` | Means | `data` |\n|---|---|---|\n| `discord` | has a role in a Discord server you moderate | **required**: a role ID, or a role name (case-insensitive) together with `server` |\n| `twitch` | subscribed to your channel | minimum tier: `1`, `2` or `3` (or `1000`/`2000`/`3000`); default any tier |\n| `patreon` | an active patron of your campaign | a tier title (case-insensitive); default any tier |\n| `google` | a member of your YouTube channel | ignored |\n\nFor `discord`, the MinecraftAuth bot must be in the role's server, and your linked Discord account must be its owner or have the Administrator or Manage Messages permission there. A role name is only looked up in `server`, since anyone can create a role with the same name in a server of their own. For every other platform, you must have that platform linked. See https://minecraftauth.me/developers/docs/membership-checks",
        "operationId" : "subscribed",
        "parameters" : [ {
          "name" : "minecraft",
          "in" : "query",
          "description" : "The player's Minecraft UUID, with or without dashes",
          "required" : true,
          "schema" : {
            "type" : "string"
          },
          "example" : "069a79f4-44e9-4726-a5be-fca90e38aaf5"
        }, {
          "name" : "platform",
          "in" : "query",
          "description" : "`discord`, `twitch`, `patreon` or `google`",
          "required" : true,
          "example" : "twitch",
          "schema" : {
            "$ref" : "#/components/schemas/PlatformId"
          }
        }, {
          "name" : "data",
          "in" : "query",
          "description" : "Narrows what counts; see the table above",
          "schema" : {
            "type" : "string"
          },
          "example" : "2"
        }, {
          "name" : "server",
          "in" : "query",
          "description" : "`discord` only: the Discord server (guild) ID the role is in. Required for a role name",
          "schema" : {
            "type" : "string"
          },
          "example" : "123456789012345678"
        } ],
        "responses" : {
          "200" : {
            "description" : "The check ran",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/MembershipResult"
                }
              }
            }
          },
          "400" : {
            "description" : "Missing or malformed `minecraft`, a missing, unknown or unsupported `platform`, malformed `data`, or for `discord`: no role, a role name without `server`, a malformed `server`, or a role that isn't in `server`",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401" : {
            "description" : "No credentials",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403" : {
            "description" : "Wrong or retired credentials, you have no linked account on the platform, you aren't a member or moderator of the role's Discord server",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404" : {
            "description" : "No player linked that Minecraft account, or they have no usable account on the platform",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409" : {
            "description" : "`discord` only: the MinecraftAuth bot isn't in `server`, or in any server with that role ID",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429" : {
            "description" : "Rate limited: retry after `Retry-After` seconds",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502" : {
            "description" : "The platform couldn't be asked; try again later",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security" : [ {
          "ApplicationCredentials" : [ ]
        }, {
          "ServerToken" : [ ]
        }, {
          "ServerTokenBasic" : [ ]
        } ]
      }
    }
  },
  "tags" : [ {
    "name" : "Lookup",
    "description" : "Find a player's linked accounts by any one of them."
  }, {
    "name" : "Membership",
    "description" : "Check whether a player follows, subscribes to or supports you, or is in your Discord server."
  }, {
    "name" : "Access requests",
    "description" : "Ask players for access to accounts they keep private, without a website to redirect them back to."
  } ]
}