1.Can we Create Status Labels Using API in Monday.com ?
Hello @Anil12 Welcome to the community: Yes, you can create and manage Status labels in monday.com using their API. This can be achieved through two primary methods:
- Creating a Status Column with Custom Labels:
- When adding a new Status column to a board, you can define custom labels during its creation. This is done using the
create_column
mutation with thedefaults
argument to specify your labels. - Example:
graphql
CopyEdit
mutation {
create_column(
board_id: 1234567890,
title: "Project Status",
column_type: status,
defaults: "{\"labels\":{\"0\": \"Not Started\", \"1\": \"In Progress\", \"2\": \"Completed\"}}"
) {
id
}
}
In this example, a new Status column titled “Project Status” is created with three labels: “Not Started”, “In Progress”, and “Completed”.
developer.monday.com
2. Adding New Labels to an Existing Status Column:
- To add new labels to an existing Status column, you can use mutations like
change_column_value
,change_multiple_column_values
, orcreate_item
. By setting thecreate_labels_if_missing
argument totrue
, the API will create any labels that don’t already exist in the column. - Example:
graphql
CopyEdit
mutation {
change_column_value(
board_id: 1234567890,
item_id: 9876543210,
column_id: "status",
value: "{\"label\": \"Awaiting Review\"}",
create_labels_if_missing: true
) {
id
}
}
In this example, the label “Awaiting Review” is added to the “status” column if it doesn’t already exist.
Important Considerations:
- Permissions: Creating new labels modifies the board’s structure. Ensure that the API token or user account you’re using has the necessary permissions to change the board’s structure.
- Label Colors: By default, new labels are assigned default colors based on their index. If you need specific colors for your labels, you can define them using the
labels_colors
attribute in thedefaults
JSON when creating a column. For example:
json
CopyEdit
{
"labels": {
"0": "Not Started",
"1": "In Progress",
"2": "Completed"
},
"labels_colors": {
"0": {"color": "#c4c4c4"},
"1": {"color": "#fdab3d"},
"2": {"color": "#00c875"}
}
}
This JSON sets specific colors for each label during the column creation.
By utilizing these methods, you can effectively manage Status labels in monday.com through the API, tailoring them to fit your workflow requirements.