POST /v1/files/{file_key}/variables
This API is available to full members of Enterprise orgs with Editor seats.
The POST /v1/files/:file_key/variables endpoint lets you bulk create, update, and delete variables and variable collections.
The request body supports the following 4 top-level arrays. Changes from these arrays will be applied in the below order, and within each array, by array order.
- variableCollections: For creating, updating, and deleting variable collections
- variableModes: For creating, updating, and deleting modes within variable collections
- Each collection can have a maximum of 40 modes
- Mode names cannot be longer than 40 characters
- variables: For creating, updating, and deleting variables
- Each collection can have a maximum of 5000 variables
- Variable names must be unique within a collection and cannot contain certain special characters such as
.{}
- variableModeValues: For setting a variable value under a specific mode.
- When setting aliases, a variable cannot be aliased to itself or form an alias cycle
Temporary ids can be used to reference an object later in the same POST request body. They can be used at create time in the id property of variable collections, modes, variables, and in the initialModeId property of variable collections. They are scoped to a single request body, and must be unique within the body. The mapping of temporary ids to real ids is returned in the response.
This endpoint has the following key behaviors:
- The request body must be 4MB or less.
- Must include an
actionproperty for collections, modes, and variables to tell the API whether to create, update, or delete the object. - When creating a collection, mode, or variable, you can include a temporary
idthat can be referenced in dependent objects in the same request. For example, you can create a new collection with the id"my_new_collection". You can then setvariableCollectionIdto"my_new_collection"in new modes or variables. Temporary ids must be unique in the request body. - New collections always come with one mode. You can reference this mode by setting
initialModeIdto a temporary id in the request body. This is useful if you want to set values for variables in the mode in thevariableModeValuesarray.- The
tempIdToRealIdarray returns a mapping of the temporary ids in the request, to the real ids of the newly created objects.
- The
- When adding new modes or variables, default variable values will be applied, consistent with what happens in the UI.
- Everything to be created, updated, and deleted in the request body is treated as one atomic operation. If there is any validation failure, you will get a 400 status code response, and no changes will be persisted.
- You will not be able to update remote variables or variable collections. You can only update variables in the file where they were originally created.
Servers
- https://api.figma.com
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
file_key |
String | Yes |
File to modify variables in. This can be a file key or branch key. Use |
Request headers
| Name | Type | Required | Description |
|---|---|---|---|
Content-Type |
String | Yes |
The media type of the request body.
Default value: "application/json" |
Request body fields
| Name | Type | Required | Description |
|---|---|---|---|
variableModes[] |
Array | No |
For creating, updating, and deleting modes within variable collections. |
variableModeValues[] |
Array | No |
For setting a specific value, given a variable and a mode. |
variableModeValues[].variableId |
String | Yes |
The target variable. You can use the temporary id of a variable. |
variableModeValues[].modeId |
String | Yes |
Must correspond to a mode in the variable collection that contains the target variable. |
variableModeValues[].value |
Yes |
The value for the variable. The value must match the variable's type. If setting to a variable alias, the alias must resolve to this type. If overriding a value, the value type must match the variable's type. If removing an overridden value, the value must be |
|
variableCollections[] |
Array | No |
For creating, updating, and deleting variable collections. |
variables[] |
Array | No |
For creating, updating, and deleting variables. |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.