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

# Create a new variable config

> Creates a new variable configuration for collecting user data.



## OpenAPI

````yaml /openapi/admin.json post /variables
openapi: 3.1.0
info:
  title: Nudj Admin API
  version: 1.0.0
servers:
  - url: https://{subdomain}.nudj.cx/api/v2/admin
    description: Organization API Server
    variables:
      subdomain:
        description: Your organization's subdomain (required)
        default: your-org
security:
  - ApiToken: []
paths:
  /variables:
    post:
      tags:
        - Variable
      summary: Create a new variable config
      description: Creates a new variable configuration for collecting user data.
      operationId: createVariableConfig
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: The name of the variable
                type:
                  type: string
                  enum:
                    - form-short-text
                    - form-long-text
                    - form-number
                    - form-select
                    - form-checkbox
                    - form-email
                    - form-name
                    - form-address
                    - form-date
                  description: >-
                    Determines how the variable should be rendered in the UI
                    (e.g., text input, select dropdown, date picker, etc.)
                label:
                  type: string
                  description: The label of the variable
                placeholder:
                  type:
                    - string
                    - 'null'
                  description: The placeholder text
                useDefaultProfileValue:
                  type: boolean
                  description: Whether to use the default profile value
                availableInQuestionBank:
                  type: boolean
                  description: Whether this variable is available in the question bank
                maxValueOccurrences:
                  type: number
                  minimum: 1
                  description: >-
                    The maximum number of times a unique value can be used
                    across all instances of this variable
                isSingleOutputPerUser:
                  type: boolean
                  description: Whether a user can only have one output for this variable
                isImmutable:
                  type: boolean
                  description: Whether the value, once set by a user, cannot be changed
                prerequisiteVariableConfigIds:
                  type:
                    - array
                    - 'null'
                  items:
                    type: string
                    pattern: ^[0-9a-fA-F]{24}$
                  description: The variable configs that must be completed before this one
                options:
                  type:
                    - array
                    - 'null'
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                      value:
                        type: string
                    required:
                      - key
                      - value
                  description: >-
                    An array of predefined values that users can choose from
                    when the type is set to select
                validationRegex:
                  type:
                    - string
                    - 'null'
                  description: >-
                    Regular expression pattern to validate variable values. If
                    set, values must match this pattern.
              required:
                - name
                - type
              description: The input required to create a variable config
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VariableConfig'
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
components:
  schemas:
    VariableConfig:
      type: object
      properties:
        id:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: The id of the variable config
        organisationId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: The organisation that the variable config belongs to
        type:
          type: string
          enum:
            - form-short-text
            - form-long-text
            - form-number
            - form-select
            - form-checkbox
            - form-email
            - form-name
            - form-address
            - form-date
          description: >-
            Determines how the variable should be rendered in the UI (e.g., text
            input, select dropdown, date picker, etc.)
        name:
          type: string
          description: The name of the variable
        label:
          type: string
          description: The label of the variable
        placeholder:
          type:
            - string
            - 'null'
          description: The placeholder text
        useDefaultProfileValue:
          type: boolean
          description: Whether to use the default profile value
        availableInQuestionBank:
          type: boolean
          description: Whether this variable is available in the question bank
        maxValueOccurrences:
          type: number
          minimum: 1
          description: >-
            The maximum number of times a unique value can be used across all
            instances of this variable
        isSingleOutputPerUser:
          type: boolean
          description: Whether a user can only have one output for this variable
        isImmutable:
          type: boolean
          description: Whether the value, once set by a user, cannot be changed
        prerequisiteVariableConfigIds:
          type:
            - array
            - 'null'
          items:
            type: string
            pattern: ^[0-9a-fA-F]{24}$
          description: The variable configs that must be completed before this one
        options:
          type:
            - array
            - 'null'
          items:
            type: object
            properties:
              key:
                type: string
              value:
                type: string
            required:
              - key
              - value
          description: >-
            An array of predefined values that users can choose from when the
            type is set to select
        validationRegex:
          type:
            - string
            - 'null'
          description: >-
            Regular expression pattern to validate variable values. If set,
            values must match this pattern.
        validationEndpointConfig:
          type:
            - object
            - 'null'
          properties:
            url:
              type: string
              format: uri
            method:
              type: string
            headers:
              type:
                - object
                - 'null'
              additionalProperties:
                type: string
          required:
            - url
            - method
          description: Configuration for validating variable values
        createdAt:
          type: string
          description: The date when this variable config was created
        createdBy:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: The user who created this variable config
        updatedAt:
          type:
            - string
            - 'null'
          description: The date when this variable config was last updated
        updatedBy:
          type:
            - string
            - 'null'
          pattern: ^[0-9a-fA-F]{24}$
          description: The user who last updated this variable config
      required:
        - id
        - organisationId
        - type
        - name
        - label
        - useDefaultProfileValue
        - availableInQuestionBank
        - maxValueOccurrences
        - isSingleOutputPerUser
        - isImmutable
        - createdAt
        - createdBy
      title: Variable Config
      description: A variable configuration
    error.BAD_REQUEST:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Invalid input data
        code:
          type: string
          description: The error code
          example: BAD_REQUEST
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
    error.INTERNAL_SERVER_ERROR:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Internal server error
        code:
          type: string
          description: The error code
          example: INTERNAL_SERVER_ERROR
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
  securitySchemes:
    ApiToken:
      type: apiKey
      in: header
      name: x-api-token

````