# Update rows and columns

This API is used to update the properties of rows and columns in a spreadsheet, including hiding rows and columns and set the height (if a row) or width (if a column) of the dimension in pixels. 

## Limitation

You can act on up to 5,000 rows and columns at once.

##  Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dimension_range
HTTP Method | PUT
Supported app types | Custom App、Store App
Required scopes<br>**The scopes required to call this API. You can call the API with any of the scopes.**<br>Enable any scope from the list | View, comment, edit, and manage all files in My Space(drive:drive)<br>View, comment, edit, and manage Sheets(sheets:spreadsheet)

###  Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | When calling an API, the app needs to authenticate its identity through an access token. Refer to [Choose and obtain access tokens](https://open.feishu.cn/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM#5aa2e490).<br>**Value format**："Bearer `access_token`"<br>Supported options are:<br>- `tenant_access_token`：<br>Call the API on behalf of the app. The range of readable and writable data is determined by the app's own [data permission range](https://open.feishu.cn/document/home/introduction-to-scope-and-authorization/configure-app-data-permissions). Refer to [Get custom app tenant_access_token](https://open.feishu.cn/document/ukTMukTMukTM/ukDNz4SO0MjL5QzM/auth-v3/auth/tenant_access_token_internal) or [Get store app tenant_access_token](https://open.feishu.cn/document/ukTMukTMukTM/ukDNz4SO0MjL5QzM/auth-v3/auth/tenant_access_token). **Example value**："Bearer t-g1044qeGEDXTB6NDJOGV4JQCYDGHRBARFTGT1234"<br>- `user_access_token`：<br>Call the API on behalf of the user. The range of readable and writable data is determined by the user's data permission range. Refer to [Get user_access_token](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/authentication-management/access-token/get-user-access-token). **Example value**："Bearer u-cjz1eKCEx289x1TXEiQJqAh5171B4gDHPq00l0GE1234"
Content-Type | string | Yes | **Fixed value**: "application/json; charset=utf-8"

### Path parameters

Parameter | Type | Description
---|---|---
spreadsheetToken | string | Spreadsheet token. For more information about how to obtain the token, see [Spreadsheet overview](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview) | .

### Request body  
|Parameter|Type|Required|Description|
|--|-----|--|----|----|
|dimension|/|Yes|Dimension information of rows and columns to be updated| 
|&emsp;∟sheetId|string|Yes|sheetId|
|&emsp;∟majorDimension|string|No|The dimension to be updated. Values:<br>- ROWS <br> - COLUMNS| 
|&emsp;∟startIndex|int|Yes|Start index. Counts from 1. If `startIndex` is 3, updates empty rows or columns starting at row or column 3. Row or column 3 is included.| 
|&emsp;∟endIndex|int|Yes|End index. Count from 1. If `endIndex` is 7, update the row from the end of line 7. Row or column 7 is included. <br> Example: When `majorDimension` is` ROWS`, `startIndex` is 3, and `endIndex` is 7, rows in lines 3, 4, 5, 6, and 7 will be updated, for a total of 5 rows.| 
|dimensionProperties|/|Yes|Properties of rows or columns to be updated. Write at least one of the following parameters|
|&emsp;∟visible|bool|No|Whether to show rows or columns. Optional values are as follows:<br>- true: Show rows or columns <br>- false: Hide rows or columns| 
|&emsp;∟fixedSize|int|No|Row/Column size. The units are in seconds. When `fixedSize` is set to 0, it is equivalent to hiding the row or column. |

###  Request body example    
```json
{
    "dimension":{
        "sheetId":"2jm6f6",
        "majorDimension":"ROWS",
        "startIndex":1,
        "endIndex":3
    },
    "dimensionProperties":{
        "visible":true,
        "fixedSize":50
    }
}
```
###  cURL Request example
```BASH
curl --location --request PUT 'https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/shtcngNygNfuqhxTBf588jwgWbJ/dimension_range' \
--header 'Authorization: Bearer t-e346617a4acfc3a11d4ed24dca0d0c0fc8e0067e' \
--header 'Content-Type: application/json' \
--data-raw '{
    "dimension":{
        "sheetId":"2jm6f6",
        "majorDimension":"ROWS",
        "startIndex":1,
        "endIndex":3
    },
    "dimensionProperties":{
        "visible":true,
        "fixedSize":50
    }
}'
```

## Response  

###  Response body example    
```json
{
    "code": 0,
    "data": {},
    "msg": "Success"
}
```

###  Error code

For details, refer to [Server-side error codes](https://open.feishu.cn/document/ukTMukTMukTM/ugjM14COyUjL4ITN).

