# Delete rows or columns

This API is used to delete rows and columns based on spreadsheetToken and dimension information.

## Limitations

- You can delete up to 5,000 rows and columns at once.
- A worksheet should have a minimum of one row and one column. You cannot delete all rows or columns.

##  Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/dimension_range
HTTP Method | DELETE
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 | Authenticate the caller's identity through the access token. Optional values:<br>- `tenant_access_token`: Tenant authorization credential. The application acts on behalf of the tenant (i.e., a company or team) to perform corresponding operations. Example value: "Bearer t-7f1bcd13fc57d46bac21793aabcef"<br>- `user_access_token`: User authorization credential. The application acts on behalf of the user to perform corresponding operations. Example value: "Bearer u-7f1bcd13fc57d46bac21793aabcef"<br>For more information, refer to [Obtaining Access Tokens](https://open.feishu.cn/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM).
Content-Type | string | Yes | **Fixed value**: "application/json; charset=utf-8"

###  Path parameters
|Parameter|Type|Required|Description&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;|
|--|-----|--|----|
|spreadsheetToken|string|Yes| Spreadsheet token. For details, see [Spreadsheet overview](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview).|
###  Request body
|Parameter|Type|Required|Description&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;|
|--|-----|--|----|
|dimension|/|Yes|Dimension information of the rows and columns to delete. The row or column in the range [startIndex, endIndex] will be deleted|
|&emsp;∟sheetId|string|Yes|sheetId|
|&emsp;∟majorDimension|string|Yes|The dimension to be deleted. Values:<br>- ROWS <br> - COLUMNS|
|&emsp;∟startIndex|int|Yes|Start location. Start from 1. If `startIndex` is 3, the deletion starts at the 3rd row or column. Contains the third row or column.|
|&emsp;∟endIndex|int|Yes|End location. Start from 1. If `endIndex` is 7, delete until the end of the 7th row or column. Include the 7th row or column<br> Example: When `majorDimension` is `ROWS`, `startIndex` is 3, and `endIndex` is 7, delete the data in rows 3, 4, 5, 6, and 7, for a total of 5 rows.|
### Request body example
```json
{
    "dimension":{
        "sheetId":"2jm6f6",
        "majorDimension":"ROWS",
        "startIndex":3,
        "endIndex":7
    }
}
```
###  cURL Request example
```bash
curl --location --request DELETE '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":3,
        "endIndex":7
    }
}'
```
##  Response
### Response body
|Parameter|Type|Description|
|--|-----|--|
|delCount|int |Number of rows/columns to be deleted|
|majorDimension|string |The dimension to be deleted. Values:<br>- ROWS <br> - COLUMNS|
### Response body example
```json
{
    "code": 0,
    "data": {
        "delCount": 0,
        "majorDimension": "ROWS"
    },
    "msg": "success"
}

```
### Error code

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

