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?

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?

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

Ok, thank you for your answer

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

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?