Go Quickstart
Call the Engium REST API from Go using the standard net/http package — no third-party dependencies required.
info
Prerequisites
- •Go 1.21+
- •API key and Tenant ID from Settings → Developer
info
Zero dependencies
The example uses only Go standard library packages (net/http, encoding/json). No go get required — just set ENGIUM_API_KEY and ENGIUM_TENANT_ID environment variables and run.
Implementation
main.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
const base = "https://api.engium.app/api/v1"
type EngiumClient struct {
apiKey string
tenant string
http *http.Client
}
func NewClient() *EngiumClient {
return &EngiumClient{
apiKey: os.Getenv("ENGIUM_API_KEY"),
tenant: os.Getenv("ENGIUM_TENANT_ID"),
http: &http.Client{Timeout: 30 * time.Second},
}
}
func (c *EngiumClient) Post(path string, body any) (map[string]any, error) {
b, _ := json.Marshal(body)
req, _ := http.NewRequest("POST", base+"/"+path, bytes.NewBuffer(b))
req.Header.Set("Authorization", "Bearer "+c.apiKey)
req.Header.Set("X-Tenant-ID", c.tenant)
req.Header.Set("Content-Type", "application/json")
resp, err := c.http.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
data, _ := io.ReadAll(resp.Body)
var result map[string]any
json.Unmarshal(data, &result)
return result, nil
}
func main() {
client := NewClient()
session, err := client.Post("conversations/send", map[string]any{
"recipient": "+15550102999",
"channel": "whatsapp",
"message": map[string]string{"text": "Hello from Go! 🐹"},
})
if err != nil {
panic(err)
}
fmt.Printf("Session ID : %v\n", session["id"])
fmt.Printf("Status : %v\n", session["status"])
}Request Parameters
| Parameter | Type | Requirement |
|---|---|---|
Authorization | Header · string | Required |
X-Tenant-ID | Header · UUID | Required |
AuthorizationRequiredBearer {api_key}. Generate from Settings → Developer → API Keys.
Type:Header · string
X-Tenant-IDRequiredYour Tenant UUID. All API data is scoped to this tenant.
Type:Header · UUID
Was this helpful?