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

# Upsert env variable

> Create or update env variable by scope + key. scopeId is required for app and automation scope.



## OpenAPI

````yaml /swagger.json post /env-variable
openapi: 3.0.0
info:
  version: 1.0.0
  title: Teable App
  description: Manage Data as easy as drink a cup of tea
  x-logo:
    backgroundColor: '#F0F0F0'
    altText: Teable logo
servers:
  - url: https://app.teable.ai/api
security: []
tags:
  - name: base
    x-group: project
  - name: base node
    x-group: project node
  - name: base-share
    x-group: project-share
paths:
  /env-variable:
    post:
      tags:
        - env-variable
      summary: Upsert env variable
      description: >-
        Create or update env variable by scope + key. scopeId is required for
        app and automation scope.
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    scope:
                      type: string
                      enum:
                        - user
                    scopeId:
                      type: string
                    key:
                      type: string
                      pattern: ^[A-Z][A-Z0-9_]{0,63}$
                    value:
                      type: string
                      minLength: 1
                      maxLength: 8192
                    description:
                      type: string
                      nullable: true
                  required:
                    - scope
                    - key
                    - value
                - type: object
                  properties:
                    scope:
                      type: string
                      enum:
                        - app
                    scopeId:
                      type: string
                    key:
                      type: string
                      pattern: ^[A-Z][A-Z0-9_]{0,63}$
                    value:
                      type: string
                      minLength: 1
                      maxLength: 8192
                    description:
                      type: string
                      nullable: true
                  required:
                    - scope
                    - scopeId
                    - key
                    - value
                - type: object
                  properties:
                    scope:
                      type: string
                      enum:
                        - automation
                    scopeId:
                      type: string
                    key:
                      type: string
                      pattern: ^[A-Z][A-Z0-9_]{0,63}$
                    value:
                      type: string
                      minLength: 1
                      maxLength: 8192
                    description:
                      type: string
                      nullable: true
                  required:
                    - scope
                    - scopeId
                    - key
                    - value
      responses:
        '201':
          description: Created or updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  scope:
                    type: string
                    enum:
                      - user
                      - app
                      - automation
                  scopeId:
                    type: string
                  key:
                    type: string
                  description:
                    type: string
                    nullable: true
                  createdBy:
                    type: string
                  lastModifiedBy:
                    type: string
                    nullable: true
                  createdTime:
                    type: string
                  lastModifiedTime:
                    type: string
                    nullable: true
                required:
                  - id
                  - scope
                  - scopeId
                  - key
                  - createdBy
                  - createdTime
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          source: |-
            curl --request POST \
              --url https://app.teable.ai/api/env-variable \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"scope":"user","scopeId":"string","key":"string","value":"string","description":"string"}'
        - lang: JavaScript
          source: |-
            const url = 'https://app.teable.ai/api/env-variable';
            const options = {
              method: 'POST',
              headers: {
                Authorization: 'Bearer REPLACE_BEARER_TOKEN',
                'content-type': 'application/json'
              },
              body: '{"scope":"user","scopeId":"string","key":"string","value":"string","description":"string"}'
            };

            try {
              const response = await fetch(url, options);
              const data = await response.json();
              console.log(data);
            } catch (error) {
              console.error(error);
            }
        - lang: Node.js
          source: |-
            const http = require('https');

            const options = {
              method: 'POST',
              hostname: 'app.teable.ai',
              port: null,
              path: '/api/env-variable',
              headers: {
                Authorization: 'Bearer REPLACE_BEARER_TOKEN',
                'content-type': 'application/json'
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on('data', function (chunk) {
                chunks.push(chunk);
              });

              res.on('end', function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              scope: 'user',
              scopeId: 'string',
              key: 'string',
              value: 'string',
              description: 'string'
            }));
            req.end();
        - lang: Python
          source: >-
            import http.client


            conn = http.client.HTTPSConnection("app.teable.ai")


            payload =
            "{\"scope\":\"user\",\"scopeId\":\"string\",\"key\":\"string\",\"value\":\"string\",\"description\":\"string\"}"


            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
            }


            conn.request("POST", "/api/env-variable", payload, headers)


            res = conn.getresponse()

            data = res.read()


            print(data.decode("utf-8"))
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````