{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/api-gouv-fr/json-schema/api-gouv-fr-membership-request-schema.json",
  "title": "MembershipRequest",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/api-gouv-fr-organizations-api-openapi.yml#/components/schemas/MembershipRequest",
  "properties": {
    "assignments": {
      "description": "Objects to assign on acceptance (for partial_editor invitations)",
      "items": {
        "$ref": "#/$defs/GenericReference"
      },
      "type": "array"
    },
    "comment": {
      "description": "A request comment from the user",
      "type": "string"
    },
    "created": {
      "description": "The request creation date",
      "format": "date-time",
      "readOnly": true,
      "type": "string"
    },
    "email": {
      "description": "Email for non-registered user invitations",
      "type": "string"
    },
    "id": {
      "readOnly": true,
      "type": "string"
    },
    "kind": {
      "default": "request",
      "description": "The request kind (request or invitation)",
      "enum": [
        "request",
        "invitation"
      ],
      "type": "string"
    },
    "role": {
      "default": "editor",
      "description": "The role to assign",
      "enum": [
        "admin",
        "editor",
        "partial_editor"
      ],
      "type": "string"
    },
    "status": {
      "description": "The current request status",
      "enum": [
        "pending",
        "accepted",
        "refused",
        "canceled"
      ],
      "type": "string"
    },
    "user": {
      "$ref": "#/$defs/UserReferenceWithEmail"
    }
  },
  "required": [
    "status"
  ],
  "type": "object",
  "$defs": {
    "BaseReference": {
      "properties": {
        "class": {
          "description": "The object class",
          "type": "string"
        },
        "id": {
          "description": "The object unique identifier",
          "type": "string"
        }
      },
      "required": [
        "class",
        "id"
      ],
      "type": "object"
    },
    "GenericReference": {
      "properties": {
        "class": {
          "type": "string"
        },
        "id": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "UserReference": {
      "allOf": [
        {
          "$ref": "#/$defs/BaseReference"
        },
        {
          "properties": {
            "avatar": {
              "description": "URL of the image",
              "readOnly": true,
              "type": "string"
            },
            "avatar_thumbnail": {
              "description": "URL of the cropped and squared image (500x500)",
              "readOnly": true,
              "type": "string"
            },
            "deleted": {
              "description": "The date the account was deleted, null for a live account",
              "format": "date-time",
              "readOnly": true,
              "type": "string"
            },
            "first_name": {
              "maxLength": 255,
              "type": "string"
            },
            "last_name": {
              "maxLength": 255,
              "type": "string"
            },
            "page": {
              "description": "Link to the udata web page for this user",
              "readOnly": true,
              "type": "string"
            },
            "slug": {
              "maxLength": 255,
              "readOnly": true,
              "type": "string"
            },
            "uri": {
              "description": "Link to the API endpoint for this user",
              "readOnly": true,
              "type": "string"
            }
          },
          "required": [
            "first_name",
            "last_name",
            "slug"
          ],
          "type": "object"
        }
      ]
    },
    "UserReferenceWithEmail": {
      "allOf": [
        {
          "$ref": "#/$defs/UserReference"
        },
        {
          "properties": {
            "email": {
              "description": "The user email, obfuscated unless the caller may see it",
              "readOnly": true,
              "type": "string"
            },
            "last_login_at": {
              "format": "date-time",
              "readOnly": true,
              "type": "string"
            }
          },
          "type": "object"
        }
      ]
    }
  }
}