I am working on a project where I need to create multiple columns in a Monday.com board. I want to add 10+ columns with different types (text, numbers, date, etc.) using the Monday.com API. However, I found that creating multiple columns in a single request is not supported natively in the API.
I am currently considering using separate requests for each column, but I’m wondering if there’s a more efficient way to do this programmatically.
Can anyone suggest the best way to batch create multiple columns using separate requests or any improvements to the approach below?
You can perform multiple mutations in a single request by including them in the same mutation operation.
Try something like this:
mutation {
column1: create_column(
board_id: 1781628496,
title: "Work Status 1",
description: "This is my work status column",
column_type: status
) {
id
title
description
}
column2: create_column(
board_id: 1781628496,
title: "Work Status 2",
description: "This is my work status column",
column_type: status
) {
id
title
description
}
}
Some points to note…
Aliases:
Use aliases (column1, column2) to differentiate between the two mutations. This ensures that the response fields don’t conflict with each other.
Independent Execution:
Each mutation is executed independently, but they are sent in a single request. If one mutation fails, it does not affect the execution of the other mutations.
Response Structure:
The response will include the results of both mutations, grouped under the aliases you provided (column1 and column2).
Error Handling
If one of the mutations fails, the response will include an errors field, but the other mutation will still be executed. For example (with only an illustrative error):
{
"data": {
"column1": {
"id": "123",
"title": "Work Status 1",
"description": "This is my work status column"
},
"column2": null
},
"errors": [
{
"message": "Failed to create column",
"locations": [{ "line": 10, "column": 3 }],
"path": ["column2"]
}
]
}
Ask your favourite AI if you want to make your mutation more dynamic using variables (which is a very good idea – always use variables).