{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "instance": {
      "description": "A private instance as its members see it.",
      "properties": {
        "app": {
          "description": "The place.hud.app it runs, by its author's DID.",
          "format": "at-uri",
          "type": "string"
        },
        "authority": {
          "description": "Who made it, and alone adds and takes out its members and deletes it.",
          "ref": "place.hud.defs#actor",
          "type": "ref"
        },
        "createdAt": {
          "format": "datetime",
          "type": "string"
        },
        "members": {
          "description": "Its members, the authority first, then by handle.",
          "items": {
            "ref": "#member",
            "type": "ref"
          },
          "type": "array"
        },
        "name": {
          "description": "What its members call it.",
          "maxLength": 640,
          "type": "string"
        },
        "role": {
          "description": "What the person is in it: its authority, a member who writes in it, or one who reads it alone.",
          "knownValues": [
            "authority",
            "writer",
            "reader"
          ],
          "maxLength": 16,
          "type": "string"
        },
        "uri": {
          "description": "Its space, at:space/<authority DID>/place.hud.app.instance/<key>: what the entry methods take as instance.",
          "format": "at-uri",
          "type": "string"
        },
        "version": {
          "description": "A mark of what HUD read of it, which changes whenever any of its members' repos does. Opaque.",
          "maxLength": 128,
          "type": "string"
        }
      },
      "required": [
        "uri",
        "name",
        "app",
        "authority",
        "members",
        "role",
        "version"
      ],
      "type": "object"
    },
    "main": {
      "description": "A private instance of a frame app (a place.hud.app.instance space), read as the person: HUD trades a delegation token from their PDS for a space credential from the space's host, then reads its writers' repos with it, each checked against its MAC. Its name, the app it runs, its members and what the person may do in it. Requires auth: the workspace's web session (its cookie) or a HUD access token as Bearer.",
      "errors": [
        {
          "description": "Neither instance nor authority and key given, or not a space of place.hud.app.instance.",
          "name": "InvalidRequest"
        },
        {
          "description": "It was deleted, or it runs another app than the one asked.",
          "name": "NotFound"
        },
        {
          "description": "The person is not one of its members, or there is no such instance: its host says nothing of which.",
          "name": "NotAMember"
        },
        {
          "description": "The person's PDS gives no delegation token to read it with: it does not offer spaces, or their sign-in does not allow reading them (the message says which: sign in again for the latter).",
          "name": "CannotRead"
        },
        {
          "description": "No live web session or HUD access token, or the person's sign-in at their PDS ended: sign in.",
          "name": "AuthRequired"
        },
        {
          "description": "A PDS refused, could not be reached, or answered what does not check (a MAC, a repo's records).",
          "name": "UpstreamFailure"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "ref": "#instance",
          "type": "ref"
        }
      },
      "parameters": {
        "properties": {
          "app": {
            "description": "The app it must run, its authority a DID or a handle: an instance of another app is not found.",
            "format": "at-uri",
            "type": "string"
          },
          "authority": {
            "description": "Who made it, by DID or handle, with key, in place of instance: as its page's address names it.",
            "format": "at-identifier",
            "type": "string"
          },
          "instance": {
            "description": "The instance's space, at:space/<authority DID>/place.hud.app.instance/<key>. Or give authority and key.",
            "format": "at-uri",
            "type": "string"
          },
          "key": {
            "description": "Its space's key, a TID, with authority.",
            "format": "record-key",
            "type": "string"
          }
        },
        "type": "params"
      },
      "type": "query"
    },
    "member": {
      "description": "A member of a private instance, as its authority published them.",
      "properties": {
        "cannotRead": {
          "description": "Why they can't read it, once HUD found their PDS gives no delegation token (it does not offer spaces). Left out where HUD knows of nothing in the way.",
          "maxLength": 300,
          "type": "string"
        },
        "did": {
          "format": "did",
          "type": "string"
        },
        "handle": {
          "description": "Their handle, verified, where known.",
          "maxLength": 253,
          "type": "string"
        },
        "write": {
          "description": "Whether they write in it, as the app's writers do; else they read it alone.",
          "type": "boolean"
        }
      },
      "required": [
        "did",
        "write"
      ],
      "type": "object"
    }
  },
  "description": "A private instance of a frame app, as its members see it.",
  "id": "place.hud.getInstance",
  "lexicon": 1
}
