Create a credential
Create a credential.
POST
/
telephony_credentials
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const telephonyCredential = await client.telephonyCredentials.create({
connection_id: '1234567890',
});
console.log(telephonyCredential.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
)
telephony_credential = client.telephony_credentials.create(
connection_id="1234567890",
)
print(telephony_credential.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"),
)
telephonyCredential, err := client.TelephonyCredentials.New(context.TODO(), telnyx.TelephonyCredentialNewParams{
ConnectionID: "1234567890",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", telephonyCredential.Data)
}package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.telephonycredentials.TelephonyCredentialCreateParams;
import com.telnyx.sdk.models.telephonycredentials.TelephonyCredentialCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
TelephonyCredentialCreateParams params = TelephonyCredentialCreateParams.builder()
.connectionId("1234567890")
.build();
TelephonyCredentialCreateResponse telephonyCredential = client.telephonyCredentials().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
telephony_credential = telnyx.telephony_credentials.create(connection_id: "1234567890")
puts(telephony_credential)<?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 {
$telephonyCredential = $client->telephonyCredentials->create(
connectionID: '1234567890',
expiresAt: '2018-02-02T22:25:27.521Z',
name: 'My-new-credential',
tag: 'some_tag',
);
var_dump($telephonyCredential);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx telephony-credentials create \
--api-key 'My API Key' \
--connection-id 1234567890curl --request POST \
--url https://api.telnyx.com/v2/telephony_credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My-new-credential",
"connection_id": "1234567890"
}
'{
"data": {
"id": "c215ade3-0d39-418e-94be-c5f780760199",
"record_type": "credential",
"name": "2020-06-18 21:32:38.917732Z",
"expired": false,
"user_id": "user-id",
"resource_id": "connection:804252963366242252",
"sip_password": "a92dbcfb60184a8cb330b0acb2f7617b",
"sip_username": "gencrednCvHU5IYpSBPPsXI2iQsDX",
"created_at": "2020-06-18T21:32:38",
"expires_at": "2042-06-18T21:32:38",
"updated_at": "2020-06-18T21:32:38.000Z"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Parameters that can be defined during credential creation
Identifies the Credential Connection this credential is associated with.
Example:
"1234567890"
Tags a credential. A single tag can hold at maximum 1000 credentials.
Example:
"some_tag"
ISO-8601 formatted date indicating when the credential will expire.
Example:
"2018-02-02T22:25:27.521Z"
Response
Successful response with details about a credential
Show child attributes
Show child attributes
Example:
{
"id": "c215ade3-0d39-418e-94be-c5f780760199",
"record_type": "credential",
"name": "2020-06-18 21:32:38.917732Z",
"expired": false,
"user_id": "user-id",
"resource_id": "connection:804252963366242252",
"sip_password": "a92dbcfb60184a8cb330b0acb2f7617b",
"sip_username": "gencrednCvHU5IYpSBPPsXI2iQsDX",
"created_at": "2020-06-18T21:32:38",
"expires_at": "2042-06-18T21:32:38",
"updated_at": "2020-06-18T21:32:38.000Z"
}
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 telephonyCredential = await client.telephonyCredentials.create({
connection_id: '1234567890',
});
console.log(telephonyCredential.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
)
telephony_credential = client.telephony_credentials.create(
connection_id="1234567890",
)
print(telephony_credential.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"),
)
telephonyCredential, err := client.TelephonyCredentials.New(context.TODO(), telnyx.TelephonyCredentialNewParams{
ConnectionID: "1234567890",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", telephonyCredential.Data)
}package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.telephonycredentials.TelephonyCredentialCreateParams;
import com.telnyx.sdk.models.telephonycredentials.TelephonyCredentialCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
TelephonyCredentialCreateParams params = TelephonyCredentialCreateParams.builder()
.connectionId("1234567890")
.build();
TelephonyCredentialCreateResponse telephonyCredential = client.telephonyCredentials().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
telephony_credential = telnyx.telephony_credentials.create(connection_id: "1234567890")
puts(telephony_credential)<?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 {
$telephonyCredential = $client->telephonyCredentials->create(
connectionID: '1234567890',
expiresAt: '2018-02-02T22:25:27.521Z',
name: 'My-new-credential',
tag: 'some_tag',
);
var_dump($telephonyCredential);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx telephony-credentials create \
--api-key 'My API Key' \
--connection-id 1234567890curl --request POST \
--url https://api.telnyx.com/v2/telephony_credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My-new-credential",
"connection_id": "1234567890"
}
'{
"data": {
"id": "c215ade3-0d39-418e-94be-c5f780760199",
"record_type": "credential",
"name": "2020-06-18 21:32:38.917732Z",
"expired": false,
"user_id": "user-id",
"resource_id": "connection:804252963366242252",
"sip_password": "a92dbcfb60184a8cb330b0acb2f7617b",
"sip_username": "gencrednCvHU5IYpSBPPsXI2iQsDX",
"created_at": "2020-06-18T21:32:38",
"expires_at": "2042-06-18T21:32:38",
"updated_at": "2020-06-18T21:32:38.000Z"
}
}