Trello error 401 PHP

Hi, I’m new at Trello API and I’m working with on a PHP project. I’m trying to write a comment or put a label on a card following the example on the documentation (, but the only result is I got is error 401.

The error doesn’t occur with the Unirest\Request::get example

I’m quite sure that my token has all the authorizations. On the authorization page, I can see that the token can do everything but read my password.

What I am missing?


Can you see the error message coming along with the 401?

Generally the error will respond with a message that includes some clue as to what is happening.

Here the error when I try to delete a card:

object(Unirest\Response)#1 (4) {
  string(11) "invalid key"
  string(11) "invalid key"
  array(25) {
    string(10) "HTTP/2 401"
    string(3) "off"
    string(4) "DENY"
    string(6) "noopen"
    string(4) "none"
    string(31) "strict-origin-when-cross-origin"
    string(8) "no-store"
    string(53) "no-store, no-cache, must-revalidate, proxy-revalidate"
    string(8) "no-cache"
    string(1) "0"
    string(8) "1.2308.0"
    string(10) "Production"
    string(1) "*"
    string(22) "GET, PUT, POST, DELETE"
    string(35) "Authorization, Accept, Content-Type"
    string(188) "x-rate-limit-api-key-interval-ms, x-rate-limit-api-key-max, x-rate-limit-api-key-remaining, x-rate-limit-api-token-interval-ms, x-rate-limit-api-token-max, x-rate-limit-api-token-remaining"
    string(25) "text/plain; charset=utf-8"
    string(2) "11"
    string(29) "Thu, 10 Dec 2020 10:12:44 GMT"
    string(2) "93"
    string(108) "report-uri="", max-age=86400"
    string(25) "max-age=63072000; preload"
    string(7) "nosniff"
    string(13) "1; mode=block"
    string(16) "globaledge-envoy"

That means that the API key isn’t making it through correctly. Can you double-check that you are using the correct API key?

The key works correctly with the get request.
This is all the code I’m using:

require_once '/Users/silvio/vendor/mashape/unirest-php/src/Unirest.php';
$headers = array(
  'Accept' => 'application/json'

$query = array(
  'key' => '{MYKEY}',
  'token' => '{MY TOKEN}'

  // $response = Unirest\Request::get(
  //   '',
  //   $headers,
  //   $query
  // );

  $response = Unirest\Request::post(


What are you trying to do in that request?

It looks like a POST to /cards/{idCard}/idLabels with only a key and token in the parameters.

I’d expect a request to create a new label to look like this:

curl '{{key}}&token={{token}}' \
  -H 'accept: application/json' \
  -H 'content-type: application/json' \
  --data-binary '{"name":"asd","color":"pink","idBoard":"586e8f681d4fe9b06a928307"}' \

You’ll notice that there are additional parameters required to create a label.

I notice that in your code after the idCard you use /labels/ and then all the parameters.

in the example code found here the url is:

I change my URL from /idLabel/ to /labels/ and it works, even without all the parameters.
Then I’ve put also all the correct parameters and still works