Skip to main content
Bindings allow your edge functions to interact with Telnyx platform services. They provide secure, auto-authenticated access without managing API keys in your code.

Available Bindings

BindingDescriptionStatus
VoiceMake and receive callsβœ… Available
MessagingSend SMS/MMSβœ… Available
Phone NumbersManage numbersβœ… Available
FaxSend faxesβœ… Available
Verify2FA/verificationβœ… Available
Cloud StorageS3-compatible storageβœ… Available
KVKey-value storeπŸ”œ Coming soon
SQL DBServerless databaseπŸ”œ Coming soon

What is a Binding?

When you configure a binding for your function, you grant it the capability to access Telnyx services. The binding handles authentication automatically β€” your API key is never exposed in your code or logs.
Your Function β†’ Binding Proxy β†’ Telnyx API
      ↓              ↓              ↓
  Placeholder    Resolves      Actual API
  API Key        Credentials   Call Made
When you deploy a function with an active binding:
  1. Your function receives placeholder credentials as environment variables
  2. When your code calls the Telnyx SDK, the binding proxy intercepts the request
  3. The proxy resolves the placeholder to your real API key
  4. The API call proceeds with proper authentication
Benefits:
  • API key never appears in function code
  • API key never appears in logs
  • Credentials can be rotated without code changes

Creating a Binding

One-time setup per organization:
# Create a binding for your organization
telnyx-edge bindings create

# Verify the binding works
telnyx-edge bindings validate

Managing Bindings

# View your current binding
telnyx-edge bindings get

# Validate the binding is working
telnyx-edge bindings validate

# Rotate binding credentials (recommended monthly)
telnyx-edge bindings update

# Remove the binding
telnyx-edge bindings delete

Using Bindings: Telnyx API

With a binding configured, the Telnyx SDK automatically uses the injected credentials β€” no configuration required.
const Telnyx = require('telnyx');

// SDK automatically uses TELNYX_API_KEY and TELNYX_BASE_URL
const telnyx = new Telnyx();

async function getBalance() {
    const balance = await telnyx.balance.retrieve();
    return {
        balance: balance.data.balance,
        currency: balance.data.currency
    };
}

async function sendMessage(to, from, text) {
    const message = await telnyx.messages.create({
        from: from,
        to: to,
        text: text
    });
    return { messageId: message.data.id };
}

Using Bindings: Cloud Storage

Cloud Storage bindings use S3-compatible APIs rather than the Telnyx REST API.
package main

import (
    "os"
    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/credentials"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/s3"
)

func getStorageClient() *s3.S3 {
    sess := session.Must(session.NewSession(&aws.Config{
        Endpoint:    aws.String("https://us-east-1.telnyxcloudstorage.com"),
        Region:      aws.String("us-east-1"),
        Credentials: credentials.NewStaticCredentials(
            os.Getenv("TELNYX_API_KEY"),
            "", // Not required for Telnyx
            "",
        ),
    }))
    return s3.New(sess)
}

func listObjects(bucket string) ([]string, error) {
    client := getStorageClient()
    
    result, err := client.ListObjectsV2(&s3.ListObjectsV2Input{
        Bucket: aws.String(bucket),
    })
    if err != nil {
        return nil, err
    }
    
    var keys []string
    for _, obj := range result.Contents {
        keys = append(keys, *obj.Key)
    }
    return keys, nil
}
Native SDK support for Cloud Storage via bindings is in progress. Currently, use S3-compatible libraries (boto3, aws-sdk-go) with the binding credentials.

Using Bindings: KV

πŸ”œ Coming soon β€” KV bindings will allow key-value storage directly from edge functions.

Using Bindings: SQL DB

πŸ”œ Coming soon β€” SQL DB bindings will provide serverless database access from edge functions.

Bindings vs Secrets

FeatureBindingsSecrets
PurposeTelnyx service accessGeneral sensitive data
ScopeOne per organizationUnlimited per organization
CredentialsAuto-managedUser-provided
InjectionTELNYX_API_KEY, TELNYX_BASE_URLCustom environment variables
Rotationbindings updateManual re-add
Use caseTelnyx SDK/API integrationDatabase passwords, external API keys
Use bindings for Telnyx service access β€” credentials are managed automatically. Use secrets for third-party services or when you need multiple different credentials.

Error Handling

import telnyx
from telnyx.error import TelnyxError, AuthenticationError, APIError

def safe_api_call():
    try:
        balance = telnyx.Balance.retrieve()
        return {"balance": balance.balance}

    except AuthenticationError as e:
        # Binding issue - credentials invalid or expired
        return {
            "error": "Authentication failed",
            "hint": "Try: telnyx-edge bindings update"
        }

    except APIError as e:
        # API-level error
        return {
            "error": f"API error: {e.message}",
            "code": e.code
        }

    except TelnyxError as e:
        # General Telnyx error
        return {"error": str(e)}

Troubleshooting

Binding not found

$ telnyx-edge bindings get
❌ No binding found

# Solution: Create a binding
$ telnyx-edge bindings create

Validation failed

$ telnyx-edge bindings validate
❌ Binding validation failed

# Solutions:
# 1. Update the binding
telnyx-edge bindings update

# 2. Check your Telnyx account status

# 3. Verify authentication
telnyx-edge auth status

Function can’t access Telnyx API

# Check binding exists
telnyx-edge bindings get

# Validate binding works
telnyx-edge bindings validate

# Redeploy function to get latest credentials
telnyx-edge ship