{
  "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": {
          "handle": {
            "type": "string",
            "format": "handle",
            "description": "Tentative handle. Will be checked for availability or used to build handle suggestions."
          },
          "email": {
            "type": "string",
            "description": "User-provided email. Might be used to build handle suggestions."
          },
          "birthDate": {
            "type": "string",
            "format": "datetime",
            "description": "User-provided birth date. Might be used to build handle suggestions."
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": ["handle", "result"],
          "properties": {
            "handle": {
              "type": "string",
              "format": "handle",
              "description": "Echo of the input handle."
            },
            "result": {
              "type": "union",
              "refs": ["#resultAvailable", "#resultUnavailable"]
            }
          }
        }
      },
      "errors": [
        {
          "name": "InvalidEmail",
          "description": "An invalid email was provided."
        }
      ]
    },
    "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."
        }
      }
    }
  }
}

