> ## Documentation Index
> Fetch the complete documentation index at: https://developer.dittowords.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These are Ditto's developer docs. Ditto is a single source of truth for product copy across design, review, localization, and code.
> The first step on any codebase is a scan: https://developer.dittowords.com/get-started/scan-your-repo.md. That page also covers reviewing the style guide Ditto drafts from the scan. After it, the follow-on guides are Connect Figma files and Set up localization (under /guides/) and Connect the Ditto MCP (the Setup page of the MCP reference).
> Two different MCP servers: the Ditto MCP server at https://api.dittowords.com/v2/mcp gives an agent a workspace's text and style guide rules; the documentation MCP server at https://developer.dittowords.com/mcp searches these docs.
> Prefer logging in with a Ditto account (npx -y @dittowords/cli@latest login; OAuth in MCP clients) over API keys. API keys are for CI and headless clients only.
> Commands are complete as written and use npx -y @dittowords/cli@latest; nothing needs a global install.

# Create variables

> Creates variables in your workspace.

The shape of `data` depends on `type`: string and number take an `example` and an optional `fallback`, hyperlink takes `text` and `url`, list takes an array of strings, and map takes an object of string keys to string values.

Either every variable is created or none is.



## OpenAPI

````yaml openapi.json post /variables
openapi: 3.0.0
info:
  version: 1.0.0
  title: Ditto API
  description: Programmatically read and write data in your Ditto workspace.
servers:
  - url: https://api.dittowords.com/v2
security: []
paths:
  /variables:
    post:
      tags:
        - Variables
      summary: Create variables
      description: >-
        Creates variables in your workspace.


        The shape of `data` depends on `type`: string and number take an
        `example` and an optional `fallback`, hyperlink takes `text` and `url`,
        list takes an array of strings, and map takes an object of string keys
        to string values.


        Either every variable is created or none is.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                variables:
                  type: array
                  items:
                    oneOf:
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - string
                          data:
                            type: object
                            properties:
                              example:
                                type: string
                              fallback:
                                type: string
                            required:
                              - example
                          name:
                            type: string
                            pattern: ^[A-Za-z0-9_]+$
                            description: >-
                              The variable's name, which doubles as its
                              developer ID. Letters, numbers, and underscores
                              only, and unique within the workspace.
                        required:
                          - type
                          - data
                          - name
                        title: String
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - number
                          data:
                            type: object
                            properties:
                              example:
                                anyOf:
                                  - type: number
                                    title: Number
                                  - type: string
                                    title: String
                              fallback:
                                anyOf:
                                  - type: number
                                    title: Number
                                  - type: string
                                    title: String
                            required:
                              - example
                          name:
                            type: string
                            pattern: ^[A-Za-z0-9_]+$
                            description: >-
                              The variable's name, which doubles as its
                              developer ID. Letters, numbers, and underscores
                              only, and unique within the workspace.
                        required:
                          - type
                          - data
                          - name
                        title: Number
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - hyperlink
                          data:
                            type: object
                            properties:
                              text:
                                type: string
                              url:
                                type: string
                            required:
                              - text
                              - url
                          name:
                            type: string
                            pattern: ^[A-Za-z0-9_]+$
                            description: >-
                              The variable's name, which doubles as its
                              developer ID. Letters, numbers, and underscores
                              only, and unique within the workspace.
                        required:
                          - type
                          - data
                          - name
                        title: Hyperlink
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - list
                          data:
                            type: array
                            items:
                              type: string
                          name:
                            type: string
                            pattern: ^[A-Za-z0-9_]+$
                            description: >-
                              The variable's name, which doubles as its
                              developer ID. Letters, numbers, and underscores
                              only, and unique within the workspace.
                        required:
                          - type
                          - data
                          - name
                        title: List
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - map
                          data:
                            type: object
                            additionalProperties:
                              type: string
                          name:
                            type: string
                            pattern: ^[A-Za-z0-9_]+$
                            description: >-
                              The variable's name, which doubles as its
                              developer ID. Letters, numbers, and underscores
                              only, and unique within the workspace.
                        required:
                          - type
                          - data
                          - name
                        title: Map
                  minItems: 1
                  description: Array of new variables to create
              required:
                - variables
              example:
                variables:
                  - name: user_name
                    type: string
                    data:
                      example: Jane Doe
                      fallback: there
                  - name: help_link
                    type: hyperlink
                    data:
                      text: Learn more
                      url: https://dittowords.com
      responses:
        '200':
          description: Returns the names of the created variables
          content:
            application/json:
              schema:
                type: object
                properties:
                  names:
                    type: array
                    items:
                      type: string
                    description: Names of the created variables, in request order
                required:
                  - names
                example:
                  names:
                    - user_name
                    - help_link
        '400':
          description: >-
            Returned when the request body fails validation. Common causes
            include: a name that isn't unique in the workspace, a name repeated
            within the request, or data that doesn't match the variable's type.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.