{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hjarni-com/json-schema/hjarni-com-me-schema.json",
  "title": "Me",
  "description": "`onboarding`, `teams`, `limits` and `suggestions` are present for a full-access token and absent for an agent token.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hjarni-com-openapi.json#/components/schemas/Me",
  "type": "object",
  "required": [
    "user",
    "token"
  ],
  "properties": {
    "user": {
      "$ref": "#/$defs/MeUser"
    },
    "token": {
      "$ref": "#/$defs/MeToken"
    },
    "onboarding": {
      "$ref": "#/$defs/Onboarding"
    },
    "teams": {
      "type": "array",
      "description": "Teams the person belongs to, by name.",
      "items": {
        "$ref": "#/$defs/TeamMembershipInfo"
      }
    },
    "limits": {
      "$ref": "#/$defs/Limits"
    },
    "suggestions": {
      "type": "object",
      "required": [
        "create_team"
      ],
      "properties": {
        "create_team": {
          "type": "boolean",
          "description": "True when the person is a good fit to be offered a team."
        }
      }
    }
  },
  "$defs": {
    "AgentGrantInfo": {
      "type": "object",
      "description": "One folder an agent token was given.",
      "required": [
        "container_id",
        "name",
        "team_id",
        "level",
        "effective"
      ],
      "properties": {
        "container_id": {
          "type": "integer"
        },
        "name": {
          "type": "string",
          "description": "The folder's name, or for a space's root the team's name or \"Personal\"."
        },
        "team_id": {
          "type": [
            "integer",
            "null"
          ]
        },
        "level": {
          "type": "string",
          "enum": [
            "read",
            "write"
          ],
          "description": "What was granted. Everything below the folder inherits it unless another grant says otherwise."
        },
        "effective": {
          "type": "string",
          "enum": [
            "none",
            "read",
            "write"
          ],
          "description": "What the token can do there now, after the person's own role caps it."
        }
      }
    },
    "ContainerRef": {
      "type": "object",
      "required": [
        "id",
        "name"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "Limits": {
      "type": "object",
      "description": "Personal allowances; a null limit means unlimited.",
      "required": [
        "notes_used",
        "notes_limit",
        "file_storage_bytes_used",
        "file_storage_bytes_limit",
        "files_used",
        "files_limit"
      ],
      "properties": {
        "notes_used": {
          "type": "integer"
        },
        "notes_limit": {
          "type": [
            "integer",
            "null"
          ]
        },
        "file_storage_bytes_used": {
          "type": "integer"
        },
        "file_storage_bytes_limit": {
          "type": [
            "integer",
            "null"
          ]
        },
        "files_used": {
          "type": "integer"
        },
        "files_limit": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "MeToken": {
      "type": "object",
      "description": "The token making the request. `instructions`, `follows_brain_instructions` and `grants` appear only for an agent token (`restricted: true`).",
      "required": [
        "id",
        "name",
        "restricted",
        "scope_container"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "restricted": {
          "type": "boolean",
          "description": "True for an agent token, which reaches only its grants."
        },
        "scope_container": {
          "description": "Kept for older clients: the folder when the token holds exactly one grant and it is write, otherwise null. Read `grants` instead.",
          "oneOf": [
            {
              "$ref": "#/$defs/ContainerRef"
            },
            {
              "type": "null"
            }
          ]
        },
        "instructions": {
          "type": "string",
          "description": "What the person wrote for this agent; an empty string when nothing."
        },
        "follows_brain_instructions": {
          "type": "boolean",
          "description": "Whether this agent should also follow the person's brain-wide instructions (the API does not serve those to agent tokens)."
        },
        "grants": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AgentGrantInfo"
          }
        }
      }
    },
    "MeUser": {
      "type": "object",
      "required": [
        "id",
        "first_name",
        "email_address",
        "plan",
        "email"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "first_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "email_address": {
          "type": "string",
          "format": "email"
        },
        "plan": {
          "type": "string",
          "description": "The stored plan name, \"free\" or \"pro\"."
        },
        "email": {
          "type": "string",
          "format": "email",
          "deprecated": true,
          "description": "Same as email_address, kept for older clients."
        }
      }
    },
    "Onboarding": {
      "type": "object",
      "required": [
        "completed",
        "completed_at",
        "signals",
        "missing_steps"
      ],
      "properties": {
        "completed": {
          "type": "boolean"
        },
        "completed_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "signals": {
          "type": "object",
          "required": [
            "connected_mcp",
            "has_real_notes",
            "has_custom_instructions",
            "team_brain_available"
          ],
          "properties": {
            "connected_mcp": {
              "type": "boolean"
            },
            "has_real_notes": {
              "type": "boolean"
            },
            "has_custom_instructions": {
              "type": "boolean"
            },
            "team_brain_available": {
              "type": "boolean"
            }
          }
        },
        "missing_steps": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "connect_mcp",
              "first_note"
            ]
          }
        },
        "next_action": {
          "type": "string",
          "description": "Setup guidance for an assistant, present only while setup is incomplete and a first note is the gap."
        }
      }
    },
    "TeamMembershipInfo": {
      "type": "object",
      "required": [
        "id",
        "name",
        "role",
        "notes_used",
        "notes_limit"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "role": {
          "type": "string",
          "enum": [
            "owner",
            "member"
          ]
        },
        "notes_used": {
          "type": "integer"
        },
        "notes_limit": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Null when the team has no limit."
        }
      }
    }
  }
}