{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/layout-link/json-schema/layout-link-whoami-schema.json",
  "title": "Whoami",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/layout-link-openapi.json#/components/schemas/Whoami",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "app"
        },
        "app": {
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/AppId"
            }
          },
          "required": [
            "id"
          ]
        },
        "environment": {
          "$ref": "#/$defs/Environment"
        },
        "approvalStatus": {
          "type": "string",
          "enum": [
            "pending",
            "approved",
            "denied",
            "suspended"
          ]
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "delivery": {
          "description": "Whether this credential can order delivery: for its application, in its environment. `false` means a cart asked for delivery builds a pickup that says why, and a build session refuses it. Absent while Layout has delivery off for every application.",
          "type": "boolean"
        }
      },
      "required": [
        "kind",
        "app",
        "environment",
        "approvalStatus",
        "scopes"
      ]
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "user"
        },
        "app": {
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/AppId"
            }
          },
          "required": [
            "id"
          ]
        },
        "environment": {
          "$ref": "#/$defs/Environment"
        },
        "user": {
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/UserId"
            }
          },
          "required": [
            "id"
          ]
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "delivery": {
          "description": "Whether this credential can order delivery: for its application, in its environment. `false` means a cart asked for delivery builds a pickup that says why, and a build session refuses it. Absent while Layout has delivery off for every application.",
          "type": "boolean"
        }
      },
      "required": [
        "kind",
        "app",
        "environment",
        "user",
        "scopes"
      ]
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "grant"
        },
        "app": {
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/AppId"
            }
          },
          "required": [
            "id"
          ]
        },
        "environment": {
          "$ref": "#/$defs/Environment"
        },
        "user": {
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/UserId"
            }
          },
          "required": [
            "id"
          ]
        },
        "scopes": {
          "description": "`build`: build, read and cancel this application's carts for the person. `confirm`: confirm them, with the person's order code whenever Layout asks for one.",
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "build",
              "confirm"
            ]
          }
        },
        "expiresAt": {
          "type": "string"
        },
        "delivery": {
          "description": "Whether this credential can order delivery: for its application, in its environment. `false` means a cart asked for delivery builds a pickup that says why, and a build session refuses it. Absent while Layout has delivery off for every application.",
          "type": "boolean"
        }
      },
      "required": [
        "kind",
        "app",
        "environment",
        "user",
        "scopes",
        "expiresAt"
      ]
    }
  ],
  "$defs": {
    "AppId": {
      "type": "string",
      "pattern": "^(?:lyt_app|app)_[0-9a-f]{8,64}$"
    },
    "Environment": {
      "type": "string",
      "enum": [
        "sandbox",
        "live"
      ]
    },
    "UserId": {
      "type": "string",
      "pattern": "^usr_[a-f0-9]{8,32}$"
    }
  }
}