Create a secret
Create a new secret with an associated identifier that can be used to securely integrate with other services.
POST
/
integration_secrets
JavaScript
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);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)package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
integrationSecret, err := client.IntegrationSecrets.New(context.TODO(), telnyx.IntegrationSecretNewParams{
Identifier: "my_secret",
Type: telnyx.IntegrationSecretNewParamsTypeBearer,
Token: telnyx.String("my_secret_value"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", integrationSecret.Data)
}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);
}
}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)<?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();
}telnyx integration-secrets create \
--api-key 'My API Key' \
--identifier my_secret \
--type bearercurl --request POST \
--url https://api.telnyx.com/v2/integration_secrets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"identifier": "my_secret",
"type": "bearer",
"token": "my_secret_value"
}
'{
"data": {
"record_type": "integration_secret",
"id": "<string>",
"identifier": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"errors": [
{
"detail": "<string>",
"code": "<string>",
"title": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The unique identifier of the secret.
The type of secret.
Available options:
bearer, basic The token for the secret. Required for bearer type secrets, ignored otherwise.
The username for the secret. Required for basic type secrets, ignored otherwise.
The password for the secret. Required for basic type secrets, ignored otherwise.
Response
Successful Response
Show child attributes
Show child attributes
Was this page helpful?
⌘I
JavaScript
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);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)package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
integrationSecret, err := client.IntegrationSecrets.New(context.TODO(), telnyx.IntegrationSecretNewParams{
Identifier: "my_secret",
Type: telnyx.IntegrationSecretNewParamsTypeBearer,
Token: telnyx.String("my_secret_value"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", integrationSecret.Data)
}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);
}
}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)<?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();
}telnyx integration-secrets create \
--api-key 'My API Key' \
--identifier my_secret \
--type bearercurl --request POST \
--url https://api.telnyx.com/v2/integration_secrets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"identifier": "my_secret",
"type": "bearer",
"token": "my_secret_value"
}
'{
"data": {
"record_type": "integration_secret",
"id": "<string>",
"identifier": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"errors": [
{
"detail": "<string>",
"code": "<string>",
"title": "<string>"
}
]
}