Creating item with specific column value using a bash script


I’m working on a bash script to perform multiple automations in monday. The script is already able to create boards, create groups, create items in the correct group… the only thing missing now for me is to enter a value into a specific column for a new created item. Can someone maybe help with this? I’m new to the monday API or GraphQL API in general.

This line of code works to create an item and I know the ID of the column I want to add a value in is “numbers”. What would I have to add to this line to do this?

curl --location --request POST '''' --header 'Authorization: '$APIKey'' --header 'Content-Type: application/json' --header 'Cookie: __cfduid=d4512e647bd3dd90706f5673d6041f7c51618840981' --data-raw '{"query": "mutation { create_item (board_id: '$boardID', group_id: '$buildingPhaseID', item_name: \"TEST ITEM\") { id }}"}'

Thanks in advance for your help with this!

Hi @mkolb

Welcome to the community! (Nederlandse naam? :slight_smile: )

The easiest thing to do is play around with the API Playground (avatar > developer > API playground). Your mutation is escaping the item name (which is a normal string and doesn’t need escaping) and is missing the column_values. That one needs escaping as the API expects a stringified JSON of {columnid: value} pairs. Each column type require a different format for the value. Here is one for setting a date column (which requires a JSON format for the value) based on your input (assuming the boardId and groupId are both correct, and the columnId for the date column is “date”. Take care, you need the groupId, not the goupName.

curl --location --request POST '''' --header 'Authorization: '$APIKey'' --header 'Content-Type: application/json' --header 'Cookie: __cfduid=d4512e647bd3dd90706f5673d6041f7c51618840981' --data-raw '{"query": "mutation { create_item (board_id: '$boardID', group_id: '$buildingPhaseID', item_name: "TEST ITEM", column_values: "{\"date\":{\"date\":\"2022-10-12\"}}") { id }}"}'

Hi @basdebruin !

Thank you for your help! I tried to build this into my script, but I still get an error… This is the line I currently try to run:

curl --location --request POST '''' --header 'Authorization: '$APIKey'' --header 'Content-Type: application/json' --header 'Cookie: __cfduid=d4512e647bd3dd90706f5673d6041f7c51618840981' --data-raw '{"query": "mutation { create_item (board_id: '$boardID', group_id: '$buildingPhaseID', item_name: "TEST ITEM", column_values: "{\"numbers\":{\"Planned Time\":\"12\"}}"}'

Background is: I want to create items on a board which get a specific number as “planned time in hours” added. The board is created based on a template that already has a lot of formular_columns to then work with this value. When I tried to get the ID of this column, this was the output I received:

{"id":"numbers","title":"Planned Time","value":"\"2\""}

The line without the “column_values” part works without any issues. So creating the board and creating an item with just a title in the correct group… works like expected.

Thanks again for your support!

hi @mkolb

You really need to understand that each column type requires a different format. Where a date column from my example needs {date: "2022-10-12} a number column just need a number (not a JSON). See also: Numbers


column_values: "{\"numbers\":{\"Planned Time\":\"12\"}}"

should be something like

column_values: "{\"numbers\":\"12\"}"```