Attaches a new source to a collection.
POST
/
ai
/
collections
/
{uuid}
/
sources
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const SourceEnvelope = await client.ai.collections.sources.create('uuid', {
source_type: 'voice',
});
console.log(SourceEnvelope.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
)
source_envelope = client.ai.collections.sources.create(
uuid="uuid",
source_type="voice",
)
print(source_envelope.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"),
)
source, err := client.AI.Collections.Sources.New(
context.TODO(),
"uuid",
telnyx.AICollectionSourceNewParams{
SourceType: "source_type",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", source.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.collections.sources.SourceCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
SourceCreateParams params = SourceCreateParams.builder()
.sourceType(SourceCreateParams.SourceType.VOICE)
.build();
var response = client.ai().collections().sources().create("uuid", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
source_envelope = telnyx.ai.collections.sources.create("uuid", source_type: :voice)
puts(source_envelope)<?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 {
$source_envelope = $client->ai->collections->sources->create(
'uuid',
source_type: 'voice',
);
var_dump($source_envelope);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx ai:collections:sources create \
--api-key 'My API Key' \
--uuid 6a09ccbd-8f9b-4c3a-9b0e-2f1d3c4b5a6e \
--source-type voicecurl --request POST \
--url https://api.telnyx.com/v2/ai/collections/{uuid}/sources \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"source_type": "voice",
"bucket_id": "policy-docs"
}
'{
"data": {
"id": "source_8vkvtcksnawvbnxq48yv2l06wx",
"record_type": "ai_collection_source",
"collection_id": "6a09ccbd-8f9b-4c3a-9b0e-2f1d3c4b5a6e",
"source_type": "voice",
"bucket_id": "policy-docs",
"status": "ready"
}
}{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "The request failed because it was not well-formed.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10015"
}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"errors": [
{
"code": "collection_not_found",
"title": "Collection not found",
"detail": "No collection with uuid 'b3b1c8a2-9f4e-4d2a-9c1e-2f7a6d5b4c3a' exists for this account."
}
]
}{
"errors": [
{
"code": "collection_slug_taken",
"title": "Collection slug already in use",
"detail": "A collection with slug 'support-transcripts' already exists for this account.",
"meta": {
"pointer": "/slug"
}
}
]
}{
"errors": [
{
"code": "invalid_source_configuration",
"title": "Invalid source configuration",
"detail": "The bucket_id field is required when source_type is bucket.",
"meta": {
"pointer": "/bucket_id"
}
}
]
}Authorizations
Telnyx API key. Collections and results are automatically scoped to the authenticated user's organization.
Path Parameters
The collection's unique identifier.
Example:
"6a09ccbd-8f9b-4c3a-9b0e-2f1d3c4b5a6e"
Body
application/json
The type of Telnyx data attached as a source. bucket requires an additional bucket_id. Only voice is searchable today; meeting_bot, message, and bucket attach but are not yet searchable (Coming soon).
Available options:
voice, meeting_bot, message, bucket Example:
"voice"
The Telnyx Storage bucket name. Required when source_type is bucket; ignored otherwise.
Example:
"policy-docs"
Response
The created source.
Envelope containing a single collection source.
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 SourceEnvelope = await client.ai.collections.sources.create('uuid', {
source_type: 'voice',
});
console.log(SourceEnvelope.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
)
source_envelope = client.ai.collections.sources.create(
uuid="uuid",
source_type="voice",
)
print(source_envelope.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"),
)
source, err := client.AI.Collections.Sources.New(
context.TODO(),
"uuid",
telnyx.AICollectionSourceNewParams{
SourceType: "source_type",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", source.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.collections.sources.SourceCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
SourceCreateParams params = SourceCreateParams.builder()
.sourceType(SourceCreateParams.SourceType.VOICE)
.build();
var response = client.ai().collections().sources().create("uuid", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
source_envelope = telnyx.ai.collections.sources.create("uuid", source_type: :voice)
puts(source_envelope)<?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 {
$source_envelope = $client->ai->collections->sources->create(
'uuid',
source_type: 'voice',
);
var_dump($source_envelope);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx ai:collections:sources create \
--api-key 'My API Key' \
--uuid 6a09ccbd-8f9b-4c3a-9b0e-2f1d3c4b5a6e \
--source-type voicecurl --request POST \
--url https://api.telnyx.com/v2/ai/collections/{uuid}/sources \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"source_type": "voice",
"bucket_id": "policy-docs"
}
'{
"data": {
"id": "source_8vkvtcksnawvbnxq48yv2l06wx",
"record_type": "ai_collection_source",
"collection_id": "6a09ccbd-8f9b-4c3a-9b0e-2f1d3c4b5a6e",
"source_type": "voice",
"bucket_id": "policy-docs",
"status": "ready"
}
}{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "The request failed because it was not well-formed.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10015"
}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"errors": [
{
"code": "collection_not_found",
"title": "Collection not found",
"detail": "No collection with uuid 'b3b1c8a2-9f4e-4d2a-9c1e-2f7a6d5b4c3a' exists for this account."
}
]
}{
"errors": [
{
"code": "collection_slug_taken",
"title": "Collection slug already in use",
"detail": "A collection with slug 'support-transcripts' already exists for this account.",
"meta": {
"pointer": "/slug"
}
}
]
}{
"errors": [
{
"code": "invalid_source_configuration",
"title": "Invalid source configuration",
"detail": "The bucket_id field is required when source_type is bucket.",
"meta": {
"pointer": "/bucket_id"
}
}
]
}