Create remote collections and variables via API

Hello everyone, I’m trying to create a remote collection with remote variables to reference another collection created in a different file but I’m failing to accomplish that.

Explaining my scenario:

I’ve created a collection and it’s variables in file one, via API. And now, I have several other files which I’d like to create aliases and reference the variables on the first file.

I can do that manually through the UI, by creating an alias for each variable and pointing it to the variable on my main file. I can also see by querying the theme file with the alias, that a collection with the same id and key, plus a remote=“true” flag, along with the variables are created.

I’ve tried to reproduce this behavior and automate the alias creation by sending these information through the POST variables API, but the remote flag is always false and the IDs I’m sending are being overwritten by new ones, thus losing the reference I’m trying to create.

Is there a way to do what I’m trying to achieve through the API?

1 Like

Hi Diego, creating remote collections + variables directly is not possible because Figma manages and garbage collects these depending on how they’re actually used in the file. But it is also not possible in the POST variables endpoint to alias to variables published from other files unless it they are already used in the current file.

Would love to understand the larger workflow you’re trying to implement using the API. Do you have design tokens that you need to sync to multiple Figma files? What necessitates those variables to live in separate files vs a single file?

Happy to discuss here, but if you prefer a more private channel, please file a support ticket with us and we can continue the conversation there as well.

2 Likes

Hi James, that’s exactly our scenario. We have design tokens and were trying to create theme files and sync all collections with the tokens.

Regarding your questions, we thought we’d be able to organize it better if each theme lived on its own file. But we followed with the approach to create the design tokens and all themes in the same file, but on different collections. We are still testing it out, but it’s looking good so far. Thanks for your input.