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

# Create a secret

> Create a new secret with an associated identifier that can be used to securely integrate with other services.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/account-billing/integration-secrets.yml post /integration_secrets
openapi: 3.1.0
info:
  title: Telnyx Integration Secrets API
  version: 2.0.0
  description: API for Integration Secrets.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /integration_secrets:
    post:
      tags:
        - Integration Secrets
      summary: Create a secret
      description: >-
        Create a new secret with an associated identifier that can be used to
        securely integrate with other services.
      operationId: create_integration_secret
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateIntegrationSecretRequest'
            examples:
              bearer:
                value:
                  identifier: my_secret
                  type: bearer
                  token: my_secret_value
              basic:
                value:
                  identifier: my_secret
                  type: basic
                  username: my_username
                  password: my_password
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IntegrationSecretCreatedResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/integration-secrets_ErrorResponse'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const integrationSecret = await client.integrationSecrets.create({
              identifier: 'my_secret',
              type: 'bearer',
              token: 'my_secret_value',
            });

            console.log(integrationSecret.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            integration_secret = client.integration_secrets.create(
                identifier="my_secret",
                type="bearer",
                token="my_secret_value",
            )
            print(integration_secret.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tintegrationSecret, err := client.IntegrationSecrets.New(context.TODO(), telnyx.IntegrationSecretNewParams{\n\t\tIdentifier: \"my_secret\",\n\t\tType:       telnyx.IntegrationSecretNewParamsTypeBearer,\n\t\tToken:      telnyx.String(\"my_secret_value\"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", integrationSecret.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.integrationsecrets.IntegrationSecretCreateParams;

            import
            com.telnyx.sdk.models.integrationsecrets.IntegrationSecretCreateResponse;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    IntegrationSecretCreateParams params = IntegrationSecretCreateParams.builder()
                        .identifier("my_secret")
                        .type(IntegrationSecretCreateParams.Type.BEARER)
                        .build();
                    IntegrationSecretCreateResponse integrationSecret = client.integrationSecrets().create(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            integration_secret = telnyx.integration_secrets.create(identifier:
            "my_secret", type: :bearer)


            puts(integration_secret)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $integrationSecret = $client->integrationSecrets->create(
                identifier: 'my_secret',
                type: 'bearer',
                token: 'my_secret_value',
                password: 'password',
                username: 'username',
              );

              var_dump($integrationSecret);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx integration-secrets create \
              --api-key 'My API Key' \
              --identifier my_secret \
              --type bearer
components:
  schemas:
    CreateIntegrationSecretRequest:
      properties:
        identifier:
          type: string
          title: Identifier
          description: The unique identifier of the secret.
        type:
          type: string
          title: Type
          description: The type of secret.
          enum:
            - bearer
            - basic
        token:
          type: string
          title: Token
          description: >-
            The token for the secret. Required for bearer type secrets, ignored
            otherwise.
        username:
          type: string
          title: Username
          description: >-
            The username for the secret. Required for basic type secrets,
            ignored otherwise.
        password:
          type: string
          title: Password
          description: >-
            The password for the secret. Required for basic type secrets,
            ignored otherwise.
      type: object
      required:
        - identifier
        - type
      title: CreateIntegrationSecretRequest
    IntegrationSecretCreatedResponse:
      properties:
        data:
          $ref: '#/components/schemas/IntegrationSecret'
      type: object
      required:
        - data
      title: IntegrationSecretCreatedResponse
    integration-secrets_ErrorResponse:
      properties:
        errors:
          items:
            $ref: '#/components/schemas/integration-secrets_Error'
          type: array
          title: Errors
      type: object
      title: ErrorResponse
    IntegrationSecret:
      properties:
        record_type:
          type: string
          title: Record Type
          example: integration_secret
        id:
          type: string
          title: Id
        identifier:
          type: string
          title: Identifier
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - record_type
        - id
        - identifier
        - created_at
      title: IntegrationSecret
    integration-secrets_Error:
      properties:
        code:
          type: string
          title: Telnyx error code
        detail:
          type: string
          title: Error details
        title:
          type: string
          title: Error title
      type: object
      required:
        - detail
      title: Error
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````