Variables
Create Variables
Create new variables and variable collections in a Figma file.
Create new variables and/or variable collections in a file. This is the primary endpoint for syncing design tokens from code to Figma.
POST https://api.figma.com/v1/files/:file_key/variables
Authentication
Requires a valid access token with file_content:write scope. Pass via X-Figma-Token header (personal access token) or Authorization: Bearer header (OAuth).
Parameters
Path parameters
The key of the file to create variables in.
Request Body
The request body is a JSON object with three optional arrays: variableCollections, variableModes, and variables. Each item must have "action": "CREATE".
| Field | Type | Required | Description |
|---|---|---|---|
variableCollections | array | No | Collections to create |
variableModes | array | No | Modes to create within collections |
variables | array | No | Variables to create within collections |
Example Request
Response
Returns the created resources with permanent IDs mapped from temporary IDs.
{
"meta": {
"tempIdMapping": {
"temp_collection_1": "VariableCollectionId:5:0",
"temp_mode_1": "5:0",
"temp_var_1": "VariableID:5:1",
"temp_var_2": "VariableID:5:2"
}
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
meta.tempIdMapping | object | Map of temporary IDs to permanent Figma IDs |
Temporary IDs (prefixed with temp_) are replaced with permanent Figma IDs in the response. Store this mapping if your system needs to reference the created resources in future API calls.