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=go --name=hello-world
This creates a new directory with the function:
hello-world/
├── func.toml    # Function configuration
├── go.mod       # Go dependencies
└── handler.go   # Your function code

Function Code

The generated Go function uses package function with a Handle function:
package function

import (
    "encoding/json"
    "io"
    "log"
    "net/http"
)

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

func Handle(w http.ResponseWriter, r *http.Request) {
    log.Printf("Serving request: %s %s", r.Method, r.URL.Path)

    response := Response{
        Message: "Hello from Telnyx Edge Compute!",
        Status:  "success",
    }

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

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:
// Go example
package function

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

func Handle(w http.ResponseWriter, r *http.Request) {
    json.NewEncoder(w).Encode(map[string]string{
        "message": "Hello from the edge",
    })
}
# Python example
class Function:
    async def handle(self, scope, receive, send):
        await send({
            "type": "http.response.start",
            "status": 200,
            "headers": [[b"content-type", b"application/json"]],
        })
        await send({
            "type": "http.response.body",
            "body": b'{"message": "Hello from the edge"}',
        })
// Java (Quarkus Funqy) example
package functions;

import io.quarkus.funqy.Funq;

public class Function {
    @Funq
    public Output function(Input input) {
        return new Output("Hello from the edge");
    }
}

Runtime Dependencies

Language-specific dependency files that define required packages:
// go.mod (Go)
module my-edge-function

go 1.21
# pyproject.toml (Python)
[project]
name = "my-edge-function"
version = "0.1.0"
dependencies = []
<!-- pom.xml (Java/Quarkus) -->
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-funqy</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: