# Deploy an updated Worker revision

`PUT /$event/workers/{workerId}`



[Agents API guide](https://docs.contextual.io/tenants/tenant-apis/agents-api.md)

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Contextual Agents Api",
    "description": " "
  },
  "security": [
    {
      "jwt": []
    }
  ],
  "servers": [
    {
      "url": "https://agents.{tenantId}.my.contextual.io/api/v1",
      "variables": {
        "tenantId": {
          "default": "YOUR-TENANT-ID"
        }
      }
    }
  ],
  "paths": {
    "/$event/workers/{workerId}": {
      "put": {
        "tags": [
          "Workers"
        ],
        "summary": "Deploy an updated Worker revision",
        "parameters": [
          {
            "name": "workerId",
            "in": "path",
            "required": true
          }
        ],
        "deprecated": false,
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerDeploymentAgent"
                }
              }
            }
          },
          "400": {
            "description": "Invalid Worker configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authorization header",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Agent plan limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Worker not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Worker deployment dependency unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "jwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "WorkerDeploymentAgent": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "displayName": {
                "type": "string"
              },
              "envVars": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label",
                    "value"
                  ],
                  "additionalProperties": false
                }
              },
              "size": {
                "type": "string"
              },
              "configName": {
                "type": "string"
              },
              "livenessTimeoutSeconds": {
                "default": 50,
                "type": "integer",
                "minimum": 50,
                "maximum": 3600,
                "multipleOf": 10
              },
              "customDomain": {
                "type": "string",
                "pattern": "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$"
              },
              "type": {
                "type": "string",
                "const": "worker"
              },
              "worker": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "workerVersion": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "runtimeClassName": {
                "type": "string",
                "enum": [
                  "kata-xxsmall",
                  "kata-xsmall",
                  "kata-small",
                  "kata-medium",
                  "kata-large",
                  "kata-xlarge",
                  "kata-xxlarge"
                ]
              },
              "schedule": {
                "type": "string",
                "pattern": "^((\\*(\\/\\d+)?|([0-5]?\\d)(-([0-5]?\\d)(\\/\\d+)?)?(,([0-5]?\\d)(-([0-5]?\\d)(\\/\\d+)?)?)*)\\s+(\\*(\\/\\d+)?|([01]?\\d|2[0-3])(-([01]?\\d|2[0-3])(\\/\\d+)?)?(,([01]?\\d|2[0-3])(-([01]?\\d|2[0-3])(\\/\\d+)?)?)*)\\s+(\\*(\\/\\d+)?|(0?[1-9]|[12]\\d|3[01])(-(0?[1-9]|[12]\\d|3[01])(\\/\\d+)?)?(,(0?[1-9]|[12]\\d|3[01])(-(0?[1-9]|[12]\\d|3[01])(\\/\\d+)?)?)*)\\s+(\\*(\\/\\d+)?|([1-9]|1[012])(-([1-9]|1[012])(\\/\\d+)?)?(,([1-9]|1[012])(-([1-9]|1[012])(\\/\\d+)?)?)*|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\s+(\\*(\\/\\d+)?|([0-6])(-([0-6])(\\/\\d+)?)?(,([0-6])(-([0-6])(\\/\\d+)?)?)*|mon|tue|wed|thu|fri|sat|sun)|(@yearly|@annually|@monthly|@weekly|@daily|@midnight|@hourly))$"
              },
              "_metaData": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "createdAt": {
                    "type": "string",
                    "pattern": "^(?:\\d+(?:\\.\\d+?)?|(?:\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z))$",
                    "description": "An ISO 8601 date time string",
                    "format": "date-time"
                  },
                  "updatedAt": {
                    "type": "string",
                    "pattern": "^(?:\\d+(?:\\.\\d+?)?|(?:\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z))$",
                    "description": "An ISO 8601 date time string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "id",
                  "createdAt"
                ],
                "additionalProperties": false
              },
              "maxReplicas": {
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              },
              "scaleType": {
                "default": "cpu",
                "type": "string",
                "const": "cpu"
              },
              "minReplicas": {
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              },
              "targetCpu": {
                "type": "number",
                "minimum": 1,
                "maximum": 100
              }
            },
            "required": [
              "name",
              "displayName",
              "size",
              "livenessTimeoutSeconds",
              "type",
              "worker",
              "workerVersion",
              "runtimeClassName",
              "_metaData",
              "maxReplicas",
              "scaleType",
              "minReplicas",
              "targetCpu"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "displayName": {
                "type": "string"
              },
              "envVars": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label",
                    "value"
                  ],
                  "additionalProperties": false
                }
              },
              "size": {
                "type": "string"
              },
              "configName": {
                "type": "string"
              },
              "livenessTimeoutSeconds": {
                "default": 50,
                "type": "integer",
                "minimum": 50,
                "maximum": 3600,
                "multipleOf": 10
              },
              "customDomain": {
                "type": "string",
                "pattern": "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$"
              },
              "type": {
                "type": "string",
                "const": "worker"
              },
              "worker": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "workerVersion": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "runtimeClassName": {
                "type": "string",
                "enum": [
                  "kata-xxsmall",
                  "kata-xsmall",
                  "kata-small",
                  "kata-medium",
                  "kata-large",
                  "kata-xlarge",
                  "kata-xxlarge"
                ]
              },
              "schedule": {
                "type": "string",
                "pattern": "^((\\*(\\/\\d+)?|([0-5]?\\d)(-([0-5]?\\d)(\\/\\d+)?)?(,([0-5]?\\d)(-([0-5]?\\d)(\\/\\d+)?)?)*)\\s+(\\*(\\/\\d+)?|([01]?\\d|2[0-3])(-([01]?\\d|2[0-3])(\\/\\d+)?)?(,([01]?\\d|2[0-3])(-([01]?\\d|2[0-3])(\\/\\d+)?)?)*)\\s+(\\*(\\/\\d+)?|(0?[1-9]|[12]\\d|3[01])(-(0?[1-9]|[12]\\d|3[01])(\\/\\d+)?)?(,(0?[1-9]|[12]\\d|3[01])(-(0?[1-9]|[12]\\d|3[01])(\\/\\d+)?)?)*)\\s+(\\*(\\/\\d+)?|([1-9]|1[012])(-([1-9]|1[012])(\\/\\d+)?)?(,([1-9]|1[012])(-([1-9]|1[012])(\\/\\d+)?)?)*|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\s+(\\*(\\/\\d+)?|([0-6])(-([0-6])(\\/\\d+)?)?(,([0-6])(-([0-6])(\\/\\d+)?)?)*|mon|tue|wed|thu|fri|sat|sun)|(@yearly|@annually|@monthly|@weekly|@daily|@midnight|@hourly))$"
              },
              "_metaData": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "createdAt": {
                    "type": "string",
                    "pattern": "^(?:\\d+(?:\\.\\d+?)?|(?:\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z))$",
                    "description": "An ISO 8601 date time string",
                    "format": "date-time"
                  },
                  "updatedAt": {
                    "type": "string",
                    "pattern": "^(?:\\d+(?:\\.\\d+?)?|(?:\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z))$",
                    "description": "An ISO 8601 date time string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "id",
                  "createdAt"
                ],
                "additionalProperties": false
              },
              "maxReplicas": {
                "default": 1,
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              },
              "pollingInterval": {
                "default": 20,
                "type": "integer",
                "minimum": 5,
                "maximum": 9007199254740991
              },
              "minReplicas": {
                "default": 0,
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "cooldownPeriod": {
                "default": 5,
                "type": "number",
                "minimum": 0
              },
              "lagThreshold": {
                "default": 100,
                "type": "number",
                "minimum": 2
              },
              "scaleType": {
                "type": "string",
                "const": "lag"
              }
            },
            "required": [
              "name",
              "displayName",
              "size",
              "livenessTimeoutSeconds",
              "type",
              "worker",
              "workerVersion",
              "runtimeClassName",
              "_metaData",
              "maxReplicas",
              "pollingInterval",
              "minReplicas",
              "cooldownPeriod",
              "lagThreshold",
              "scaleType"
            ],
            "additionalProperties": false
          }
        ]
      },
      "$ErrorResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": [
              "string",
              "number"
            ]
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false
      }
    }
  }
}
```