Somebody else in our CartoDB organisation has created a map.


I need to use the Static Maps API to get a .jpg image from the map, as described here. I'll be storing the .jpg locally and serving it up to a customer via our own API.

I've tried various values for the :token parameter, but none seems to work:

  1. map name (slightly complicated because it contains a space, which I've substituted with both + and %20)
  2. our API key (we use CartoDB.js elsewhere in our organisation)
  3. the GUID in the three samples I see when on https://<ouraccount>.cartodb.com/dashboard/maps I click "publish" on the map.

This leads me to construct a URL like:


But when I try to visit the URL in my browser, I get the message:

{"errors":["Invalid or nonexistent map configuration token '<token value>'"]}

How do I find the layergroupid?

1 Answer 1


If you have a Map (named map if it has private data) created already in the Editor, you will be able to find it's template map name in the viz.json file of the map. (Available at the third link in the Publish button under the CartoDB.js title).

Inside your viz.json, look for "named_map" and "name"

type: "namedmap",
order: 1,
options: {
type: "namedmap",
user_name: "iriberri",
maps_api_template: "https://{user}.cartodb.com:443",
sql_api_template: "https://{user}.cartodb.com:443",
tiler_protocol: "http",
tiler_domain: "cartodb.com",
tiler_port: "80",
filter: "mapnik",
named_map: {
name: "tpl_59dc29e0_f006_11e5_9245_0e674067d321",  <------ named map name
stat_tag: "59dc29e0-f006-11e5-9245-0e674067d321",
params: {
layer0: 1,
layer1: 1

Now you have your named map name you can instantiate it in order to get the layergroupid.

Notice that the layergroupid token will expire after some time, so each time that you need to use it you'll have to instantiate it. In order to instantiate it, no browser or javascript is required, just:

-H 'Content-Type: application/json' \
-d '' \

And this will return a JSON object with the layergroupid and other information.

  • I follow the steps to get the map name (like yours, mine starts with tpl and then what looks like a GUID). I'm using Postman instead of cURL, but I don't think that should make a difference. But when I POST to https://user_name.cartodb.com/api/v1/map/named/map_name?api_key=my_api_key I get Unauthorized template instantiation Mar 22, 2016 at 10:44
  • Is the map password protected?
    – iriberri
    Mar 22, 2016 at 10:59
  • No. (I'd see that in the options, as illustrated here, right?) Mar 22, 2016 at 11:32
  • Yep, exactly! I should have said it in other words: which is the privacy option of the map?
    – iriberri
    Mar 22, 2016 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.