> ## 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 or update a variable value

> Creates a new variable value or updates an existing one if it already exists for the given variable.



## OpenAPI

````yaml /openapi/integration.json post /variables/{variableId}
openapi: 3.0.3
info:
  title: Nudj Integration API
  version: 1.0.0
servers:
  - url: https://{subdomain}.nudj.cx/api/v2/integration
    description: Organization API Server
    variables:
      subdomain:
        description: Your organization's subdomain (required)
        default: your-org
security:
  - ApiToken: []
paths:
  /variables/{variableId}:
    post:
      tags:
        - Variables
      summary: Create or update a variable value
      description: >-
        Creates a new variable value or updates an existing one if it already
        exists for the given variable.
      operationId: upsertVariableValue
      parameters:
        - in: path
          name: variableId
          schema:
            type: string
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                value:
                  type: string
                eventName:
                  type: string
                  enum:
                    - achievement-completion
                    - facebook-comment
                    - facebook-follow
                    - facebook-like
                    - image-analysis-object-detection
                    - image-analysis-receipt-detection
                    - instagram-follow
                    - instagram-like
                    - instagram-comment
                    - instagram-share
                    - instagram-post
                    - interaction-engage-with-content
                    - interaction-external-link
                    - interaction-image-upload
                    - interaction-spot-object
                    - platform-comment-on-post
                    - platform-complete-achievement
                    - platform-generative-action
                    - platform-like-post
                    - platform-play-game
                    - platform-validate-event
                    - question-multiple-choice
                    - question-open-ended
                    - question-rate-your-experience
                    - question-secret-access-code
                    - question-select-date
                    - question-select-from-images
                    - question-select-value-in-range
                    - question-select-from-list
                    - question-closed-ended
                    - question-vote
                    - spotify-follow
                    - spotify-listen
                    - spotify-save
                    - tiktok-follow
                    - tiktok-watch
                    - tiktok-post
                    - youtube-like
                    - youtube-comment
                    - youtube-subscribe
                    - action-completion
                    - skip-action
                    - 42-school
                    - api-auth-link
                    - api-token-link
                    - apple
                    - asgardeo
                    - atlassian
                    - auth0
                    - authentik
                    - azure-ad-b2c
                    - azure-ad
                    - azure-devops
                    - battlenet
                    - beyondidentity
                    - box
                    - boxyhq-saml
                    - bungie
                    - click-up
                    - cognito
                    - coinbase
                    - descope
                    - discord
                    - dribbble
                    - dropbox
                    - duende-identity-server6
                    - email
                    - eveonline
                    - facebook
                    - faceit
                    - foursquare
                    - freshbooks
                    - fusionauth
                    - github
                    - gitlab
                    - google
                    - hubspot
                    - identity-server4
                    - instagram
                    - kakao
                    - keycloak
                    - line
                    - linkedin
                    - mailchimp
                    - mailru
                    - mastodon
                    - mattermost
                    - medium
                    - naver
                    - netlify
                    - notion
                    - okta
                    - onelogin
                    - organisation-oidc
                    - osso
                    - osu
                    - passage
                    - patreon
                    - pinterest
                    - pipedrive
                    - reddit
                    - salesforce
                    - slack
                    - spotify
                    - strava
                    - tiktok
                    - todoist
                    - trakt
                    - twitch
                    - twitter
                    - united-effects
                    - vk
                    - wikimedia
                    - wordpress
                    - workos
                    - yandex
                    - youtube
                    - zitadel
                    - zoho
                    - zoom
                    - blog-comment
                    - blog-like
                    - blog-share
                    - blog-view
                    - challenge-started
                    - challenge-completion
                    - challenge-unlock
                    - community-visit
                    - parental-approval-requested
                    - parental-approval-approved
                    - parental-approval-rejected
                    - custom
                    - game-started
                    - game-completed
                    - leaderboard-finish
                    - invite-admin-user
                    - points-credit
                    - points-spend
                    - post-comment
                    - post-like
                    - post-view
                    - reward-redemption
                    - reward-allocation-purchase
                    - reward-giveaway-winner
                    - reward-claim
                    - reward-distribution
                    - manual-distribution
                    - referral-link-used
                    - shop-purchase
                    - share-challenge-details
                    - share-challenge-results
                    - share-community
                    - share-reward
                    - share-post
                    - share-profile
                    - share-anything
                    - streak-extended
                    - profile-picture-added
                    - bio-added
                    - variable-captured
                    - xp-gained
                    - xp-total
                    - xp-leaderboard-topper
                eventId:
                  type: string
              required:
                - value
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Variable'
        '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:
    Variable:
      type: object
      properties:
        id:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: The id of the variable
        organisationId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: The organisation that the variable 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
          nullable: true
          description: The placeholder text for the variable
        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 value for this variable
        isImmutable:
          type: boolean
          description: Whether the value, once set by a user, cannot be changed
        value:
          type: string
          nullable: true
          description: >-
            The value of the variable. For select variables, this refers to the
            key of the selected option
        valueCaptureDate:
          type: string
          nullable: true
          description: The date when the value was captured
        valueValidationDate:
          type: string
          nullable: true
          description: The date when the value was validated
        useDefaultProfileValue:
          type: boolean
          description: Whether to use the default profile value
        prerequisiteVariableConfigIds:
          type: array
          nullable: true
          items:
            type: string
            pattern: ^[0-9a-fA-F]{24}$
          description: The variable configs that must be completed before this one
        options:
          type: array
          nullable: true
          items:
            type: object
            properties:
              key:
                type: string
              value:
                type: string
            required:
              - key
              - value
          description: The possible options for this variable
      required:
        - id
        - organisationId
        - type
        - name
        - label
        - maxValueOccurrences
        - isSingleOutputPerUser
        - isImmutable
        - useDefaultProfileValue
      title: Variable
      description: A variable
    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
              path:
                type: array
                items:
                  oneOf:
                    - type: string
                    - type: integer
                description: The path to the field that caused the error
            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
              path:
                type: array
                items:
                  oneOf:
                    - type: string
                    - type: integer
                description: The path to the field that caused the error
            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

````