Manage conditional formatting
manage_conditional_formatsAdd, update, or delete conditional formatting rules in Google Sheets to automatically style cells when conditions like text, numbers, or custom formulas are met.
Instructions
Manages conditional-format rules that style cells when a condition holds (boolean rules; gradient color scales need raw_request). Rules are addressed by SHEET + INDEX in that sheet's rule list — get current rules and indexes from get_spreadsheet (sheets[].conditionalFormats), and re-read after every mutation because add/delete shift later indexes. action=add inserts a rule at index (default 0 = highest priority; rules are evaluated in order and the first match wins): needs ranges, condition_type (+condition_values; CUSTOM_FORMULA with a "=..." formula is the most flexible) and at least one format field (background_color, text_color, bold, italic). action=update replaces the ENTIRE rule at sheet_id+index with the newly provided one. action=delete removes the rule at sheet_id+index.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bold | No | Bold text for matching cells. | |
| index | No | Rule position in the sheet's list. add: insert position (default 0); update/delete: required. | |
| action | Yes | What to do with the rules. | |
| italic | No | Italic text for matching cells. | |
| ranges | No | add/update: the cells the rule applies to. | |
| sheet_id | No | update/delete: the sheet whose rule list is addressed. | |
| text_color | No | Text color for matching cells, "#RRGGBB". | |
| condition_type | No | Sheets API condition type, e.g. ONE_OF_LIST, ONE_OF_RANGE, NUMBER_GREATER, NUMBER_LESS, NUMBER_BETWEEN, NUMBER_EQ, TEXT_CONTAINS, TEXT_STARTS_WITH, TEXT_EQ, TEXT_IS_EMAIL, DATE_AFTER, DATE_BEFORE, DATE_BETWEEN, DATE_IS_VALID, BLANK, NOT_BLANK, BOOLEAN, CUSTOM_FORMULA. | |
| spreadsheet_id | Yes | The spreadsheet id — the long id from the URL (docs.google.com/spreadsheets/d/<spreadsheetId>/edit) or from create_spreadsheet / search_spreadsheets output. | |
| background_color | No | Fill for matching cells, "#RRGGBB". | |
| condition_values | No | Condition arguments: list items for ONE_OF_LIST (["Yes","No"]), one number for NUMBER_GREATER (["100"]), two for NUMBER_BETWEEN, "=A1>B1"-style formula for CUSTOM_FORMULA and ONE_OF_RANGE ("=Sheet1!A1:A10"), relative dates as values. Omit for BLANK / NOT_BLANK / DATE_IS_VALID. |