> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Setting

> Permission required: `edit-privileged-setting`

The `_id` of a setting is the first argument of the `RocketChat.settings.add` method used in `Rocket.Chat/packages/rocketchat-lib/server/startup/settings.js` (among other files).

For example, the following code in `settings.js` file:
  ```json
  this.add('Accounts_AllowAnonymousRead', false, {
    type: 'boolean',
    public: true  });
  ```
  This means that the setting labeled `Allow anonymous read` in the section `Accounts` has `_id` equal to `Accounts_AllowAnonymousRead`. The second argument is the default value (false). The third argument specifies the variable's type and whether it is public, hidden, and so on.

  To set a color, you can send:
  ```json
  { value: '<color-code>',
    editor: 'color' }
  ```

  And also to trigger a action-button, use:
  ```json
  { execute: true }
  ```
  ### Changelog
  | Version      | Description |
  | ---------------- | ------------|
  |0.65.0            | Added option to set a color and trigger an action       |
  |0.42.0            | Added       |

## OpenAPI

````json POST /api/v1/settings/{_id}
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Settings"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "paths": {
    "/api/v1/settings/{_id}": {
      "parameters": [
        {
          "schema": {
            "type": "string"
          },
          "name": "_id",
          "in": "path",
          "required": "true",
          "description": "The unique ID of the setting that you want to update or fetch."
        }
      ],
      "post": {
        "summary": "Update Setting",
        "tags": [
          "Settings"
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/trueSuccess"
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          }
        },
        "operationId": "post-api-v1-settings-_id",
        "description": "Permission required: `edit-privileged-setting`\n\nThe `_id` of a setting is the first argument of the `RocketChat.settings.add` method used in `Rocket.Chat/packages/rocketchat-lib/server/startup/settings.js` (among other files).\n\nFor example, the following code in `settings.js` file:\n  ```json\n  this.add('Accounts_AllowAnonymousRead', false, {\n    type: 'boolean',\n    public: true  });\n  ```\n  This means that the setting labeled `Allow anonymous read` in the section `Accounts` has `_id` equal to `Accounts_AllowAnonymousRead`. The second argument is the default value (false). The third argument specifies the variable's type and whether it is public, hidden, and so on.\n\n  To set a color, you can send:\n  ```json\n  { value: '<color-code>',\n    editor: 'color' }\n  ```\n\n  And also to trigger a action-button, use:\n  ```json\n  { execute: true }\n  ```\n  ### Changelog\n  | Version      | Description |\n  | ---------------- | ------------|\n  |0.65.0            | Added option to set a color and trigger an action       |\n  |0.42.0            | Added       |",
        "parameters": [
          {
            "$ref": "#/components/parameters/X-User-Id"
          },
          {
            "$ref": "#/components/parameters/X-Auth-Token"
          },
          {
            "$ref": "#/components/parameters/x-2fa-code"
          },
          {
            "$ref": "#/components/parameters/X-2fa-method"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "string",
                    "description": "The value to update the setting."
                  },
                  "color": {
                    "type": "string",
                    "description": "The color code to update the setting."
                  },
                  "editor": {
                    "type": "string",
                    "description": "The editor key, with color value. Required, if color was set."
                  },
                  "execute": {
                    "type": "boolean",
                    "description": "To trigger a action-button."
                  }
                },
                "required": [
                  "value"
                ]
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "trueSuccess": {
        "description": "OK",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "type": "boolean"
                }
              }
            },
            "examples": {
              "Success": {
                "value": {
                  "success": "true"
                }
              }
            }
          }
        }
      },
      "authorizationError": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Authorization Error": {
                "value": {
                  "status": "error",
                  "message": "You must be logged in to do this."
                }
              }
            }
          }
        }
      }
    },
    "parameters": {
      "X-User-Id": {
        "name": "X-User-Id",
        "in": "header",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "CkCPNctrgCDfmWLqC",
        "description": "The user ID."
      },
      "X-Auth-Token": {
        "name": "X-Auth-Token",
        "in": "header",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "1Dd4iN_ClKn5jl-xPC36snQ4s9Zd5GZnXCQuCNSKcVE",
        "description": "The authentication token."
      },
      "x-2fa-code": {
        "name": "x-2fa-code",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "The 2FA code. This parameter is required if 2FA is enabled in your workspace. See the <a href=\"https://developer.rocket.chat/apidocs/introduction-to-two-factor-authentication\" target=\"_blank\">Introduction to Two-Factor Authentication</a> document for details."
      },
      "X-2fa-method": {
        "name": "x-2fa-method",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "Enter the method with which you get the 2FA code. It can be `email`, `totp`, or `password`. This parameter is required if 2FA is enabled in your workspace."
      }
    }
  }
}
````

