{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://automationanywhere.com/schemas/work-item.json",
  "title": "Automation Anywhere Work Item",
  "description": "Schema representing a work item within the Automation Anywhere Workload Management system. A work item is a single unit of data queued for processing by an RPA bot, with a typed payload defined by the queue's work item model and lifecycle status tracking from creation through completion.",
  "type": "object",
  "required": ["queueId"],
  "properties": {
    "id": {
      "type": "integer",
      "description": "Unique numeric identifier of the work item assigned by the Control Room upon creation"
    },
    "queueId": {
      "type": "integer",
      "description": "Numeric ID of the Workload Management queue this work item belongs to"
    },
    "json": {
      "type": "object",
      "description": "Key-value data payload of the work item. Keys are attribute names defined in the queue's work item model; values are the actual data to be processed by the bot.",
      "additionalProperties": true
    },
    "status": {
      "type": "string",
      "description": "Current lifecycle status of the work item indicating where it is in the processing pipeline",
      "enum": ["NEW", "IN_PROGRESS", "FAILED", "COMPLETE", "DEFERRED"]
    },
    "result": {
      "type": "string",
      "description": "Processing outcome recorded by the bot upon completing or failing this work item",
      "enum": ["SUCCESS", "FAILURE"]
    },
    "col1": {
      "type": "string",
      "description": "Display column 1: a human-readable label extracted from the work item data for display in the Control Room queue viewer"
    },
    "col2": {
      "type": "string",
      "description": "Display column 2: a secondary human-readable label extracted from the work item data"
    },
    "col3": {
      "type": "string",
      "description": "Display column 3: a tertiary human-readable label extracted from the work item data"
    },
    "deviceId": {
      "type": "integer",
      "description": "Numeric ID of the Bot Runner device that processed or is currently processing this work item"
    },
    "deviceUserId": {
      "type": "integer",
      "description": "Numeric ID of the user account under which the processing bot executed on the device"
    },
    "automationId": {
      "type": "string",
      "description": "Deployment ID (UUID) of the automation that processed this work item, linking back to the deployment record"
    },
    "jobExecutionId": {
      "type": "string",
      "description": "Identifier of the job execution associated with processing this work item"
    },
    "startTime": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp when the bot began processing this work item"
    },
    "endTime": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp when bot processing of this work item completed"
    },
    "deferredUntil": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp until which this work item is deferred; the bot will not pick it up before this time"
    },
    "lastPausedTime": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp when the work item was last paused during processing"
    },
    "totalPausedTime": {
      "type": "integer",
      "description": "Total time in seconds this work item was in a paused state",
      "minimum": 0
    },
    "comment": {
      "type": "string",
      "description": "Optional free-text comment added by the processing bot or a human operator",
      "maxLength": 2000
    },
    "error": {
      "type": "string",
      "description": "Error message recorded when the work item processing failed, for debugging and retry decisions"
    },
    "retryCount": {
      "type": "integer",
      "description": "Number of times this work item has been automatically retried after failure",
      "minimum": 0
    },
    "hashCode": {
      "type": "integer",
      "description": "Hash of the work item data used for duplicate detection when disallowDuplicate is enabled on the queue"
    },
    "version": {
      "type": "integer",
      "description": "Optimistic concurrency control version number; must match the server value when updating"
    },
    "tenantUuid": {
      "type": "string",
      "format": "uuid",
      "description": "UUID of the tenant in a multi-tenant Control Room deployment"
    },
    "createdBy": {
      "type": "integer",
      "description": "Numeric ID of the user who created this work item"
    },
    "createdOn": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp when this work item was added to the queue"
    },
    "updatedBy": {
      "type": "integer",
      "description": "Numeric ID of the user who last modified this work item"
    },
    "updatedOn": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp of the last status or data update to this work item"
    }
  },
  "$defs": {
    "WorkItemModel": {
      "type": "object",
      "description": "Schema definition for work items in a queue, specifying the named attributes and their data types that each work item must contain",
      "required": ["name"],
      "properties": {
        "id": {
          "type": "integer",
          "description": "Unique identifier of the work item model"
        },
        "name": {
          "type": "string",
          "description": "Human-readable name for the work item model"
        },
        "attributes": {
          "type": "array",
          "description": "Ordered list of attribute definitions that form the work item data schema",
          "items": {
            "$ref": "#/$defs/WorkItemAttribute"
          }
        },
        "createdOn": {
          "type": "string",
          "format": "date-time",
          "description": "ISO 8601 timestamp when this model was created"
        },
        "updatedOn": {
          "type": "string",
          "format": "date-time",
          "description": "ISO 8601 timestamp of the last modification to this model"
        }
      }
    },
    "WorkItemAttribute": {
      "type": "object",
      "description": "A single named attribute definition within a work item model",
      "required": ["name", "type"],
      "properties": {
        "id": {
          "type": "integer",
          "description": "Unique identifier of this attribute"
        },
        "name": {
          "type": "string",
          "description": "Attribute name used as the key in work item JSON payloads",
          "minLength": 1,
          "maxLength": 100
        },
        "type": {
          "type": "string",
          "description": "Data type of values stored in this attribute",
          "enum": ["TEXT", "NUMBER", "DATE", "BOOLEAN"]
        },
        "isRequired": {
          "type": "boolean",
          "description": "Whether this attribute must be provided when creating a work item"
        }
      }
    },
    "Queue": {
      "type": "object",
      "description": "A work item queue configuration in the Workload Management system",
      "required": ["name", "workItemModelId"],
      "properties": {
        "id": {
          "type": "integer",
          "description": "Unique identifier of the queue"
        },
        "name": {
          "type": "string",
          "description": "Human-readable name for the queue",
          "minLength": 1,
          "maxLength": 255
        },
        "description": {
          "type": "string",
          "description": "Optional description of the queue's business purpose"
        },
        "workItemModelId": {
          "type": "integer",
          "description": "ID of the work item model defining the data schema for items in this queue"
        },
        "status": {
          "type": "string",
          "description": "Current operational status of the queue",
          "enum": ["ACTIVE", "INACTIVE"]
        },
        "reactivationThreshold": {
          "type": "integer",
          "description": "Percentage of remaining work items below which the queue triggers reactivation of bot processing",
          "minimum": 0,
          "maximum": 100
        },
        "disallowDuplicate": {
          "type": "boolean",
          "description": "Whether to reject work items that have the same data hash as an existing item in the queue"
        },
        "autoRetryLimit": {
          "type": "integer",
          "description": "Maximum number of automatic retries for failed work items before they are marked as permanently failed",
          "minimum": 0,
          "maximum": 10
        },
        "workItemProcessingOrders": {
          "type": "array",
          "description": "Ordered list of attribute names by which work items are prioritized for processing",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}
