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?