{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/immix/json-schema/immix-me-schema.json",
  "title": "Me",
  "description": "Your own row joined to your organisation: the fields and spellings the user row serves, with the organisation's name, `requiredApprovals` and `isInternalPlatform`.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/immix-users-api-openapi.yml#/components/schemas/Me",
  "type": "object",
  "properties": {
    "userId": {
      "type": "integer",
      "description": "Sticky entity key."
    },
    "orgId": {
      "type": "integer",
      "description": "Membership — stamped by the owner from the actor's org, or from the discovery's parent ref."
    },
    "orgName": {
      "type": "string",
      "description": "Natural key — unique among live orgs."
    },
    "name": {
      "type": "string",
      "description": "Platform name — per-org unique among live users with a non-empty name; empty until admission."
    },
    "displayName": {
      "type": "string",
      "description": "What the IdP stated at discovery (the name, else email, else nickname claim); informational, never a key."
    },
    "kind": {
      "$ref": "#/$defs/MeKind",
      "description": "UNKNOWN is the unset sentinel: outputs only — as input, omit the field instead; explicit UNKNOWN refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as UNKNOWN, never as an error; as input an unknown name refuses 400 — the parse is strict"
    },
    "status": {
      "$ref": "#/$defs/MeStatus",
      "description": "UNKNOWN is the unset sentinel: outputs only — as input, omit the field instead; explicit UNKNOWN refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as UNKNOWN, never as an error; as input an unknown name refuses 400 — the parse is strict"
    },
    "capabilities": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MeCapabilitiesItem"
      },
      "description": "The user's capabilities — what they may do; empty on a discovered row, and on an invited first administrator until the organisation is activated. a set (SBE bit-set) served as the array of its scope strings — each choice spelled <route family>:<verb> (the schema's camel-cased choice name de-camelled: accountAddressesApprove is account-addresses:approve) — in declared order; empty = none set, never null. The choice set is append-only: a consumer READING this field skips an unknown name, never errors; as input an unknown or repeated name refuses 400 — the parse is strict"
    },
    "requiredApprovals": {
      "type": "integer",
      "minimum": 0,
      "maximum": 255,
      "description": "Approvals a maker-checker mutation in this organisation needs: 1 = a second user's approval (dual control); 0 = the maker's own write is the concluded record; 2+ reserved (refused INVALID_FIELD). Set at bootstrap or activation; no command changes it on a live organisation. uint8: an integer 0..255"
    },
    "isInternalPlatform": {
      "type": "boolean",
      "description": "TRUE on exactly one org — the org that runs the platform. Set by BootstrapInternalPlatformOrg, never client-supplied. a boolean; absent reads false"
    },
    "globalSequence": {
      "$ref": "#/$defs/GlobalSequenceValue"
    }
  },
  "required": [
    "userId",
    "orgId",
    "orgName",
    "name",
    "displayName",
    "kind",
    "status",
    "capabilities",
    "requiredApprovals",
    "isInternalPlatform",
    "globalSequence"
  ],
  "$defs": {
    "GlobalSequenceValue": {
      "type": "string",
      "pattern": "^[0-9]+$",
      "description": "The position as a decimal string — the last change this member had applied, orders, balance readings and algo instances included.",
      "title": "GlobalSequenceValue"
    },
    "MeCapabilitiesItem": {
      "type": "string",
      "enum": [
        "users:manage",
        "credentials:propose",
        "credentials:approve",
        "accounts:propose",
        "accounts:approve",
        "account-addresses:propose",
        "account-addresses:approve",
        "portfolios:manage",
        "asset-policies:propose",
        "asset-policies:approve",
        "chain-policies:propose",
        "chain-policies:approve",
        "trading-policies:propose",
        "trading-policies:approve",
        "orders:trade",
        "orgs:propose",
        "orgs:approve",
        "algos:manage"
      ],
      "title": "MeCapabilitiesItem"
    },
    "MeKind": {
      "type": "string",
      "enum": [
        "UNKNOWN",
        "HUMAN",
        "SERVICE"
      ],
      "description": "UNKNOWN is the unset sentinel: outputs only — as input, omit the field instead; explicit UNKNOWN refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as UNKNOWN, never as an error; as input an unknown name refuses 400 — the parse is strict",
      "title": "MeKind"
    },
    "MeStatus": {
      "type": "string",
      "enum": [
        "UNKNOWN",
        "DISCOVERED",
        "ACTIVE",
        "DISABLED",
        "INVITED"
      ],
      "description": "UNKNOWN is the unset sentinel: outputs only — as input, omit the field instead; explicit UNKNOWN refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as UNKNOWN, never as an error; as input an unknown name refuses 400 — the parse is strict",
      "title": "MeStatus"
    }
  }
}