{
  "lexicon": 1,
  "id": "com.atproto.temp.checkHandleAvailability",
  "defs": {
    "main": {
      "type": "query",
      "description": "Checks whether the provided handle is available. If the handle is not available, available suggestions will be returned. Optional inputs will be used to generate suggestions.",
      "parameters": {
        "type": "params",
        "required": [
          "handle"
        ],
        "properties": {
          "birthDate": {
            "type": "string",
            "description": "User-provided birth date. Might be used to build handle suggestions.",
            "format": "datetime"
          },
          "email": {
            "type": "string",
            "description": "User-provided email. Might be used to build handle suggestions."
          },
          "handle": {
            "type": "string",
            "description": "Tentative handle. Will be checked for availability or used to build handle suggestions.",
            "format": "handle"
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": [
            "handle",
            "result"
          ],
          "properties": {
            "handle": {
              "type": "string",
              "description": "Echo of the input handle.",
              "format": "handle"
            },
            "result": {
              "type": "union",
              "refs": [
                "#resultAvailable",
                "#resultUnavailable"
              ]
            }
          }
        }
      },
      "errors": [
        {
          "description": "An invalid email was provided.",
          "name": "InvalidEmail"
        }
      ]
    },
    "resultAvailable": {
      "type": "object",
      "description": "Indicates the provided handle is available.",
      "properties": {}
    },
    "resultUnavailable": {
      "type": "object",
      "description": "Indicates the provided handle is unavailable and gives suggestions of available handles.",
      "required": [
        "suggestions"
      ],
      "properties": {
        "suggestions": {
          "type": "array",
          "description": "List of suggested handles based on the provided inputs.",
          "items": {
            "type": "ref",
            "ref": "#suggestion"
          }
        }
      }
    },
    "suggestion": {
      "type": "object",
      "required": [
        "handle",
        "method"
      ],
      "properties": {
        "handle": {
          "type": "string",
          "format": "handle"
        },
        "method": {
          "type": "string",
          "description": "Method used to build this suggestion. Should be considered opaque to clients. Can be used for metrics."
        }
      }
    }
  }
}