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

# Create a personal secret

> Store a secret under the caller (write-only) and optionally grant it to a resource in the same call. The value never leaves the server afterwards.



## OpenAPI

````yaml /swagger.json post /credential/secret
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:
  /credential/secret:
    post:
      tags:
        - credential
      summary: Create a personal secret
      description: >-
        Store a secret under the caller (write-only) and optionally grant it to
        a resource in the same call. The value never leaves the server
        afterwards.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                key:
                  type: string
                  pattern: ^[A-Z][A-Z0-9_]{0,63}$
                value:
                  type: string
                  minLength: 1
                  maxLength: 8192
                description:
                  type: string
                  nullable: true
                  maxLength: 500
                onConflict:
                  type: string
                  enum:
                    - error
                    - rotate
                grantTo:
                  type: object
                  properties:
                    resourceType:
                      type: string
                      enum:
                        - automation
                        - app
                    resourceId:
                      type: string
                      minLength: 1
                    alias:
                      type: string
                      pattern: ^[A-Z][A-Z0-9_]{0,63}$
                    replace:
                      type: boolean
                  required:
                    - resourceType
                    - resourceId
              required:
                - key
                - value
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  secret:
                    type: object
                    properties:
                      id:
                        type: string
                      key:
                        type: string
                      description:
                        type: string
                        nullable: true
                      createdTime:
                        type: string
                      lastModifiedTime:
                        type: string
                        nullable: true
                      usages:
                        type: array
                        items:
                          type: object
                          properties:
                            grantId:
                              type: string
                            alias:
                              type: string
                            resourceType:
                              type: string
                              enum:
                                - automation
                                - app
                            resourceId:
                              type: string
                            resourceName:
                              type: string
                              nullable: true
                            resourceDeleted:
                              type: boolean
                            baseId:
                              type: string
                            baseName:
                              type: string
                              nullable: true
                            spaceId:
                              type: string
                              nullable: true
                            spaceName:
                              type: string
                              nullable: true
                            inSpace:
                              type: boolean
                            createdTime:
                              type: string
                          required:
                            - grantId
                            - alias
                            - resourceType
                            - resourceId
                            - resourceName
                            - resourceDeleted
                            - baseId
                            - baseName
                            - spaceId
                            - spaceName
                            - inSpace
                            - createdTime
                    required:
                      - id
                      - key
                      - description
                      - createdTime
                      - lastModifiedTime
                      - usages
                  grant:
                    type: object
                    properties:
                      id:
                        type: string
                      credentialType:
                        type: string
                        enum:
                          - secret
                          - connection
                      credentialId:
                        type: string
                      alias:
                        type: string
                      resourceType:
                        type: string
                        enum:
                          - automation
                          - app
                      resourceId:
                        type: string
                      baseId:
                        type: string
                      owner:
                        type: object
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                          avatar:
                            type: string
                            nullable: true
                          inSpace:
                            type: boolean
                          isMe:
                            type: boolean
                        required:
                          - id
                          - name
                          - avatar
                          - inSpace
                          - isMe
                      credential:
                        type: object
                        properties:
                          name:
                            type: string
                          key:
                            type: string
                          provider:
                            type: string
                          source:
                            type: string
                            enum:
                              - native
                              - composio
                          account:
                            type: string
                            nullable: true
                          description:
                            type: string
                            nullable: true
                          missing:
                            type: boolean
                        required:
                          - name
                          - missing
                      createdTime:
                        type: string
                    required:
                      - id
                      - credentialType
                      - credentialId
                      - alias
                      - resourceType
                      - resourceId
                      - baseId
                      - owner
                      - credential
                      - createdTime
                required:
                  - secret
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          source: |-
            curl --request POST \
              --url https://app.teable.ai/api/credential/secret \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"key":"string","value":"string","description":"string","onConflict":"error","grantTo":{"resourceType":"automation","resourceId":"string","alias":"string","replace":true}}'
        - lang: JavaScript
          source: |-
            const url = 'https://app.teable.ai/api/credential/secret';
            const options = {
              method: 'POST',
              headers: {
                Authorization: 'Bearer REPLACE_BEARER_TOKEN',
                'content-type': 'application/json'
              },
              body: '{"key":"string","value":"string","description":"string","onConflict":"error","grantTo":{"resourceType":"automation","resourceId":"string","alias":"string","replace":true}}'
            };

            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/credential/secret',
              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({
              key: 'string',
              value: 'string',
              description: 'string',
              onConflict: 'error',
              grantTo: {
                resourceType: 'automation',
                resourceId: 'string',
                alias: 'string',
                replace: true
              }
            }));
            req.end();
        - lang: Python
          source: >-
            import http.client


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


            payload =
            "{\"key\":\"string\",\"value\":\"string\",\"description\":\"string\",\"onConflict\":\"error\",\"grantTo\":{\"resourceType\":\"automation\",\"resourceId\":\"string\",\"alias\":\"string\",\"replace\":true}}"


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


            conn.request("POST", "/api/credential/secret", payload, headers)


            res = conn.getresponse()

            data = res.read()


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

````