Examples

Make the first working integration obvious.

Copy production-shaped examples for calls, sessions, webhooks, and admin automation in cURL, Node.js, Python, and Go.

Language coverage

The API is plain HTTPS plus WebSockets. These examples avoid SDK assumptions so they work in any enterprise runtime.

cURLNode.jsPythonGo

Make an outbound call

cURL

curl -sS -X POST "https://voice.stateset.app/api/v1/make-call" \
  -H "Authorization: Bearer ${STATESET_VOICE_API_KEY}" \
  -H "content-type: application/json" \
  -d '{"to":"+15555555678","from":"+15555551234","agent_key":"support_primary"}'

Node.js

const response = await fetch("https://voice.stateset.app/api/v1/make-call", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.STATESET_VOICE_API_KEY}`,
    "content-type": "application/json"
  },
  body: JSON.stringify({
    to: "+15555555678",
    from: "+15555551234",
    agent_key: "support_primary"
  })
});

if (!response.ok) {
  throw new Error(`StateSet Voice request failed: ${response.status}`);
}

console.log(await response.json());

Python

import os
import requests

response = requests.post(
    "https://voice.stateset.app/api/v1/make-call",
    headers={
        "Authorization": f"Bearer {os.environ['STATESET_VOICE_API_KEY']}",
        "content-type": "application/json",
    },
    json={
        "to": "+15555555678",
        "from": "+15555551234",
        "agent_key": "support_primary",
    },
    timeout=20,
)
response.raise_for_status()
print(response.json())

Go

package main

import (
  "bytes"
  "fmt"
  "net/http"
  "os"
)

func main() {
  body := []byte(`{"to":"+15555555678","from":"+15555551234","agent_key":"support_primary"}`)
  req, _ := http.NewRequest("POST", "https://voice.stateset.app/api/v1/make-call", bytes.NewReader(body))
  req.Header.Set("Authorization", "Bearer "+os.Getenv("STATESET_VOICE_API_KEY"))
  req.Header.Set("content-type", "application/json")

  res, err := http.DefaultClient.Do(req)
  if err != nil {
    panic(err)
  }
  defer res.Body.Close()
  if res.StatusCode >= 300 {
    panic(fmt.Sprintf("StateSet Voice request failed: %d", res.StatusCode))
  }
}

List recent sessions

curl -sS "https://voice.stateset.app/api/v1/voice-sessions?limit=25&offset=0" \
  -H "Authorization: Bearer ${STATESET_VOICE_API_KEY}"

Webhook receiver

import express from "express";
import twilio from "twilio";

const app = express();
app.use(express.urlencoded({ extended: false }));

app.post("/twilio/inbound", (request, response) => {
  const signature = request.header("x-twilio-signature");
  const url = "https://your-company.example/twilio/inbound";
  const valid = twilio.validateRequest(
    process.env.TWILIO_AUTH_TOKEN,
    signature,
    url,
    request.body
  );

  if (!valid) return response.status(401).send("invalid signature");
  return response.redirect(307, "https://voice.stateset.app/api/v1/incoming-call");
});

Update tenant runtime config

curl -sS -X PUT "https://voice.stateset.app/api/v1/admin/tenants/${TENANT_ID}/runtime-config" \
  -H "x-admin-key: ${STATESET_ADMIN_API_KEY}" \
  -H "content-type: application/json" \
  -d '{"model":"gpt-realtime","voice":"alloy","system_prompt_key":"support_default"}'