Cli-kintone Tutorial 2: Add and Delete Records


This is the second article of the cli-kintone series, focused on adding and deleting records using cli-kintone.
The previous tutorial can be found here: Cli-kintone Tutorial 1: Export record data.

In this article we will continue to use the Customer Database used in the previous tutorial.

Add Records

STEP 1: Prepare a CSV file

The first step is to prepare a CSV file that will be used to add record data to the Kintone App.

You do not have to list every field that's in your App into the CSV file - you may limit the fields you want to add data to, as below:

Make sure to write the field code in the first row, and not the field name.
Save the data as customers.csv.

STEP 2: Add records by specifiying the CSV file

In addition to the authentication option, use the -f option to specify the file to import.

If customers.csv is saved in the same location as the cli-kintone executable file:

If you specify the file path of customers.csv:



If you specify the file path of customers.csv and import from a specified line:


Add Records after Deleting Records

STEP 1: Add Records After Deleting all Records

Use the -f and -D option to delete all records before adding new records.

If no query is specified, all records in the App will be deleted before records are added.

STEP 2: Add Records After Deleting filtered records

To delete only specified records before adding new records, you will need to filter the records to be deleted using the -q option. Refer to this page on how to write queries.

In the example below, the 5 latest records that have "Krispy" as the contact name are deleted before the new records are added:

STEP 3: Delete Records Without Adding Records

You can delete records without adding data by making an empty CSV file, specifying it with the -f option and then using the -D option:

To make an empty CSV file "empty.csv" on Windows:

For Mac and Linux, use one of the commands below in the terminal:

Add Records with Table data

In this example, we will use the Expense Report App that was used in the previous tutorial.

STEP 1: Create a CSV file containing table data

To add records that include table data, add an * symbol in the first column of the row that contains the field codes. Also add the * symbol to each row that contains the first table data row of tables in each record.

To avoid making mistakes, use a CSV file exported by cli-kintone as reference.

Save the contents above as tabledata.csv.

STEP 2: Add records by specifying the CSV file

Use the -f option to specify the CSV file to add records with table data.


The contents of the CSV file looks like the below when opened in Excel.



These are the screenshots of the three records that have data added to them. The data in the colored rectangles above match the data in the colored rectangles below.


CSV data for Check box and Multi-choice fields

Check box fields and Multi-choice fields are fields that can hold multiple values. A carriage return must be used to separate the multiple values for these fields. If you view the data in Excel, the multiple values can be seen on several lines inside one cell. When editing on excel, use the Alt + Enter shortcut in a cell for a carriage return.

The same goes for the tables. If the table contains these fields, separate the multiple values within these fields with carriage returns.

Example CSV data 


The two records in the above images can be represented with the following CSV:


In Excel, this looks like the below:


Example CSV data for Tables


The two records in the above images can be represented with the following CSV:

In Excel, this looks like the below:


How to debug if records fail to be added

If any errors occur, check the logs that are outputted into the console.


You can also identify the problem by checking the requests on the Audit Log in the System Administration page.

Click the gear icon on the upper right menu of Kintone, and go to "User & System Administration" -> "Audit Logs" -> "View & Download".

From the Audit Log list, you can see what record operations were performed and their success/failure as well as the details of each operation by clicking the "i" mark on the left side of the table.

By looking at this information, you can see if requests from cli-kintone are successfully reaching your Kintone environment and to see what errors are the cause of the issue.




This is the end of Tutorial 2 for cli-kintone.

We hope this has solved any tricky issues involving managing table data and fields that can hold multiple values.



<<< Go back to Cli-kintone Tutorial 1: Export record data

Was this article helpful?
0 out of 0 found this helpful
Do you have any questions or issues related to this article?
Please share your views with us in the Community forums!