{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/microsoft-azure-communication-services/json-schema/microsoft-azure-communication-services-router-worker-schema.json",
  "title": "RouterWorker",
  "description": "An entity for jobs to be routed to.",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/microsoft-azure-communication-services-jobrouter-api-openapi.yml#/components/schemas/RouterWorker",
  "type": "object",
  "properties": {
    "etag": {
      "$ref": "#/$defs/Azure.Core.eTag",
      "description": "The entity tag for this resource.",
      "readOnly": true
    },
    "id": {
      "type": "string",
      "description": "Id of a worker.",
      "readOnly": true
    },
    "state": {
      "$ref": "#/$defs/RouterWorkerState",
      "description": "Current state of a worker.",
      "readOnly": true
    },
    "queues": {
      "type": "array",
      "description": "Collection of queue(s) that this worker can receive work from.",
      "items": {
        "type": "string"
      }
    },
    "capacity": {
      "type": "integer",
      "format": "int32",
      "description": "The total capacity score this worker has to manage multiple concurrent jobs."
    },
    "labels": {
      "type": "object",
      "description": "A set of key/value pairs that are identifying attributes used by the rules engines to make decisions. Values must be primitive values - number, string, boolean.",
      "additionalProperties": {}
    },
    "tags": {
      "type": "object",
      "description": "A set of non-identifying attributes attached to this worker. Values must be primitive values - number, string, boolean.",
      "additionalProperties": {}
    },
    "channels": {
      "type": "array",
      "description": "Collection of channel(s) this worker can handle and their impact on the workers capacity.",
      "items": {
        "$ref": "#/$defs/RouterChannel"
      }
    },
    "offers": {
      "type": "array",
      "description": "A list of active offers issued to this worker.",
      "items": {
        "$ref": "#/$defs/RouterJobOffer"
      },
      "readOnly": true
    },
    "assignedJobs": {
      "type": "array",
      "description": "A list of assigned jobs attached to this worker.",
      "items": {
        "$ref": "#/$defs/RouterWorkerAssignment"
      },
      "readOnly": true
    },
    "loadRatio": {
      "type": "number",
      "format": "double",
      "description": "A value indicating the workers capacity. A value of '1' means all capacity is consumed. A value of '0' means no capacity is currently consumed.",
      "readOnly": true
    },
    "availableForOffers": {
      "type": "boolean",
      "description": "A flag indicating this worker is open to receive offers or not."
    }
  },
  "required": [
    "etag",
    "id"
  ],
  "$defs": {
    "Azure.Core.eTag": {
      "type": "string",
      "description": "The ETag (or entity tag) HTTP response header is an identifier for a specific version of a resource.\nIt lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content was not changed.\n\nIt is a string of ASCII characters placed between double quotes, like \"675af34563dc-tr34\"."
    },
    "RouterChannel": {
      "type": "object",
      "description": "Represents the capacity a job in this channel will consume from a worker.",
      "properties": {
        "channelId": {
          "type": "string",
          "description": "Id of a channel."
        },
        "capacityCostPerJob": {
          "type": "integer",
          "format": "int32",
          "description": "The amount of capacity that an instance of a job of this channel will consume of the total worker capacity."
        },
        "maxNumberOfJobs": {
          "type": "integer",
          "format": "int32",
          "description": "The maximum number of jobs that can be supported concurrently for this channel. Value must be greater than zero."
        }
      },
      "required": [
        "channelId",
        "capacityCostPerJob"
      ]
    },
    "RouterJobOffer": {
      "type": "object",
      "description": "An offer of a job to a worker.",
      "properties": {
        "offerId": {
          "type": "string",
          "description": "Id of an offer.",
          "readOnly": true
        },
        "jobId": {
          "type": "string",
          "description": "Id of the job."
        },
        "capacityCost": {
          "type": "integer",
          "format": "int32",
          "description": "The capacity cost consumed by the job offer."
        },
        "offeredAt": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the offer was created in UTC."
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the offer will expire in UTC."
        }
      },
      "required": [
        "offerId",
        "jobId",
        "capacityCost"
      ]
    },
    "RouterWorkerAssignment": {
      "type": "object",
      "description": "The assignment for a worker to a job.",
      "properties": {
        "assignmentId": {
          "type": "string",
          "description": "Id of the assignment."
        },
        "jobId": {
          "type": "string",
          "description": "Id of the job assigned."
        },
        "capacityCost": {
          "type": "integer",
          "format": "int32",
          "description": "The amount of capacity this assignment has consumed on the worker."
        },
        "assignedAt": {
          "type": "string",
          "format": "date-time",
          "description": "The assignment time of the job in UTC."
        }
      },
      "required": [
        "assignmentId",
        "jobId",
        "capacityCost",
        "assignedAt"
      ]
    },
    "RouterWorkerState": {
      "type": "string",
      "description": "Enums for worker states.",
      "enum": [
        "active",
        "draining",
        "inactive"
      ],
      "x-ms-enum": {
        "name": "RouterWorkerState",
        "modelAsString": true,
        "values": [
          {
            "name": "active",
            "value": "active",
            "description": "Worker is active and available to take offers."
          },
          {
            "name": "draining",
            "value": "draining",
            "description": "Worker is not active, if there are existing offers they are being revoked. No new offers are sent."
          },
          {
            "name": "inactive",
            "value": "inactive",
            "description": "Worker is not active. No new offers are sent."
          }
        ]
      }
    }
  }
}