{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google-chat-integrations-for-workspace/json-schema/google-chat-integrations-for-workspace-membership-schema.json",
  "title": "Membership",
  "description": "Represents a membership relation in Google Chat, such as whether a user or Chat app is invited to, part of, or absent from a space.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-chat-integrations-for-workspace-spaces-api-openapi.yml#/components/schemas/Membership",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "Identifier. Resource name of the membership, assigned by the server. Format: `spaces/{space}/members/{member}`"
    },
    "deleteTime": {
      "type": "string",
      "description": "Optional. Immutable. The deletion time of the membership, such as when a member left or was removed from a space. This field is output only, except when used to import historical memberships in import mode spaces.",
      "format": "google-datetime"
    },
    "member": {
      "$ref": "#/$defs/User",
      "description": "Optional. The Google Chat user or app the membership corresponds to. If your Chat app [authenticates as a user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), the output only populates the [user](https://developers.google.com/workspace/chat/api/reference/rest/v1/User) `name` and `type` fields for both internal and external users, unless they are members of the space or have a prior affinity, like a direct message (DM) conversation, with the calling user."
    },
    "groupMember": {
      "$ref": "#/$defs/Group",
      "description": "Optional. The Google Group the membership corresponds to. Reading or mutating memberships for Google Groups requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)."
    },
    "state": {
      "enum": [
        "MEMBERSHIP_STATE_UNSPECIFIED",
        "JOINED",
        "INVITED",
        "NOT_A_MEMBER"
      ],
      "readOnly": true,
      "description": "Output only. State of the membership.",
      "type": "string"
    },
    "affiliation": {
      "type": "string",
      "readOnly": true,
      "description": "Output only. A user's relationship to the Workspace organization that owns the space. In spaces owned by consumer accounts, the affiliation of all members is `EXTERNAL`.",
      "enum": [
        "AFFILIATION_UNSPECIFIED",
        "INTERNAL",
        "EXTERNAL",
        "MANAGED_EXTERNAL"
      ]
    },
    "role": {
      "type": "string",
      "description": "Optional. User's role within a Chat space, which determines their permitted actions in the space. This field can only be used as input in `UpdateMembership`.",
      "enum": [
        "MEMBERSHIP_ROLE_UNSPECIFIED",
        "ROLE_MEMBER",
        "ROLE_MANAGER",
        "ROLE_ASSISTANT_MANAGER"
      ]
    },
    "createTime": {
      "description": "Optional. Immutable. The creation time of the membership, such as when a member joined or was invited to join a space. This field is output only, except when used to import historical memberships in import mode spaces.",
      "type": "string",
      "format": "google-datetime"
    }
  },
  "$defs": {
    "Group": {
      "description": "A Google Group in Google Chat.",
      "type": "object",
      "properties": {
        "name": {
          "description": "Resource name for a Google Group. Represents a [group](https://cloud.google.com/identity/docs/reference/rest/v1/groups) in Cloud Identity Groups API. Format: groups/{group}",
          "type": "string"
        }
      }
    },
    "User": {
      "description": "If your Chat app [authenticates as a user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), the output for a `User` resource (such as in the Messages and Memberships APIs) only populates the `name` and `type` fields for both internal and external users, unless they are members of the space or have prior affinity with the calling user.",
      "properties": {
        "displayName": {
          "readOnly": true,
          "type": "string",
          "description": "Output only. The user's display name. Populated for both app authentication and user authentication. This field is always populated for requests made with [app authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app). When calling the Messages and Memberships APIs with [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), this field is populated for both internal and external users for the `sender` of a message, users within `annotations` (such as user mentions), and within `Membership` resources, provided the user is a member of the space or has prior affinity with the calling user."
        },
        "type": {
          "enum": [
            "TYPE_UNSPECIFIED",
            "HUMAN",
            "BOT"
          ],
          "type": "string",
          "description": "User type."
        },
        "name": {
          "type": "string",
          "description": "Resource name for a Google Chat user. Format: `users/{user}`. `users/app` can be used as an alias for the calling app bot user. For human users, `{user}` is the same user identifier as: - the `id` for the [Person](https://developers.google.com/people/api/rest/v1/people) in the People API. For example, `users/123456789` in Chat API represents the same person as the `123456789` Person profile ID in People API. - the `id` for a [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) in the Admin SDK Directory API. - the user's email address can be used as an alias for `{user}` in API requests. For example, if the People API Person profile ID for `user@example.com` is `123456789`, you can use `users/user@example.com` as an alias to reference `users/123456789`. Only the canonical resource name (for example `users/123456789`) will be returned from the API."
        },
        "avatarUrl": {
          "readOnly": true,
          "type": "string",
          "description": "Output only. The user's avatar image URL. When calling the Messages and Memberships APIs with [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), this field is populated for both internal and external users for the `sender` of a message, users within `annotations` (such as user mentions), and within `Membership` resources, provided the user is a member of the space or has prior affinity with the calling user."
        },
        "email": {
          "type": "string",
          "description": "Output only. The user's email address. When calling the Messages and Memberships APIs with [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), this field is populated for both internal and external users for the `sender` of a message, users within `annotations` (such as user mentions), and within `Membership` resources, provided the user is a member of the space or has prior affinity with the calling user.",
          "readOnly": true
        },
        "domainId": {
          "description": "Unique identifier of the user's Google Workspace domain.",
          "type": "string"
        },
        "isAnonymous": {
          "readOnly": true,
          "type": "boolean",
          "description": "Output only. When `true`, the user is deleted or their profile is not visible, such as when a user is mentioned in a space without being a member and without prior affinity with the calling user."
        }
      },
      "type": "object"
    }
  }
}