Can I change the fillStyleId without importByKeyAsync?

Hello again!

I am trying to replace an old token (paint style) with a new token without having to import the style by async key (to speed things up). We use a combination of the REST API and Figma’s API to make things performant but I am struggling to find how the data connects.

If get the REST API, the paint style has the below object output

    "key": "364b7f55ed6d667ce2583d93df6b6e6c05757c56",
    "file_key": "tccM0bdIgBt1SFL7spGcy1",
    "node_id": "8146:263",
    "style_type": "FILL",
    "thumbnail_url": "",
    "name": "Light/$elevation.surface.hovered",
    "description": "Hovered state of elevation.surface",
    "created_at": "2022-09-25T23:58:41.879Z",
    "updated_at": "2022-09-25T23:58:41.879Z",
    "user": {
        "id": "1092589794519853188",
        "handle": "Lewis Healey",
        "img_url": ""
    "sort_position": "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~LO"

But when I inspect a node within Figma and look for it’s that same paint style and its fillStyleId, I get “S:364b7f55ed6d667ce2583d93df6b6e6c05757c56,8146:5”. I can see the key inside this string but not sure what the 8146:5 is.

I am guessing a part is the node ID but I am unsure what the number represents after the semicolon. Would love to know how I can know that

This full number is an ID and you can discard as it seems like you don’t need it for anything.

1 Like

Thanks Gleb! When I try to replace it without that ID, it seems to error “Error: in set_fillStyleId: Cannot set style successfully: Cannot find style”

You can change fillStyleId to any id you know (local or imported from a library). Notice how the style ids look like:

To use a style from the library, you definitely need to import it into a file. This way it will get a unique id in the file (a unique id is assigned automatically. That is, you cannot know "S:1a2b…n9,unique-id" in advance). If it’s already imported, you can get the style id from the node, or from pluginData/clientStorage if you’ve saved it there.

Ahh ok I see now, you can only use what has already been imported, makes sense! I will importByKey.