{
  "$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-job-schema.json",
  "title": "RouterJob",
  "description": "A unit of work to be routed",
  "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/RouterJob",
  "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 job.",
      "readOnly": true
    },
    "channelReference": {
      "type": "string",
      "description": "Reference to an external parent context, eg. call ID."
    },
    "status": {
      "$ref": "#/$defs/RouterJobStatus",
      "description": "The status of the job.",
      "readOnly": true
    },
    "enqueuedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp a job was queued in UTC.",
      "readOnly": true
    },
    "channelId": {
      "type": "string",
      "description": "The channel identifier. eg. voice, chat, etc."
    },
    "classificationPolicyId": {
      "type": "string",
      "description": "Id of a classification policy used for classifying this job."
    },
    "queueId": {
      "type": "string",
      "description": "Id of a queue that this job is queued to."
    },
    "priority": {
      "type": "integer",
      "format": "int32",
      "description": "Priority of this job. Value must be between -100 to 100."
    },
    "dispositionCode": {
      "type": "string",
      "description": "Reason code for cancelled or closed jobs."
    },
    "requestedWorkerSelectors": {
      "type": "array",
      "description": "A collection of manually specified worker selectors, which a worker must satisfy in order to process this job.",
      "items": {
        "$ref": "#/$defs/RouterWorkerSelector"
      }
    },
    "attachedWorkerSelectors": {
      "type": "array",
      "description": "A collection of worker selectors attached by a classification policy, which a worker must satisfy in order to process this job.",
      "items": {
        "$ref": "#/$defs/RouterWorkerSelector"
      },
      "readOnly": true
    },
    "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": {}
    },
    "assignments": {
      "type": "object",
      "description": "A collection of the assignments of the job. Key is AssignmentId.",
      "additionalProperties": {
        "$ref": "#/$defs/RouterJobAssignment"
      },
      "readOnly": true
    },
    "tags": {
      "type": "object",
      "description": "A set of non-identifying attributes attached to this job. Values must be primitive values - number, string, boolean.",
      "additionalProperties": {}
    },
    "notes": {
      "type": "array",
      "description": "Notes attached to a job, sorted by timestamp.",
      "items": {
        "$ref": "#/$defs/RouterJobNote"
      }
    },
    "scheduledAt": {
      "type": "string",
      "format": "date-time",
      "description": "If set, job will be scheduled to be enqueued at a given time.",
      "readOnly": true
    },
    "matchingMode": {
      "$ref": "#/$defs/JobMatchingMode",
      "description": "If provided, will determine how job matching will be carried out. Default mode: QueueAndMatchMode."
    }
  },
  "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\"."
    },
    "JobMatchingMode": {
      "type": "object",
      "description": "A matching mode of one of the following types:\nQueueAndMatchMode: Used when matching worker to a job is required to be done right after job is queued.\nScheduleAndSuspendMode: Used for scheduling jobs to be queued at a future time. At specified time, matching of a worker to the job will not start automatically.\nSuspendMode: Used when matching workers to a job needs to be suspended.",
      "properties": {
        "kind": {
          "$ref": "#/$defs/JobMatchingModeKind",
          "description": "The type discriminator describing a sub-type of JobMatchingMode."
        }
      },
      "required": [
        "kind"
      ]
    },
    "JobMatchingModeKind": {
      "type": "string",
      "description": "Discriminators for supported matching mode types.",
      "enum": [
        "queueAndMatch",
        "scheduleAndSuspend",
        "suspend"
      ],
      "x-ms-enum": {
        "name": "JobMatchingModeKind",
        "modelAsString": true,
        "values": [
          {
            "name": "queueAndMatch",
            "value": "queueAndMatch",
            "description": "Discriminator value for QueueAndMatchMode."
          },
          {
            "name": "scheduleAndSuspend",
            "value": "scheduleAndSuspend",
            "description": "Discriminator value for ScheduleAndSuspendMode."
          },
          {
            "name": "suspend",
            "value": "suspend",
            "description": "Discriminator value for SuspendMode."
          }
        ]
      }
    },
    "LabelOperator": {
      "type": "string",
      "description": "Describes supported operations on label values.",
      "enum": [
        "equal",
        "notEqual",
        "lessThan",
        "lessThanOrEqual",
        "greaterThan",
        "greaterThanOrEqual"
      ],
      "x-ms-enum": {
        "name": "LabelOperator",
        "modelAsString": true,
        "values": [
          {
            "name": "equal",
            "value": "equal",
            "description": "Equal."
          },
          {
            "name": "notEqual",
            "value": "notEqual",
            "description": "Not Equal."
          },
          {
            "name": "lessThan",
            "value": "lessThan",
            "description": "Less than."
          },
          {
            "name": "lessThanOrEqual",
            "value": "lessThanOrEqual",
            "description": "Less than or equal."
          },
          {
            "name": "greaterThan",
            "value": "greaterThan",
            "description": "Greater than."
          },
          {
            "name": "greaterThanOrEqual",
            "value": "greaterThanOrEqual",
            "description": "Greater than or equal."
          }
        ]
      }
    },
    "RouterJobAssignment": {
      "type": "object",
      "description": "Assignment details of a job to a worker.",
      "properties": {
        "assignmentId": {
          "type": "string",
          "description": "Id of a job assignment.",
          "readOnly": true
        },
        "workerId": {
          "type": "string",
          "description": "Id of the Worker assigned to the job."
        },
        "assignedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the job was assigned to a worker in UTC."
        },
        "completedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the job was marked as completed after being assigned in UTC."
        },
        "closedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the job was marked as closed after being completed in UTC."
        }
      },
      "required": [
        "assignmentId",
        "assignedAt"
      ]
    },
    "RouterJobNote": {
      "type": "object",
      "description": "A note attached to a job.",
      "properties": {
        "message": {
          "type": "string",
          "description": "The message contained in the note."
        },
        "addedAt": {
          "type": "string",
          "format": "date-time",
          "description": "The time at which the note was added in UTC. If not provided, will default to the current time."
        }
      },
      "required": [
        "message"
      ]
    },
    "RouterJobStatus": {
      "type": "string",
      "description": "Describes the various status of a job.",
      "enum": [
        "pendingClassification",
        "queued",
        "assigned",
        "completed",
        "closed",
        "cancelled",
        "classificationFailed",
        "created",
        "pendingSchedule",
        "scheduled",
        "scheduleFailed",
        "waitingForActivation"
      ],
      "x-ms-enum": {
        "name": "RouterJobStatus",
        "modelAsString": true,
        "values": [
          {
            "name": "pendingClassification",
            "value": "pendingClassification",
            "description": "Job is waiting to be classified."
          },
          {
            "name": "queued",
            "value": "queued",
            "description": "Job has been queued."
          },
          {
            "name": "assigned",
            "value": "assigned",
            "description": "Job has been assigned to a worker."
          },
          {
            "name": "completed",
            "value": "completed",
            "description": "Job has been completed by a worker."
          },
          {
            "name": "closed",
            "value": "closed",
            "description": "Job has been closed by a worker."
          },
          {
            "name": "cancelled",
            "value": "cancelled",
            "description": "Job has been cancelled."
          },
          {
            "name": "classificationFailed",
            "value": "classificationFailed",
            "description": "Classification process failed for the job."
          },
          {
            "name": "created",
            "value": "created",
            "description": "Job has been created."
          },
          {
            "name": "pendingSchedule",
            "value": "pendingSchedule",
            "description": "Job has been created but not been scheduled yet."
          },
          {
            "name": "scheduled",
            "value": "scheduled",
            "description": "Job has been scheduled successfully."
          },
          {
            "name": "scheduleFailed",
            "value": "scheduleFailed",
            "description": "Job scheduling failed."
          },
          {
            "name": "waitingForActivation",
            "value": "waitingForActivation",
            "description": "Job is in a suspended state and waiting for an update."
          }
        ]
      }
    },
    "RouterWorkerSelector": {
      "type": "object",
      "description": "Describes a condition that must be met against a set of labels for worker selection.",
      "properties": {
        "key": {
          "type": "string",
          "description": "The label key to query against."
        },
        "labelOperator": {
          "$ref": "#/$defs/LabelOperator",
          "description": "Describes how the value of the label is compared to the value defined on the worker selector."
        },
        "value": {
          "description": "The value to compare against the actual label value with the given operator. Values must be primitive values - number, string, boolean."
        },
        "expiresAfterSeconds": {
          "type": "number",
          "format": "double",
          "description": "Describes how long this label selector is valid in seconds."
        },
        "expedite": {
          "type": "boolean",
          "description": "Pushes a job to the front of the queue as long as this selector is active."
        },
        "status": {
          "$ref": "#/$defs/RouterWorkerSelectorStatus",
          "description": "Status of the worker selector.",
          "readOnly": true
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time",
          "description": "The time at which this worker selector expires in UTC.",
          "readOnly": true
        }
      },
      "required": [
        "key",
        "labelOperator"
      ]
    },
    "RouterWorkerSelectorStatus": {
      "type": "string",
      "description": "Describes the status of a worker selector.",
      "enum": [
        "active",
        "expired"
      ],
      "x-ms-enum": {
        "name": "RouterWorkerSelectorStatus",
        "modelAsString": true,
        "values": [
          {
            "name": "active",
            "value": "active",
            "description": "Worker selector is valid."
          },
          {
            "name": "expired",
            "value": "expired",
            "description": "Worker selector is not valid."
          }
        ]
      }
    }
  }
}