| name | trello-api-8-custom-fields |
| description | Sub-skill of trello-api: 8. Custom Fields. |
| version | 1.0.0 |
| category | business |
| type | reference |
| scripts_exempt | true |
8. Custom Fields
8. Custom Fields
REST API - Custom Fields:
curl -s "https://api.trello.com/1/boards/BOARD_ID/customFields?key=$TRELLO_API_KEY&token=$TRELLO_TOKEN" | jq
curl -s -X POST "https://api.trello.com/1/customFields" \
-d "key=$TRELLO_API_KEY" \
-d "token=$TRELLO_TOKEN" \
-d "idModel=BOARD_ID" \
-d "modelType=board" \
-d "name=Priority Score" \
-d "type=number" \
-d "pos=top" | jq
curl -s -X POST "https://api.trello.com/1/customFields" \
-H "Content-Type: application/json" \
-d '{
"key": "'$TRELLO_API_KEY'",
"token": "'$TRELLO_TOKEN'",
"idModel": "BOARD_ID",
"modelType": "board",
"name": "Status",
"type": "list",
"pos": "bottom",
"options": [
{"value": {"text": "Not Started"}, "pos": 1},
{"value": {"text": "In Progress"}, "pos": 2},
{"value": {"text": "Completed"}, "pos": 3}
]
}' | jq
curl -s -X PUT "https://api.trello.com/1/cards/CARD_ID/customField/FIELD_ID/item" \
-H "Content-Type: application/json" \
-d '{
"key": "'$TRELLO_API_KEY'",
"token": "'$TRELLO_TOKEN'",
"value": {"number": "85"}
}' | jq
curl -s -X PUT "https://api.trello.com/1/cards/CARD_ID/customField/FIELD_ID/item" \
-H "Content-Type: application/json" \
-d '{
"key": "'$TRELLO_API_KEY'",
"token": "'$TRELLO_TOKEN'",
"idValue": "OPTION_ID"
}' | jq
curl -s "https://api.trello.com/1/cards/CARD_ID/customFieldItems?key=$TRELLO_API_KEY&token=$TRELLO_TOKEN" | jq
Python Custom Fields:
import requests
import os
API_KEY = os.environ["TRELLO_API_KEY"]
TOKEN = os.environ["TRELLO_TOKEN"]
def get_custom_fields(board_id):
"""Get all custom fields for a board."""
url = f"https://api.trello.com/1/boards/{board_id}/customFields"
response = requests.get(url, params={"key": API_KEY, "token": TOKEN})
return response.json()
def set_custom_field_value(card_id, field_id, value, field_type="text"):
"""Set custom field value on a card."""
url = f"https://api.trello.com/1/cards/{card_id}/customField/{field_id}/item"
if field_type == "number":
data = {"value": {"number": str(value)}}
elif field_type == "text":
data = {"value": {"text": value}}
elif field_type == "checkbox":
data = {"value": {"checked": str(value).lower()}}
elif field_type == "date":
data = {"value": {"date": value}}
elif field_type == "list":
data = {"idValue": value}
:
data = {: {: (value)}}
response = requests.put(
url,
json={**data, : API_KEY, : TOKEN}
)
response.json()
():
url =
response = requests.get(url, params={: API_KEY, : TOKEN})
response.json()
fields = get_custom_fields()
field fields:
()
set_custom_field_value(, , , )
values = get_card_custom_fields()
value values:
()