Loading...
Loading...
Compare original and translation side by side
go get github.com/team-telnyx/telnyx-gogo get github.com/team-telnyx/telnyx-goimport (
"context"
"fmt"
"os"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
client := telnyx.NewClient(
option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)clientimport (
"context"
"fmt"
"os"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
client := telnyx.NewClient(
option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)clientimport "errors"
result, err := client.Messages.Send(ctx, params)
if err != nil {
var apiErr *telnyx.Error
if errors.As(err, &apiErr) {
switch apiErr.StatusCode {
case 422:
fmt.Println("Validation error — check required fields and formats")
case 429:
// Rate limited — wait and retry with exponential backoff
fmt.Println("Rate limited, retrying...")
default:
fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error())
}
} else {
fmt.Println("Network error — check connectivity and retry")
}
}401403404422429import "errors"
result, err := client.Messages.Send(ctx, params)
if err != nil {
var apiErr *telnyx.Error
if errors.As(err, &apiErr) {
switch apiErr.StatusCode {
case 422:
fmt.Println("Validation error — check required fields and formats")
case 429:
// Rate limited — wait and retry with exponential backoff
fmt.Println("Rate limited, retrying...")
default:
fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error())
}
} else {
fmt.Println("Network error — check connectivity and retry")
}
}401403404422429GET /room_compositions page, err := client.RoomCompositions.List(context.Background(), telnyx.RoomCompositionListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)completed_atcreated_atdownload_urlduration_secsended_atformatidrecord_typeresolutionroom_idsession_idsize_mbstarted_atstatusupdated_atuser_idvideo_layoutwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /room_compositions page, err := client.RoomCompositions.List(context.Background(), telnyx.RoomCompositionListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)completed_atcreated_atdownload_urlduration_secsended_atformatidrecord_typeresolutionroom_idsession_idsize_mbstarted_atstatusupdated_atuser_idvideo_layoutwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPOST /room_compositionsformatresolutionsession_idvideo_layoutwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs roomComposition, err := client.RoomCompositions.New(context.Background(), telnyx.RoomCompositionNewParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", roomComposition.Data)completed_atcreated_atdownload_urlduration_secsended_atformatidrecord_typeresolutionroom_idsession_idsize_mbstarted_atstatusupdated_atuser_idvideo_layoutwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPOST /room_compositionsformatresolutionsession_idvideo_layoutwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs roomComposition, err := client.RoomCompositions.New(context.Background(), telnyx.RoomCompositionNewParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", roomComposition.Data)completed_atcreated_atdownload_urlduration_secsended_atformatidrecord_typeresolutionroom_idsession_idsize_mbstarted_atstatusupdated_atuser_idvideo_layoutwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /room_compositions/{room_composition_id} roomComposition, err := client.RoomCompositions.Get(context.Background(), "5219b3af-87c6-4c08-9b58-5a533d893e21")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", roomComposition.Data)completed_atcreated_atdownload_urlduration_secsended_atformatidrecord_typeresolutionroom_idsession_idsize_mbstarted_atstatusupdated_atuser_idvideo_layoutwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /room_compositions/{room_composition_id} roomComposition, err := client.RoomCompositions.Get(context.Background(), "5219b3af-87c6-4c08-9b58-5a533d893e21")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", roomComposition.Data)completed_atcreated_atdownload_urlduration_secsended_atformatidrecord_typeresolutionroom_idsession_idsize_mbstarted_atstatusupdated_atuser_idvideo_layoutwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsDELETE /room_compositions/{room_composition_id} err := client.RoomCompositions.Delete(context.Background(), "5219b3af-87c6-4c08-9b58-5a533d893e21")
if err != nil {
log.Fatal(err)
}DELETE /room_compositions/{room_composition_id} err := client.RoomCompositions.Delete(context.Background(), "5219b3af-87c6-4c08-9b58-5a533d893e21")
if err != nil {
log.Fatal(err)
}GET /room_participants page, err := client.RoomParticipants.List(context.Background(), telnyx.RoomParticipantListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)contextidjoined_atleft_atrecord_typesession_idupdated_atGET /room_participants page, err := client.RoomParticipants.List(context.Background(), telnyx.RoomParticipantListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)contextidjoined_atleft_atrecord_typesession_idupdated_atGET /room_participants/{room_participant_id} roomParticipant, err := client.RoomParticipants.Get(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", roomParticipant.Data)contextidjoined_atleft_atrecord_typesession_idupdated_atGET /room_participants/{room_participant_id} roomParticipant, err := client.RoomParticipants.Get(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", roomParticipant.Data)contextidjoined_atleft_atrecord_typesession_idupdated_atGET /room_recordings page, err := client.RoomRecordings.List(context.Background(), telnyx.RoomRecordingListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)codeccompleted_atcreated_atdownload_urlduration_secsended_atidparticipant_idrecord_typeroom_idsession_idsize_mbstarted_atstatustypeupdated_atGET /room_recordings page, err := client.RoomRecordings.List(context.Background(), telnyx.RoomRecordingListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)codeccompleted_atcreated_atdownload_urlduration_secsended_atidparticipant_idrecord_typeroom_idsession_idsize_mbstarted_atstatustypeupdated_atDELETE /room_recordings response, err := client.RoomRecordings.DeleteBulk(context.Background(), telnyx.RoomRecordingDeleteBulkParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)room_recordingsDELETE /room_recordings response, err := client.RoomRecordings.DeleteBulk(context.Background(), telnyx.RoomRecordingDeleteBulkParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)room_recordingsGET /room_recordings/{room_recording_id} roomRecording, err := client.RoomRecordings.Get(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", roomRecording.Data)codeccompleted_atcreated_atdownload_urlduration_secsended_atidparticipant_idrecord_typeroom_idsession_idsize_mbstarted_atstatustypeupdated_atGET /room_recordings/{room_recording_id} roomRecording, err := client.RoomRecordings.Get(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", roomRecording.Data)codeccompleted_atcreated_atdownload_urlduration_secsended_atidparticipant_idrecord_typeroom_idsession_idsize_mbstarted_atstatustypeupdated_atDELETE /room_recordings/{room_recording_id} err := client.RoomRecordings.Delete(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}DELETE /room_recordings/{room_recording_id} err := client.RoomRecordings.Delete(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}GET /room_sessions page, err := client.Rooms.Sessions.List0(context.Background(), telnyx.RoomSessionList0Params{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)activecreated_atended_atidparticipantsrecord_typeroom_idupdated_atGET /room_sessions page, err := client.Rooms.Sessions.List0(context.Background(), telnyx.RoomSessionList0Params{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)activecreated_atended_atidparticipantsrecord_typeroom_idupdated_atGET /room_sessions/{room_session_id} session, err := client.Rooms.Sessions.Get(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionGetParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", session.Data)activecreated_atended_atidparticipantsrecord_typeroom_idupdated_atGET /room_sessions/{room_session_id} session, err := client.Rooms.Sessions.Get(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionGetParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", session.Data)activecreated_atended_atidparticipantsrecord_typeroom_idupdated_atPOST /room_sessions/{room_session_id}/actions/end response, err := client.Rooms.Sessions.Actions.End(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)resultPOST /room_sessions/{room_session_id}/actions/end response, err := client.Rooms.Sessions.Actions.End(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)resultPOST /room_sessions/{room_session_id}/actions/kickexcludeparticipants response, err := client.Rooms.Sessions.Actions.Kick(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionActionKickParams{
ActionsParticipantsRequest: telnyx.ActionsParticipantsRequestParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)resultPOST /room_sessions/{room_session_id}/actions/kickexcludeparticipants response, err := client.Rooms.Sessions.Actions.Kick(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionActionKickParams{
ActionsParticipantsRequest: telnyx.ActionsParticipantsRequestParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)resultPOST /room_sessions/{room_session_id}/actions/muteexcludeparticipants response, err := client.Rooms.Sessions.Actions.Mute(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionActionMuteParams{
ActionsParticipantsRequest: telnyx.ActionsParticipantsRequestParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)resultPOST /room_sessions/{room_session_id}/actions/muteexcludeparticipants response, err := client.Rooms.Sessions.Actions.Mute(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionActionMuteParams{
ActionsParticipantsRequest: telnyx.ActionsParticipantsRequestParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)resultPOST /room_sessions/{room_session_id}/actions/unmuteexcludeparticipants response, err := client.Rooms.Sessions.Actions.Unmute(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionActionUnmuteParams{
ActionsParticipantsRequest: telnyx.ActionsParticipantsRequestParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)resultPOST /room_sessions/{room_session_id}/actions/unmuteexcludeparticipants response, err := client.Rooms.Sessions.Actions.Unmute(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionActionUnmuteParams{
ActionsParticipantsRequest: telnyx.ActionsParticipantsRequestParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)resultGET /room_sessions/{room_session_id}/participants page, err := client.Rooms.Sessions.GetParticipants(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionGetParticipantsParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)contextidjoined_atleft_atrecord_typesession_idupdated_atGET /room_sessions/{room_session_id}/participants page, err := client.Rooms.Sessions.GetParticipants(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionGetParticipantsParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)contextidjoined_atleft_atrecord_typesession_idupdated_atGET /rooms page, err := client.Rooms.List(context.Background(), telnyx.RoomListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)active_session_idcreated_atenable_recordingidmax_participantsrecord_typesessionsunique_nameupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /rooms page, err := client.Rooms.List(context.Background(), telnyx.RoomListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)active_session_idcreated_atenable_recordingidmax_participantsrecord_typesessionsunique_nameupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPOST /roomsenable_recordingmax_participantsunique_namewebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs room, err := client.Rooms.New(context.Background(), telnyx.RoomNewParams{
UniqueName: "my-meeting-room",
MaxParticipants: 10,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", room.Data)active_session_idcreated_atenable_recordingidmax_participantsrecord_typesessionsunique_nameupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPOST /roomsenable_recordingmax_participantsunique_namewebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs room, err := client.Rooms.New(context.Background(), telnyx.RoomNewParams{
UniqueName: "my-meeting-room",
MaxParticipants: 10,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", room.Data)active_session_idcreated_atenable_recordingidmax_participantsrecord_typesessionsunique_nameupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /rooms/{room_id} room, err := client.Rooms.Get(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomGetParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", room.Data)active_session_idcreated_atenable_recordingidmax_participantsrecord_typesessionsunique_nameupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /rooms/{room_id} room, err := client.Rooms.Get(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomGetParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", room.Data)active_session_idcreated_atenable_recordingidmax_participantsrecord_typesessionsunique_nameupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPATCH /rooms/{room_id}enable_recordingmax_participantsunique_namewebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs room, err := client.Rooms.Update(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomUpdateParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", room.Data)active_session_idcreated_atenable_recordingidmax_participantsrecord_typesessionsunique_nameupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPATCH /rooms/{room_id}enable_recordingmax_participantsunique_namewebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs room, err := client.Rooms.Update(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomUpdateParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", room.Data)active_session_idcreated_atenable_recordingidmax_participantsrecord_typesessionsunique_nameupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsDELETE /rooms/{room_id} err := client.Rooms.Delete(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}DELETE /rooms/{room_id} err := client.Rooms.Delete(context.Background(), "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")
if err != nil {
log.Fatal(err)
}token_ttl_secsrefresh_token_ttl_secsPOST /rooms/{room_id}/actions/generate_join_client_tokenrefresh_token_ttl_secstoken_ttl_secs response, err := client.Rooms.Actions.GenerateJoinClientToken(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomActionGenerateJoinClientTokenParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)refresh_tokenrefresh_token_expires_attokentoken_expires_attoken_ttl_secsrefresh_token_ttl_secsPOST /rooms/{room_id}/actions/generate_join_client_tokenrefresh_token_ttl_secstoken_ttl_secs response, err := client.Rooms.Actions.GenerateJoinClientToken(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomActionGenerateJoinClientTokenParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)refresh_tokenrefresh_token_expires_attokentoken_expires_attoken_ttl_secsPOST /rooms/{room_id}/actions/refresh_client_tokenrefresh_tokentoken_ttl_secs response, err := client.Rooms.Actions.RefreshClientToken(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomActionRefreshClientTokenParams{
RefreshToken: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZWxueXhfdGVsZXBob255IiwiZXhwIjoxNTkwMDEwMTQzLCJpYXQiOjE1ODc1OTA5NDMsImlzcyI6InRlbG55eF90ZWxlcGhvbnkiLCJqdGkiOiJiOGM3NDgzNy1kODllLTRhNjUtOWNmMi0zNGM3YTZmYTYwYzgiLCJuYmYiOjE1ODc1OTA5NDIsInN1YiI6IjVjN2FjN2QwLWRiNjUtNGYxMS05OGUxLWVlYzBkMWQ1YzZhZSIsInRlbF90b2tlbiI6InJqX1pra1pVT1pNeFpPZk9tTHBFVUIzc2lVN3U2UmpaRmVNOXMtZ2JfeENSNTZXRktGQUppTXlGMlQ2Q0JSbWxoX1N5MGlfbGZ5VDlBSThzRWlmOE1USUlzenl6U2xfYURuRzQ4YU81MHlhSEd1UlNZYlViU1ltOVdJaVEwZz09IiwidHlwIjoiYWNjZXNzIn0.gNEwzTow5MLLPLQENytca7pUN79PmPj6FyqZWW06ZeEmesxYpwKh0xRtA0TzLh6CDYIRHrI8seofOO0YFGDhpQ",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)tokentoken_expires_attoken_ttl_secsPOST /rooms/{room_id}/actions/refresh_client_tokenrefresh_tokentoken_ttl_secs response, err := client.Rooms.Actions.RefreshClientToken(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomActionRefreshClientTokenParams{
RefreshToken: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZWxueXhfdGVsZXBob255IiwiZXhwIjoxNTkwMDEwMTQzLCJpYXQiOjE1ODc1OTA5NDMsImlzcyI6InRlbG55eF90ZWxlcGhvbnkiLCJqdGkiOiJiOGM3NDgzNy1kODllLTRhNjUtOWNmMi0zNGM3YTZmYTYwYzgiLCJuYmYiOjE1ODc1OTA5NDIsInN1YiI6IjVjN2FjN2QwLWRiNjUtNGYxMS05OGUxLWVlYzBkMWQ1YzZhZSIsInRlbF90b2tlbiI6InJqX1pra1pVT1pNeFpPZk9tTHBFVUIzc2lVN3U2UmpaRmVNOXMtZ2JfeENSNTZXRktGQUppTXlGMlQ2Q0JSbWxoX1N5MGlfbGZ5VDlBSThzRWlmOE1USUlzenl6U2xfYURuRzQ4YU81MHlhSEd1UlNZYlViU1ltOVdJaVEwZz09IiwidHlwIjoiYWNjZXNzIn0.gNEwzTow5MLLPLQENytca7pUN79PmPj6FyqZWW06ZeEmesxYpwKh0xRtA0TzLh6CDYIRHrI8seofOO0YFGDhpQ",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)tokentoken_expires_atGET /rooms/{room_id}/sessions page, err := client.Rooms.Sessions.List1(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionList1Params{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)activecreated_atended_atidparticipantsrecord_typeroom_idupdated_atGET /rooms/{room_id}/sessions page, err := client.Rooms.Sessions.List1(
context.Background(),
"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
telnyx.RoomSessionList1Params{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)activecreated_atended_atidparticipantsrecord_typeroom_idupdated_at