Trello Rest API - Card Colors/Covers

Apologies if this has been asked/answered; I didn’t find any threads.

Will the Rest API be updated to allow for control over a card’s cover/color?

1 Like

Great question! It isn’t documented yet (on my to-do, I promise!).

Let me see if I can’t give a rough outline of it here:

On a PUT to /1/cards/{idCard} you can pass in a cover key and object with the following option key/values:

Option Values About
color pink, yellow, lime, blue, black, orange, red, purple, sky, green Makes the cover a solid color .
brightness dark, light Determines whether the text on the cover should be dark or light.
url An unsplash URL: https://images.unsplash.com Used if making an image the cover. Only Unsplash URLs work.
idAttachment ID of an attachment on the card Used if setting an attached image as the cover.
size normal, full Determines whether to show the card name on the cover, or below it.

brightness can be sent alongside any of the other parameters, but all of the other parameters are mutually exclusive; you can not have the cover be a color and an idAttachment at the same time.

On the brightness options, setting it to light will make the text on the card cover dark:
05%20PM

And vice versa, setting it to dark will make the text on the card cover light:
31%20PM

Additionally, we added a setCover to the attachments POST endpoint that accepts a Boolean value. If true the attached image will be made the card cover.

POST https://trello.com/1/cards/{idCard}/attachments

{
  file: [fileData],
  setCover: true,
}
1 Like

Perfect! That’ll do for me for now! Thank you!

Also, anything on your roadmap that will allow custom RGB values for card covers? Considering the brightness setting, I think this would be an awesome and useful option!

Thanks again!

As far as I know, that isn’t on the roadmap right now.

But I’ll happily pass along the idea! :slight_smile:

Hey @bcook

I tried this today but was not able to set the cover on the card, can you confirm current API supports this?

Yes, I’m certain the API supports this. Here is the blog announcing this feature: https://blog.trello.com/card-covers-and-colors.

If you open your browser’s network tab and watch the requests made by the Trello web client to the server, you’ll see a cover object in the payload when you make changes to the card cover via this widget on the right of the card back:

The API documented and available to you is the same one that the web client (and mobile clients!) use, as well.

I’m also not able to get this API endpoint to work.

I’m confused re how & what format I need to provide the cover info.

I can easily change items such as ‘desc’ (which are string format), but per API reference card is an object.

For example, (and i’m using python), using the sample code in the URL above, I can update say the ‘desc’ by adding ‘desc’: ‘updated text in desc field’ to the query dictionary.

But I cant work out how to update the ‘cover’. Getting card data, it appears ‘cover’ is a dictionary in python, as I get the following in response.text
“cover”:{“idAttachment”:null,“color”:null,“idUploadedBackground”:null,“size”:“normal”,“brightness”:“light”}

I’ve tried passing a cover dictionary via the query. eg attempting to set cover to purple:
‘cover’: {‘idAttachment’: None, ‘color’: ‘purple’, ‘idUploadedBackground’: None, ‘size’: ‘normal’, ‘brightness’: ‘light’}

How should the cover be specified in the put request’s query parameter ?

@DennisEagles @bcook
I am facing same issue. Tried to update card cover color but even though I am getting success response, card cover is not updating. Below is the screenshot of the PUT request. Please suggest.

@GauravSrivastava @DennisEagles
I am using VSCode “REST.Client” add-in https://marketplace.visualstudio.com/items?itemName=humao.rest-client to work with the Trello API.

The following test_trello.http file to update a Trello card worked for me.
Getting a status code of 200 with updated card info.

Update the variables.

###
@trello_api = https://api.trello.com

@trello_token = 70XXXXXXXXXXb2
# This grants access to the data. This needs to be KEPT SECRET.
# On the same page as https://trello.com/app-key, click the hyperlinked "Token" under the API key.
# click "Allow".

@trello_key = 5XXXXXXXXXXXXXXXXXXXXXXXXc
# You can get your API key by logging into Trello and visiting https://trello.com/app-key
# An API key by itself doesn't grant access to a user's Trello data and could be public.

@trello_card = 5XXXXXXXXXXXXXXX6
# Get the card ID by opening a card on your test Trello board, then delete the name in URL and add .json to the URL, press enter to get a web page with card data, including card ID.

###
# Let check that PUT call is working with simple card name change
PUT {{trello_api}}/1/cards/{{trello_card}}?key={{trello_key}}&token={{trello_token}}  HTTP/1.1
content-type: application/json

{
    "name":"Let us change the name to test PUT."
}

###
# Update card cover colour

PUT {{trello_api}}/1/cards/{{trello_card}}?key={{trello_key}}&token={{trello_token}}  HTTP/1.1
content-type: application/json

{
"cover":{
            "color":"purple",
            "idAttachment":null,
            "idUploadedBackground":null,
            "size":"normal",
            "brightness":"light"
            }
}
1 Like

@RudigerWolf Thank ou Rudiger. Adding content-type: application/json solved my issue.

Interesting … I was using the example code from Atlassian trello api docs and couldnt get it to work … but with the help of a genius on stackoverflow was able to get it working by passing a ‘json’ parameter in the request with the cover stuff, in addition to the ‘params’ parameter with the key/token.