Skip to main content
Question

REST API Variable - Impossible to add variable alias


Hello there,

I am creating a script to implement our design system tokens in our Figma files. So I am using the variables API. It works when I created variables with values like COLORS/FLOAT but when I am trying to add alias to another variable it didn’t work.

My first question is, which id should I use to link another variable to it. On this screenshot: "id" or "subscribed_id"?

To explain my situation, I have two files, A and B. File A contains many variables and I want to link my variables in file B to the variables in file A. The library in file A is published and added to file B.

In file A, when I retrieve the published variables, I find my variable:

            "VariableID:62:47": {
                "id": "VariableID:62:47",
                "subscribed_id": "VariableID:f42c18f818106af0843093aaf39f8f68705af7f0/1403:183",
                "name": "border-radius/0",
                "key": "f42c18f818106af0843093aaf39f8f68705af7f0",
                "variableCollectionId": "VariableCollectionId:62:46",
                "resolvedDataType": "FLOAT",
                "updatedAt": "2024-01-19T14:29:13.559Z"
            },

When I want to link to this variable in file B, I get the following error:

{
  status: 400,
  error: true,
  message: 'Invalid alias: VariableID:f42c18f818106af0843093aaf39f8f68705af7f0/1403:183 does not exist (variable: VariableID:128:9, mode: 504:0).'
}

If I try to make this link manually on the Figma website, it works as you can see with this API response:

            "VariableID:128:9": {
                "id": "VariableID:128:9",
                "name": "border-radius/native/0",
                "remote": false,
                "key": "7abc432b27e4538f6ce66421848864a9a021ce81",
                "variableCollectionId": "VariableCollectionId:128:8",
                "resolvedType": "FLOAT",
                "description": "",
                "hiddenFromPublishing": false,
                "valuesByMode": {
                    "128:0": {
                        "type": "VARIABLE_ALIAS",
                        "id": "VariableID:339b4b1cb132b20c5b54a084a8d15841544a6d4e/294:45"
                    },
                    "504:0": {
                        "type": "VARIABLE_ALIAS",
                        "id": "VariableID:f42c18f818106af0843093aaf39f8f68705af7f0/1403:183"
                    },
                }
            }

So, do you think there’s an error with your API or that I’ve got a problem with my code?

This topic has been closed for replies.

7 replies

James_Yang
Figmate
  • Figmate
  • 82 replies
  • January 25, 2024

Hi, you’ve hit an API limitation, which is that you can’t alias a remote variable (a variable from another file) that isn’t already used in the file.

You can do this in the UI because it’s able to make the network calls needed to fetch the variable and all of its dependencies (e.g. the variable collection it is in), but this functionality is currently not available in the API.


Hello, thank you for your reply.
Is this part of the roadmap? If so, do you have any idea when it might be released?


James_Yang
Figmate
  • Figmate
  • 82 replies
  • January 26, 2024

We’ve been aware of this limitation, but don’t have anything currently scheduled to address it.


Ok, thank you for your answer


Ian_Gloude

@James_Yang has there been any change in the roadmap to address this limitation?


Ian_Gloude

Question: would a plugin have the necessary context to make the required network calls you’re referencing here, or are those only available to the app exclusively?


Bryan_Berger

This poses a significant challenge for teams aiming to separate concerns by organizing variables into more highly scoped files, such as a raw palette library that other libraries can consume and reference from.

For teams managing thousands of variables, achieving this effectively requires API support.

Is there any update on the roadmap regarding this?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings