{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/permitio/json-schema/permitio-relationship-tuple-read-schema.json",
  "title": "RelationshipTupleRead",
  "x-generated": "2026-11-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/permitio-openapi.json#/components/schemas/RelationshipTupleRead",
  "properties": {
    "subject": {
      "type": "string",
      "title": "Subject",
      "description": "resource_key:resource_instance_key of the subject"
    },
    "relation": {
      "type": "string",
      "title": "Relation",
      "description": "key of the assigned relation"
    },
    "object": {
      "type": "string",
      "title": "Object",
      "description": "resource_key:resource_instance_key of the object"
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id",
      "description": "Unique id of the relationship tuple"
    },
    "tenant": {
      "type": "string",
      "title": "Tenant",
      "description": "The tenant the relationship tuple is associated with"
    },
    "subject_id": {
      "type": "string",
      "format": "uuid",
      "title": "Subject Id",
      "description": "Unique id of the subject"
    },
    "relation_id": {
      "type": "string",
      "format": "uuid",
      "title": "Relation Id",
      "description": "Unique id of the relation"
    },
    "object_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Object Id",
      "description": "Unique id of the object (null = all resources of this type)"
    },
    "tenant_id": {
      "type": "string",
      "format": "uuid",
      "title": "Tenant Id",
      "description": "Unique id of the tenant"
    },
    "organization_id": {
      "type": "string",
      "format": "uuid",
      "title": "Organization Id",
      "description": "Unique id of the organization that the relationship tuple belongs to."
    },
    "project_id": {
      "type": "string",
      "format": "uuid",
      "title": "Project Id",
      "description": "Unique id of the project that the relationship tuple belongs to."
    },
    "environment_id": {
      "type": "string",
      "format": "uuid",
      "title": "Environment Id",
      "description": "Unique id of the environment that the relationship tuple belongs to."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "Date and time when the relationship tuple was created (ISO_8601 format)."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At",
      "description": "Date and time when the relationship tuple was created (ISO_8601 format)."
    },
    "subject_details": {
      "anyOf": [
        {
          "$ref": "#/$defs/ResourceInstanceBlockRead"
        },
        {
          "type": "null"
        }
      ],
      "description": "The subject details of the relationship tuple"
    },
    "relation_details": {
      "anyOf": [
        {
          "$ref": "#/$defs/StrippedRelationBlockRead"
        },
        {
          "type": "null"
        }
      ],
      "description": "The relation details of the relationship tuple"
    },
    "object_details": {
      "anyOf": [
        {
          "$ref": "#/$defs/ResourceInstanceBlockRead"
        },
        {
          "type": "null"
        }
      ],
      "description": "The object details of the relationship tuple"
    },
    "tenant_details": {
      "anyOf": [
        {
          "$ref": "#/$defs/TenantBlockRead"
        },
        {
          "type": "null"
        }
      ],
      "description": "The tenant details of the relationship tuple"
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "subject",
    "relation",
    "object",
    "id",
    "tenant",
    "subject_id",
    "relation_id",
    "tenant_id",
    "organization_id",
    "project_id",
    "environment_id",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "ResourceInstanceBlockRead": {
      "properties": {
        "key": {
          "type": "string",
          "title": "Key",
          "description": "A unique identifier by which Permit will identify the resource instance for permission checks. You will later pass this identifier to the `permit.check()` API. A key can be anything: for example the resource db id, a url slug, a UUID or anything else as long as it's unique on your end. The resource instance key must be url-friendly."
        },
        "tenant": {
          "type": "string",
          "title": "Tenant",
          "description": "the *key* of the tenant that this resource belongs to, used to enforce tenant boundaries in multi-tenant apps."
        },
        "resource": {
          "type": "string",
          "title": "Resource",
          "description": "the *key* of the resource (type) of this resource instance. For example: if this resource instance is the annual budget document, the key of the resource might be `document`."
        },
        "attributes": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Attributes",
          "description": "Arbitrary resource attributes that will be used to enforce attribute-based access control policies.",
          "default": {}
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "key",
        "tenant",
        "resource"
      ],
      "title": "ResourceInstanceBlockRead"
    },
    "StrippedRelationBlockRead": {
      "properties": {
        "key": {
          "type": "string",
          "title": "Key",
          "description": "A URL-friendly name of the relation (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the relation."
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The name of the relation"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description",
          "description": "An optional longer description of what this relation represents in your system"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "key",
        "name"
      ],
      "title": "StrippedRelationBlockRead"
    },
    "TenantBlockRead": {
      "properties": {
        "key": {
          "type": "string",
          "title": "Key",
          "description": "A unique id by which Permit will identify the tenant. The tenant key must be url-friendly (slugified)."
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "A descriptive name for the tenant"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description",
          "description": "an optional longer description of the tenant"
        },
        "attributes": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Attributes",
          "description": "Arbitraty tenant attributes that will be used to enforce attribute-based access control policies.",
          "default": {}
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "key",
        "name"
      ],
      "title": "TenantBlockRead"
    }
  }
}