{
  "$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-create-or-update-schema.json",
  "title": "RouterJobCreateOrUpdate",
  "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/RouterJobCreateOrUpdate",
  "type": "object",
  "properties": {
    "channelReference": {
      "type": "string",
      "description": "Reference to an external parent context, eg. call ID."
    },
    "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"
      }
    },
    "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 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"
      }
    },
    "matchingMode": {
      "$ref": "#/$defs/JobMatchingModeCreateOrUpdate",
      "description": "If provided, will determine how job matching will be carried out. Default mode: QueueAndMatchMode."
    }
  },
  "$defs": {
    "JobMatchingModeCreateOrUpdate": {
      "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."
          }
        ]
      }
    },
    "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"
      ]
    },
    "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."
          }
        ]
      }
    }
  }
}