> ## 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.

# Create variables

> Creates variables in your workspace. A variable's name is also its developer ID, so it must be unique in the 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. A variable's name is also its
        developer ID, so it must be unique in the 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
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - number
                          data:
                            type: object
                            properties:
                              example:
                                anyOf:
                                  - type: number
                                  - type: string
                              fallback:
                                anyOf:
                                  - type: number
                                  - 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
                      - 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
                      - 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
                      - 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
                  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

````