Skip to main content

Tutorial Objectives

This tutorial covers learning the basic Edge Compute development workflow.

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

Check out the edge-compute repo and download the latest release from the 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=javascript --name=hello-world
This creates a new directory with the function:
hello-world/
├── index.js     # Your function code
├── package.json # Node.js dependencies
└── func.toml    # Function configuration

Function Code

The generated index.js contains a basic HTTP handler:
export async function handler(request) {
    const response = {
        message: "Hello from Telnyx Edge Compute!",
        status: "success"
    };

    return new Response(JSON.stringify(response), {
        headers: { "Content-Type": "application/json" }
    });
}

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.

Function Anatomy

Every Telnyx Edge Compute function consists of three essential components:

Function Code

The main application code that handles HTTP requests and responses:
# Python example
import json

async def handler(request):
    data = await request.json()
    
    return Response(
        json.dumps({
            "message": "Hello from the edge",
            "received": data
        }),
        headers={"Content-Type": "application/json"}
    )
// Go example  
func handler(w http.ResponseWriter, r *http.Request) {
    response := map[string]string{
        "message": "Hello from the edge",
        "method":  r.Method,
        "path":    r.URL.Path,
    }
    
    w.Header().Set("Content-Type", "application/json")
    json.NewEncoder(w).Encode(response)
}
// Java (Quarkus) example
@Path("/")
public class EdgeResource {
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response handler(Map<String, Object> data) {
        return Response.ok(Map.of(
            "message", "Hello from the edge",
            "received", data
        )).build();
    }
}

Runtime Dependencies

Language-specific dependency files that define required packages:
# requirements.txt (Python)
telnyx>=2.0.0
requests>=2.28.0
// go.mod (Go)
module my-edge-function

go 1.21
<!-- pom.xml (Java/Quarkus) -->
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>

Function Configuration

The func.toml file that defines deployment and runtime configuration:
[edge_compute]
func_id = "func-abc123def456"
func_name = "hello-world"

[env_vars]
MY_KEY = "VAL"

Next Steps

Now that your function is deployed, explore these topics to go deeper: