Tokens

Read, create, update or delete tokens of a specific design system.

To manipulate the tokens, access the tokens object on the SDK. Through that, you can invoke all tokens methods mentioned, like this:


                                                        
                                                        
                                                            await sdk.tokens.deleteToken({
                                                          designSystemId, versionId
                                                        }, token.idInVersion)
                                                        
                                                            

Read methods

Get tokens

Fetches all remote tokens in a specified version with optional filtering.


                                                        
                                                        
                                                            async getTokens(
                                                          from: RemoteVersionIdentifier,
                                                          filter?: {
                                                            type?: TokenType;
                                                            brandId?: string;
                                                          }
                                                        ): Promise<Array<Token>>
                                                        
                                                            

Get token usage

Retrieves all occurrences of a specified token in a version, including its usages in other tokens, components, and documentation pages. This method returns persistent identifiers of tokens, components, and documentation pages containing the specified token.


                                                        
                                                        
                                                            async getTokenUsage(
                                                          from: RemoteVersionIdentifier,
                                                          idInVersion: string
                                                        ): Promise<{
                                                          tokens: Array<string>;
                                                          components: Array<string>;
                                                          documentationPages: Array<string>;
                                                        }>
                                                        
                                                            

Fetch token groups

Fetches all remote token groups in a version with optional filtering. Use this method to retrieve token groups from a specific design system version, with filtering options based on type or brand.


                                                        
                                                        
                                                            async getTokenGroups(
                                                          from: RemoteVersionIdentifier,
                                                          filter?: {
                                                            type?: TokenType;
                                                            brandId?: string;
                                                          }
                                                        ): Promise<Array<TokenGroup>>
                                                        
                                                            

Get token themes

Fetches all remote themes in a version. This method retrieves all themes in the specified design system version.


                                                        
                                                        
                                                            async getTokenThemes(
                                                          from: RemoteVersionIdentifier
                                                        ): Promise<Array<TokenTheme>>
                                                        
                                                            

Get token properties

Retrieves all remote property definitions for tokens. Use this method to fetch all property definitions in the specified design system version related to tokens.


                                                        
                                                        
                                                            async getTokenThemes(
                                                          from: RemoteVersionIdentifier
                                                        ): Promise<Array<TokenTheme>>
                                                        
                                                            

Get token property values

Retrieves all remote property values for tokens.


                                                        
                                                        
                                                            async getTokenThemes(
                                                          from: RemoteVersionIdentifier
                                                        ): Promise<Array<TokenTheme>>
                                                        
                                                            

Get token data views

Retrieves all remote property views for tokens. This method fetches all property views in the specified design system version related to tokens.


                                                        
                                                        
                                                            async getTokenDataViews(
                                                          from: RemoteVersionIdentifier
                                                        ): Promise<Array<ElementDataView>>
                                                        
                                                            

Create/update methods

Create token

Creates a remote token in a version, assigning a persistent ID to the token. This method creates a new remote token in the specified design system version and adds it to a token group. The parentId parameter is the ID of the group to which the token is added.


                                                        
                                                        
                                                            async createToken(
                                                          to: RemoteVersionIdentifier,
                                                          token: Token,
                                                          parentId: string
                                                        ): Promise<{
                                                          id: string;
                                                          idInVersion: string;
                                                        }>
                                                        
                                                            

Create local token

Creates a local token without an associated remote ID. This token must be created remotely using createToken. Use this method to create a new local token of the specified type with default values. The token will not have a remote ID until created remotely.


                                                        
                                                        
                                                            createLocalToken<T extends TokenType>(
                                                          tokenType: T,
                                                          versionId: string,
                                                          brandId: string,
                                                          properties: Array<ElementProperty>
                                                        ): TokenTypeMapToken[T]
                                                        
                                                            

Create local theme override

Creates a local token override without an associated remote ID. This method creates a local token override for a specific theme without an associated remote ID. It is used to customize token properties for a theme.


                                                        
                                                        
                                                            createLocalThemeOverride<T extends AnyToken>(
                                                          theme: TokenTheme,
                                                          baseToken: T
                                                        ): T
                                                        
                                                            

Create token group

Creates a remote token group in a version, assigning a persistent ID to the group. Use this method to create a new remote token group in the specified design system version and add it to another token group. The parentId parameter is the ID of the group to which the new group is added.


                                                        
                                                        
                                                            async createTokenGroup(
                                                          to: RemoteVersionIdentifier,
                                                          group: TokenGroup,
                                                          parentId: string
                                                        ): Promise<{
                                                          id: string;
                                                          idInVersion: string;
                                                        }>
                                                        
                                                            

Create local token group

Creates a local token group without an associated remote ID.


                                                        
                                                        
                                                            createLocalTokenGroup(
                                                          tokenType: TokenType,
                                                          versionId: string,
                                                          brandId: string
                                                        ): TokenGroup
                                                        
                                                            

Update token

Updates a remote token in a version.


                                                        
                                                        
                                                            async updateToken(
                                                          to: RemoteVersionIdentifier,
                                                          token: Token
                                                        ): Promise<void>
                                                        
                                                            

Update token group

Updates a remote token group in a version.


                                                        
                                                        
                                                            async updateTokenGroup(
                                                          to: RemoteVersionIdentifier,
                                                          group: TokenGroup
                                                        ): Promise<void>
                                                        
                                                            

Update token property value

Updates or creates a remote token property value.


                                                        
                                                        
                                                            async updateTokenPropertyValue(
                                                          to: RemoteVersionIdentifier,
                                                          newValue: string,
                                                          forToken: Token,
                                                          forProperty: ElementProperty
                                                        )
                                                        
                                                            

Resize token column

Resizes a specific token column in a property view.


                                                        
                                                        
                                                            async updateResizeTokenColumn(
                                                          to: RemoteVersionIdentifier,
                                                          view: ElementDataView,
                                                          column: ElementDataViewColumn,
                                                          newWidth: number
                                                        ): Promise<void>
                                                        
                                                            

Reorder token column

Moves a column to a new index and reorders all other columns around it in a property view.


                                                        
                                                        
                                                            async updateReorderTokenColumn(
                                                          to: RemoteVersionIdentifier,
                                                          view: ElementDataView,
                                                          column: ElementDataViewColumn,
                                                          newIndex: number
                                                        ): Promise<void>
                                                        
                                                            

Create local token theme

Creates a local token theme without an associated remote ID.


                                                        
                                                        
                                                            
                                                        createLocalTokenTheme(versionId: string, brandId: string): TokenTheme
                                                        
                                                            

Create token theme

Creates a remote token theme in a version, assigning a persistent ID to the theme.


                                                        
                                                        
                                                            async createTokenTheme(
                                                          to: RemoteVersionIdentifier,
                                                          theme: TokenTheme
                                                        ): Promise<{
                                                          id: string;
                                                          idInVersion: string;
                                                        }>
                                                        
                                                            

Delete methods

Delete token property value

Deletes a remote token property value.


                                                        
                                                        
                                                            async deleteTokenPropertyValue(
                                                          to: RemoteVersionIdentifier,
                                                          valueId: string
                                                        ): Promise<void>
                                                        
                                                            

Delete token property

Deletes a remote token property and removes all associated values.


                                                        
                                                        
                                                            async deleteTokenProperty(
                                                          to: RemoteVersionIdentifier,
                                                          propertyIdInVersion: string
                                                        ): Promise<void>
                                                        
                                                            

Delete token

Deletes a remote token from a version.


                                                        
                                                        
                                                            async deleteToken(
                                                          to: RemoteVersionIdentifier,
                                                          tokenIdInVersion: string
                                                        ): Promise<void>
                                                        
                                                            

Ungroup token group

Deletes a remote token group and adjusts the token group tree by moving subgroups to the parent group. This method does not delete the contents of the group.


                                                        
                                                        
                                                            async ungroupTokenGroup(
                                                          to: RemoteVersionIdentifier,
                                                          tokenGroupIdInVersion: string
                                                        ): Promise<void>
                                                        
                                                            

Delete token group

Deletes a remote token group and all its descendants, including tokens and subgroups. This method will remove all items (groups and tokens) underneath the deleted group.


                                                        
                                                        
                                                            async deleteTokenGroup(
                                                          to: RemoteVersionIdentifier,
                                                          tokenGroupToDelete: TokenGroup,
                                                          tokens: Array<Token>,
                                                          tokenGroups: Array<TokenGroup>
                                                        ): Promise<void>
                                                        
                                                            

Delete token theme

Deletes a remote token theme, including all theme overrides and disconnection from assigned columns.


                                                        
                                                        
                                                            async deleteTokenTheme(
                                                          to: RemoteVersionIdentifier,
                                                          idInVersion: string
                                                        ): Promise<void>
                                                        
                                                            

Compute methods

Compute tokens by applying themes

Resolves tokens by applying themes to them and retrieves a new token set where values correctly correspond to the applied theme.


                                                        
                                                        
                                                            async computeTokensByApplyingThemes(
                                                          tokens: Array<Token>,
                                                          themes: Array<TokenTheme>
                                                        ): Promise<Array<Token>>
                                                        
                                                            

Compute group trees

Separates groups by types and organizes them into a map.


                                                        
                                                        
                                                            async computeGroupTrees(
                                                          groups: Array<TokenGroup>
                                                        ): Promise<Map<TokenType, Array<TokenGroup>>>