{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ivans/json-schema/ivans-market-credential-schema.json",
  "title": "MarketCredential",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ivans-market-credentials-api-openapi.yml#/components/schemas/MarketCredential",
  "type": "object",
  "properties": {
    "uuid": {
      "type": "string",
      "format": "uuid",
      "readOnly": true
    },
    "nickname": {
      "type": "string",
      "maxLength": 128
    },
    "username": {
      "type": "string",
      "maxLength": 128
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "lastModifiedBy": {
      "$ref": "#/$defs/SimpleUser"
    },
    "marketConfiguration": {
      "type": "string"
    },
    "user": {
      "$ref": "#/$defs/SimpleUser"
    },
    "accessStructures": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/StructureAccess"
      }
    },
    "lastUsedOn": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "required": [
    "accessStructures",
    "lastModifiedBy",
    "marketConfiguration",
    "nickname",
    "updatedAt",
    "user",
    "username",
    "uuid"
  ],
  "$defs": {
    "SimpleUser": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "integratorUserId": {
          "type": "string"
        },
        "name": {
          "type": "string",
          "readOnly": true
        },
        "externalId": {
          "type": "string",
          "description": "Unique identifier from external system. Used to identify agents.",
          "maxLength": 64
        }
      },
      "required": [
        "id",
        "integratorUserId",
        "name"
      ]
    },
    "StructureAccess": {
      "type": "object",
      "properties": {
        "agency": {
          "$ref": "#/$defs/StructureChild"
        },
        "branch": {
          "$ref": "#/$defs/StructureChild"
        },
        "department": {
          "$ref": "#/$defs/StructureChild"
        },
        "businessUnit": {
          "$ref": "#/$defs/StructureChild"
        }
      },
      "required": [
        "agency",
        "branch",
        "businessUnit",
        "department"
      ]
    },
    "StructureChild": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "id",
        "name"
      ]
    }
  }
}