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

# Post base chatexecute script

> Execute TypeScript code in sandbox for chat tools



## OpenAPI

````yaml /swagger.json post /base/{baseId}/chat/execute-script
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: []
paths:
  /base/{baseId}/chat/execute-script:
    post:
      tags:
        - chat
      description: Execute TypeScript code in sandbox for chat tools
      parameters:
        - schema:
            type: string
          required: true
          name: baseId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                code:
                  type: string
                  description: TypeScript code to execute
                input:
                  type: object
                  additionalProperties:
                    nullable: true
                  description: Input parameters for the script
                integrationIds:
                  type: array
                  items:
                    type: string
                  description: Integration IDs to inject into script context
                dependencies:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                      version:
                        type: string
                    required:
                      - name
                      - version
                  description: NPM dependencies to install
              required:
                - code
      responses:
        '200':
          description: Script execution result
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  result:
                    type: object
                    additionalProperties:
                      nullable: true
                  logs:
                    type: object
                    properties:
                      stdout:
                        type: string
                      stderr:
                        type: string
                    required:
                      - stdout
                      - stderr
                  executionTime:
                    type: number
                  error:
                    type: string
                required:
                  - success
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          source: |-
            curl --request POST \
              --url https://app.teable.ai/api/base/%7BbaseId%7D/chat/execute-script \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"code":"string","input":{"property1":null,"property2":null},"integrationIds":["string"],"dependencies":[{"name":"string","version":"string"}]}'
        - lang: JavaScript
          source: >-
            const url =
            'https://app.teable.ai/api/base/%7BbaseId%7D/chat/execute-script';

            const options = {
              method: 'POST',
              headers: {
                Authorization: 'Bearer REPLACE_BEARER_TOKEN',
                'content-type': 'application/json'
              },
              body: '{"code":"string","input":{"property1":null,"property2":null},"integrationIds":["string"],"dependencies":[{"name":"string","version":"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/base/%7BbaseId%7D/chat/execute-script',
              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({
              code: 'string',
              input: {property1: null, property2: null},
              integrationIds: ['string'],
              dependencies: [{name: 'string', version: 'string'}]
            }));
            req.end();
        - lang: Python
          source: >-
            import http.client


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


            payload =
            "{\"code\":\"string\",\"input\":{\"property1\":null,\"property2\":null},\"integrationIds\":[\"string\"],\"dependencies\":[{\"name\":\"string\",\"version\":\"string\"}]}"


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


            conn.request("POST", "/api/base/%7BbaseId%7D/chat/execute-script",
            payload, headers)


            res = conn.getresponse()

            data = res.read()


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

````