Delete Data with the Command Line Tool

Contents

Overview

This article introduces how to delete data from Kintone using cli-kintone (External link) .

Initial Setup

This section introduces the required Kintone Apps and settings.

Prepare Sample Apps

For this tutorial, a Kintone App with record data is needed. Feel free to use any created App. If there is no other app, use the Customer Database App or the Expense Report App made in the Export Data with the Command Line Tool article.

Set the API Token

Go to the App Settings, click API Token, and update the existing API Token created in the Export Data with the Command Line Tool article. Make sure to check the Delete Records option, and take note of the API token, as it is needed in the later steps.

Prepare Data as CSV

To delete specific records, specify the Record number to be deleted in the CSV file.

The first row of the CSV file must be a header, with the field code of the Record number field. The second row must contain either the record numbers to be deleted, or the App Code (External link) containing the record numbers to be deleted.

Example

1
2
3
"Record_number"
"1"
"2"

Delete Records

caution
Attention

Records deleted with the record delete command can not be recovered.

To delete records, specify the record delete command. In addition, specify the Kintone domain, App ID and API Token via the --base-url, --app and --api-token options, and the CSV file via the --file-path option.

  • --base-url: The subdomain to retrieve records from. (ex: https://www.example.kintone.com (External link) )
  • --app: The App ID to retrieve records from. (ex: 123)
  • --api-token: API token copied from Initial Setup
  • --file-path: The file path of a CSV file with information to update or add records.
1
2
3
cli-kintone.exe record delete --base-url KINTONE_URL --app APP_ID ^
  --api-token API_TOKEN ^
  --file-path FILE_PATH

When the command is run, a message to confirm the deletion will be output. To begin deletion, enter "Y" and submit via the Enter key. In order to cancel the operation, input "N" instead. If the --yes or -y option is passed with the command, the specified records will be deleted without confirmation.

Example

1
2
3
4
5
6
cli-kintone.exe record delete --base-url https://example.kintone.com --app 123 ^
  --api-token BNk5wfOufWtPSTc6miMBTEa0SEm5ZokIcJWSSYXL ^
  --file-path ./example.csv -y

[2024-02-07T09:09:00.223Z] INFO: Starting to delete records...
[2024-02-07T09:09:00.915Z] INFO: 2 records are deleted successfully

Delete all records

To delete all records, run the command without passing the --file-path option.

1
2
cli-kintone.exe record delete --base-url KINTONE_URL --app APP_ID ^
  --api-token API_TOKEN

Example

1
2
3
4
5
6
cli-kintone.exe record delete --base-url https://example.kintone.com --app 123 ^
  --api-token BNk5wfOufWtPSTc6miMBTEa0SEm5ZokIcJWSSYXL

? Are you sure want to delete records? Yes
[2024-02-07T09:25:17.113Z] INFO: Starting to delete all records...
[2024-02-07T09:25:17.675Z] INFO: 3 records are deleted successfully