# Perform bulk actions on agents

`PUT /agents`



[Agents API guide](https://docs.contextual.io/legacy/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": {
    "/agents": {
      "put": {
        "tags": [
          "Agents"
        ],
        "summary": "Perform bulk actions on agents",
        "parameters": [
          {
            "name": "x-org-id",
            "in": "header",
            "required": false
          }
        ],
        "deprecated": false,
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "start"
                      },
                      "ids": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                        }
                      }
                    },
                    "required": [
                      "action"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "stop"
                      },
                      "reason": {
                        "type": "string"
                      },
                      "ids": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                        }
                      }
                    },
                    "required": [
                      "action"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "restart"
                      },
                      "ids": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                        }
                      }
                    },
                    "required": [
                      "action"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "set-log-level"
                      },
                      "ids": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
                        }
                      },
                      "level": {
                        "type": "string",
                        "enum": [
                          "fatal",
                          "error",
                          "warn",
                          "info",
                          "debug"
                        ]
                      },
                      "durationMs": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "action",
                      "level",
                      "durationMs"
                    ],
                    "additionalProperties": false
                  }
                ],
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Action completed",
            "content": {}
          },
          "400": {
            "description": "Invalid payload provided",
            "content": {}
          },
          "401": {
            "description": "Missing or invalid authorization header",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Agent(s) not found",
            "content": {}
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "jwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "$ErrorResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": [
              "string",
              "number"
            ]
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false
      }
    }
  }
}
```