Skip to main content

Edge Compute Quick Start

Deploy serverless functions on Telnyx Edge Compute in under 5 minutes.

Tutorial Objectives

This tutorial covers:
  • Deploying a function that responds globally in under 50ms.
  • Learning the basic Edge Compute development workflow.
  • Testing functions from anywhere in the world.
  • Understanding edge computing in practice.

Prerequisites

  • A Telnyx account with API access - Sign up here if needed.
  • Command line familiarity - Requires Terminal (macOS/Linux) or Command Prompt (Windows).
  • Time requirement - This guide takes approximately 5 minutes to complete.

Install the CLI

Download Binary

Download the latest release for your platform from the GitHub releases page. Extract the archive and add the binary to your PATH: Example for Linux/macOS:
# Download and extract
tar -xzf telnyx-edge-*.tar.gz

# Install to system PATH
sudo mv telnyx-edge /usr/local/bin/

# Verify installation
telnyx-edge --help

Authenticate

Authenticate using OAuth with your Telnyx account:
telnyx-edge auth login
This will open your browser to complete authentication.

Option 2: API Key

Alternatively, authenticate with a Telnyx API key:
telnyx-edge auth api-key set YOUR_API_KEY

Verify Authentication

Check your authentication status:
telnyx-edge auth status

Create a Function

Create a simple “Hello World” function. Choose your preferred language:
telnyx-edge new-func --language=go --name=hello-world
This creates a new directory with the function:
hello-world/
├── handler.go   # Your function code
├── go.mod       # Go dependencies
└── func.toml    # Function configuration

Function Code

The generated handler.go contains a basic HTTP handler:
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
    "os"
)

type Response struct {
    Message string `json:"message"`
    Status  string `json:"status"`
}

func handler(w http.ResponseWriter, r *http.Request) {
    response := Response{
        Message: "Hello from Telnyx Edge Compute!",
        Status:  "success",
    }

    w.Header().Set("Content-Type", "application/json")
    json.NewEncoder(w).Encode(response)
}

func main() {
    http.HandleFunc("/", handler)

    port := os.Getenv("PORT")
    if port == "" {
        port = "8080"
    }

    fmt.Printf("Server starting on port %s\n", port)
    http.ListenAndServe(":"+port, nil)
}

Deploy the Function

Navigate to the function directory and deploy:
cd hello-world
telnyx-edge ship
The CLI will:
  1. Validate your function structure.
  2. Check authentication.
  3. Package your function files.
  4. Upload to Telnyx Edge infrastructure.
  5. Deploy across edge locations.
You’ll see output like:
Deploying function 'hello-world'...
✓ Function validated successfully
✓ Authentication verified
✓ Files packaged (2.3 KB)
✓ Upload complete
✓ Function deployed successfully

Function ID: func-abc123def456
Status: Active

Test the Function

Your function is now deployed and accessible via HTTP. Functions are accessible at URLs following this pattern: https://{funcName}-{orgId}.telnyxcompute.com Test your deployed function:
curl https://hello-world-abc123.telnyxcompute.com \
  -H "Content-Type: application/json" \
  -d '{"test": "data"}'
Response:
{
  "message": "Hello from Telnyx Edge Compute!",
  "status": "success"
}

Success! The Function is Live

Your function is now running and ready to handle HTTP requests. Functions automatically scale based on demand.

Building on the Basics

Common implementation patterns include:

Handle Different HTTP Methods

func handler(w http.ResponseWriter, r *http.Request) {
    var response Response

    switch r.Method {
    case "GET":
        response = Response{Message: "Hello from GET request!", Status: "success"}
    case "POST":
        response = Response{Message: "Data received via POST!", Status: "success"}
    default:
        response = Response{Message: "Method not supported", Status: "error"}
        w.WriteHeader(http.StatusMethodNotAllowed)
    }

    w.Header().Set("Content-Type", "application/json")
    json.NewEncoder(w).Encode(response)
}

Use Environment Variables

func handler(w http.ResponseWriter, r *http.Request) {
    greeting := os.Getenv("GREETING")
    if greeting == "" {
        greeting = "Hello"
    }

    response := Response{
        Message: fmt.Sprintf("%s from Telnyx Edge Compute!", greeting),
        Status:  "success",
    }

    w.Header().Set("Content-Type", "application/json")
    json.NewEncoder(w).Encode(response)
}

Parse Query Parameters

func handler(w http.ResponseWriter, r *http.Request) {
    name := r.URL.Query().Get("name")
    if name == "" {
        name = "World"
    }

    response := Response{
        Message: fmt.Sprintf("Hello %s from Telnyx Edge Compute!", name),
        Status:  "success",
    }

    w.Header().Set("Content-Type", "application/json")
    json.NewEncoder(w).Encode(response)
}

Next Steps

The edge function has been successfully deployed. Explore these topics next:

Explore More Languages

Try creating functions in different languages:
# Go
telnyx-edge new-func --language=go --name=my-go-function

# Python
telnyx-edge new-func --language=python --name=my-python-function

# Java (Quarkus)
telnyx-edge new-func --language=quarkus --name=my-java-function

Learn Core Concepts

Integrate with Telnyx Services

Common Commands

Here are the most frequently used CLI commands:
# Authentication
telnyx-edge auth login                    # Login with OAuth
telnyx-edge auth status                   # Check auth status
telnyx-edge auth logout                   # Logout
telnyx-edge auth api-key set KEY          # Set API key
telnyx-edge auth api-key clear            # Clear API key

# Function management
telnyx-edge new-func -l=go -n=my-func     # Create new function
telnyx-edge ship                          # Deploy function from current directory
telnyx-edge delete-func my-func           # Delete a function

# Secrets management
telnyx-edge secrets add API_KEY "value"   # Add a secret
telnyx-edge secrets list                  # List secrets
telnyx-edge secrets delete API_KEY        # Delete a secret

# Bindings (automatic Telnyx API key injection)
telnyx-edge bindings create               # Create binding for your org
telnyx-edge bindings get                  # View current binding
telnyx-edge bindings validate             # Test binding works
telnyx-edge bindings update               # Regenerate tokens
telnyx-edge bindings delete               # Remove binding

# System
telnyx-edge status                        # Check CLI status
telnyx-edge help                          # Show help

Getting Help

Need help? Here are your options: