api

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const QualityDescription = "RTP quality metrics. Omitted for WebRTC legs or unanswered legs with no media."

QualityDescription is the description for the quality object in leg.disconnected.

Variables

View Source
var CodecsItemEnum = []string{"PCMU", "PCMA", "G722", "opus", "AMR-WB", "AMR-NB"}

CodecsItemEnum provides the enum for CreateLegRequest.codecs array items.

View Source
var DeleteReasonEnum = []string{"busy", "declined", "rejected", "unavailable", "not_found", "forbidden", "server_error"}

DeleteReasonEnum lists the reason values accepted on DELETE /v1/legs/{id}. Each maps to a SIP final response code on unanswered legs and ends up in the resulting leg.disconnected event's cdr.reason.

View Source
var DisconnectReasonEnum = []string{
	"api_hangup", "remote_bye", "caller_cancel", "ring_timeout", "max_duration",
	"busy", "unavailable", "not_found", "forbidden", "unauthorized", "timeout",
	"cancelled", "not_acceptable", "service_unavailable", "declined",
	"rtp_timeout", "session_expired", "invite_failed", "connect_failed", "ice_failure",
}

DisconnectReasonEnum lists all possible disconnect reason values.

View Source
var TrunkTypeEnum = []string{"sip_register", "ip_ip"}

TrunkTypeEnum lists every trunk type understood by the request schema. "ip_ip" is reserved (handler returns 501); "sip_register" is implemented.

Functions

func ParseAllowedIPs added in v0.9.0

func ParseAllowedIPs(s string) ([]netip.Prefix, error)

ParseAllowedIPs parses a comma-separated list of IPs and CIDR ranges into netip.Prefix values. Bare addresses become host-prefix entries (/32 for v4, /128 for v6). Whitespace around tokens is trimmed; empty tokens are skipped. Returns an error on the first malformed entry. An empty (or whitespace-only) input returns (nil, nil), which the middleware treats as "no allowlist".

func SchemaEnrichments

func SchemaEnrichments() map[string]FieldEnrichment

SchemaEnrichments maps "TypeName.json_field_name" → enrichment metadata. These are the descriptions, enums, formats, defaults, and constraints that cannot be derived from Go struct definitions alone.

func WebhookFieldDescriptions

func WebhookFieldDescriptions() map[string]string

WebhookFieldDescriptions maps "event_type.field_name" → description for inline properties in x-webhooks entries.

func WebhookNestedFieldDescriptions

func WebhookNestedFieldDescriptions() map[string]string

WebhookNestedFieldDescriptions provides descriptions for nested struct fields in webhook events (e.g. cdr.reason, cdr.duration_total).

Types

type AMDParams added in v0.2.0

type AMDParams struct {
	InitialSilenceTimeout int `json:"initial_silence_timeout,omitempty"` // ms — max silence before no_speech
	GreetingDuration      int `json:"greeting_duration,omitempty"`       // ms — speech threshold for machine
	AfterGreetingSilence  int `json:"after_greeting_silence,omitempty"`  // ms — silence after speech for human
	TotalAnalysisTime     int `json:"total_analysis_time,omitempty"`     // ms — hard analysis deadline
	MinimumWordLength     int `json:"minimum_word_length,omitempty"`     // ms — min speech burst to count
	BeepTimeout           int `json:"beep_timeout,omitempty"`            // ms — time to wait for beep after machine (0=disabled)
}

AMDParams configures per-call Answering Machine Detection thresholds. All durations are in milliseconds. Zero values fall back to global defaults.

type AddLegRequest

type AddLegRequest struct {
	LegID      string  `json:"leg_id"`
	Mute       *bool   `json:"mute,omitempty"`
	Deaf       *bool   `json:"deaf,omitempty"`
	AcceptDTMF *bool   `json:"accept_dtmf,omitempty"`
	Role       *string `json:"role,omitempty"`
}

AddLegRequest is the request body for POST /v1/rooms/{id}/legs.

type AddLegToRoomResult added in v0.6.0

type AddLegToRoomResult struct {
	Status string `json:"status"`
	RoomID string `json:"room_id"`
	LegID  string `json:"leg_id"`
}

AddLegToRoomResult is the success payload for add_leg_to_room over VSI. Mirrors what doAddLegToRoom returns inline today.

type AgentMessageRequest

type AgentMessageRequest struct {
	Message string `json:"message"`
}

AgentMessageRequest is the request body for POST /v1/legs/{id}/agent/message and POST /v1/rooms/{id}/agent/message.

type AgentMessageResult added in v0.6.0

type AgentMessageResult struct {
	Status string `json:"status"`
}

AgentMessageResult is the success payload for injecting a message into a leg or room agent session.

type AgentStartLegResult added in v0.6.0

type AgentStartLegResult struct {
	Status string `json:"status"`
	LegID  string `json:"leg_id"`
}

AgentStartLegResult is the success payload for starting an agent on a leg.

type AgentStartRoomResult added in v0.6.0

type AgentStartRoomResult struct {
	Status string `json:"status"`
	RoomID string `json:"room_id"`
}

AgentStartRoomResult is the success payload for starting an agent on a room.

type AgentStopResult added in v0.6.0

type AgentStopResult struct {
	Status string `json:"status"`
}

AgentStopResult is the success payload for stopping a leg or room agent.

type AnswerLegRequest added in v0.5.0

type AnswerLegRequest struct {
	SpeechDetection *bool  `json:"speech_detection,omitempty"` // override server default for speaking.started/speaking.stopped events
	Codec           string `json:"codec,omitempty"`            // explicit codec to use (must be in the remote offer)
}

AnswerLegRequest is the optional request body for POST /v1/legs/{id}/answer.

type BridgeView added in v0.6.0

type BridgeView struct {
	ID         string `json:"id"`
	RoomID     string `json:"room_id"`
	Direction  string `json:"direction"`
	SampleRate int    `json:"sample_rate"`
}

BridgeView is the JSON representation of a bridge, relative to the room in the request path.

type CreateLegRequest

type CreateLegRequest struct {
	Type            string            `json:"type"`                       // "sip", "whatsapp", or "websocket"
	To              string            `json:"to,omitempty"`               // destination — SIP URI for sip legs, E.164 phone number for whatsapp legs
	URI             string            `json:"uri,omitempty"`              // deprecated alias for `to` (sip legs only)
	From            string            `json:"from,omitempty"`             // caller ID (user part of the SIP From header, e.g. "+15551234567")
	Privacy         string            `json:"privacy,omitempty"`          // SIP Privacy header value (e.g. "id", "none")
	RingTimeout     int               `json:"ring_timeout,omitempty"`     // seconds; 0 = no timeout
	MaxDuration     int               `json:"max_duration,omitempty"`     // seconds; 0 = no limit
	Codecs          []string          `json:"codecs,omitempty"`           // codec preference order, e.g. ["PCMU","PCMA","G722","opus"]
	Headers         map[string]string `json:"headers,omitempty"`          // custom SIP/WS headers for outbound INVITE or WS handshake
	RoomID          string            `json:"room_id,omitempty"`          // add leg to this room once media is ready (early_media or connected)
	Auth            *SIPAuth          `json:"auth,omitempty"`             // digest auth credentials — required for whatsapp, optional for sip
	WebhookURL      string            `json:"webhook_url,omitempty"`      // route events for this leg to this URL
	WebhookSecret   string            `json:"webhook_secret,omitempty"`   // HMAC secret for webhook signature
	AMD             *AMDParams        `json:"amd,omitempty"`              // enable answering machine detection on outbound calls
	AcceptDTMF      *bool             `json:"accept_dtmf,omitempty"`      // if false, leg will not receive DTMF broadcast from other legs in the same room
	AppID           string            `json:"app_id,omitempty"`           // application identifier for event stream filtering
	SpeechDetection *bool             `json:"speech_detection,omitempty"` // override server default for speaking.started/speaking.stopped events
	RTT             bool              `json:"rtt,omitempty"`              // offer Real-Time Text (T.140 / RFC 4103) on the outbound INVITE, or enable bidi text channel for websocket legs

	// WebSocket leg fields (only used when Type == "websocket"):
	URL          string `json:"url,omitempty"`           // ws:// or wss:// target for outbound dial
	SampleRate   int    `json:"sample_rate,omitempty"`   // 8000/16000/24000/48000; default 16000
	WireFormat   string `json:"wire_format,omitempty"`   // "binary" (default) or "json_base64"
	SampleFormat string `json:"sample_format,omitempty"` // "s16le" (default; only format in v1)

	// LiveKit leg fields (only used when Type == "livekit_room"):
	LiveKit *LiveKitParams `json:"livekit,omitempty"`
}

CreateLegRequest is the request body for POST /v1/legs.

type CreateRoomBridgeRequest added in v0.6.0

type CreateRoomBridgeRequest struct {
	ID        string `json:"id,omitempty"`
	RoomID    string `json:"room_id"`
	Direction string `json:"direction,omitempty"`
}

CreateRoomBridgeRequest is the request body for POST /v1/rooms/{id}/bridges. Direction is relative to the room in the path.

type CreateRoomRequest

type CreateRoomRequest struct {
	ID            string `json:"id"`
	WebhookURL    string `json:"webhook_url,omitempty"`
	WebhookSecret string `json:"webhook_secret,omitempty"`
	AppID         string `json:"app_id,omitempty"`
	SampleRate    int    `json:"sample_rate,omitempty"`
}

CreateRoomRequest is the request body for POST /v1/rooms.

type CreateTrunkRequest added in v0.9.0

type CreateTrunkRequest struct {
	Type        string                `json:"type"`
	AppID       string                `json:"app_id,omitempty"`
	SIPRegister *SIPRegisterTrunkSpec `json:"sip_register,omitempty"`
	IPIP        *IPIPTrunkSpec        `json:"ip_ip,omitempty"`
}

CreateTrunkRequest is the request body for POST /v1/sip/trunks. The shape is typed by `type`; today only "sip_register" is implemented. "ip_ip" (static-IP peering, no REGISTER) is reserved and rejected with 501.

type CreateTrunkResponse added in v0.9.0

type CreateTrunkResponse struct {
	ID     string `json:"id"`
	Type   string `json:"type"`
	Status string `json:"status"`
}

CreateTrunkResponse is the body returned by POST /v1/sip/trunks.

type DTMFRequest

type DTMFRequest struct {
	Digits string `json:"digits"`
}

DTMFRequest is the request body for POST /v1/legs/{id}/dtmf.

type DeepgramAgentRequest

type DeepgramAgentRequest struct {
	Settings map[string]interface{} `json:"settings,omitempty"`
	Greeting string                 `json:"greeting,omitempty"`
	Language string                 `json:"language,omitempty"`
	APIKey   string                 `json:"api_key,omitempty"`
}

DeepgramAgentRequest is the request body for POST /v1/legs/{id}/agent/deepgram and POST /v1/rooms/{id}/agent/deepgram.

type DeleteLegRequest added in v0.6.0

type DeleteLegRequest struct {
	Reason string `json:"reason,omitempty"`
}

DeleteLegRequest is the optional request body for DELETE /v1/legs/{id}. Honored only for unanswered SIP inbound legs (state ringing or early_media). For connected legs the body is ignored and the leg is hung up via SIP BYE with the legacy `api_hangup` reason.

type EarlyMediaLegRequest added in v0.6.0

type EarlyMediaLegRequest struct {
	Codec string `json:"codec,omitempty"` // explicit codec to use (must be in the remote offer)
}

EarlyMediaLegRequest is the optional request body for POST /v1/legs/{id}/early-media.

type ElevenLabsAgentRequest

type ElevenLabsAgentRequest struct {
	AgentID          string            `json:"agent_id"`
	FirstMessage     string            `json:"first_message,omitempty"`
	Language         string            `json:"language,omitempty"`
	DynamicVariables map[string]string `json:"dynamic_variables,omitempty"`
	APIKey           string            `json:"api_key,omitempty"`
}

ElevenLabsAgentRequest is the request body for POST /v1/legs/{id}/agent/elevenlabs and POST /v1/rooms/{id}/agent/elevenlabs.

type EventMeta added in v0.6.0

type EventMeta struct {
	Type     events.EventType
	Summary  string
	DataType reflect.Type
}

EventMeta describes a single event published on the bus, the webhook channel, and the VSI WebSocket. asyncapi-gen and openapi-gen both consume this list. Adding a new event type is a two-step change: register it in internal/events/types.go AND add it here.

func EventsMetadata added in v0.6.0

func EventsMetadata() []EventMeta

EventsMetadata returns every event published over the bus. asyncapi-gen emits one channel per entry; openapi-gen emits one x-webhooks entry per entry. Keeping a single list ensures the two specs cannot drift apart.

type FieldEnrichment

type FieldEnrichment struct {
	Description string
	Enum        []string
	Format      string
	Default     interface{} // string, int, bool, float64
	Minimum     *int
	Maximum     *int
}

FieldEnrichment holds additional OpenAPI metadata for a struct field that cannot be derived from Go types and tags alone.

type IPIPTrunkSpec added in v0.9.0

type IPIPTrunkSpec struct {
	PeerURI string `json:"peer_uri,omitempty"`
}

IPIPTrunkSpec is the placeholder shape for the unimplemented ip_ip type.

type LegView

type LegView struct {
	ID         string            `json:"id"`
	Type       leg.LegType       `json:"type"`
	State      leg.LegState      `json:"state"`
	RoomID     string            `json:"room_id,omitempty"`
	Muted      bool              `json:"muted"`
	Deaf       bool              `json:"deaf"`
	AcceptDTMF bool              `json:"accept_dtmf"`
	Held       bool              `json:"held"`
	Role       string            `json:"role,omitempty"`
	AppID      string            `json:"app_id,omitempty"`
	SIPHeaders map[string]string `json:"sip_headers,omitempty"`
	Headers    map[string]string `json:"headers,omitempty"`
}

LegView is the JSON representation of a leg.

type LiveKitParams added in v0.8.0

type LiveKitParams struct {
	URL             string              `json:"url,omitempty"`              // overrides LIVEKIT_URL
	Token           string              `json:"token,omitempty"`            // pre-signed JWT
	Room            string              `json:"room,omitempty"`             // required when minting
	Identity        string              `json:"identity,omitempty"`         // required when minting
	ParticipantName string              `json:"participant_name,omitempty"` // optional display name
	Permissions     *LiveKitPermissions `json:"permissions,omitempty"`      // defaults: publish+subscribe true, data false
	TokenTTL        string              `json:"token_ttl,omitempty"`        // Go duration string; default 6h
	OpusBitrate     int                 `json:"opus_bitrate,omitempty"`     // override LIVEKIT_OPUS_BITRATE
}

LiveKitParams configures a livekit_room leg. Provide either Token (a pre-signed JWT) OR Room+Identity (the leg-create handler will mint a JWT when LIVEKIT_TOKEN_SIGNING_ENABLED=true). If both are provided, the explicit Token wins.

type LiveKitPermissions added in v0.8.0

type LiveKitPermissions struct {
	CanPublish     *bool `json:"can_publish,omitempty"`
	CanSubscribe   *bool `json:"can_subscribe,omitempty"`
	CanPublishData *bool `json:"can_publish_data,omitempty"`
	RoomAdmin      *bool `json:"room_admin,omitempty"` // grants admin actions like server-side MuteTrack on remote participants
}

LiveKitPermissions mirrors the LiveKit video grant flags. Nil pointers fall back to defaults (publish=true, subscribe=true, data=false).

type PipecatAgentRequest

type PipecatAgentRequest struct {
	WebsocketURL string `json:"websocket_url"`
}

PipecatAgentRequest is the request body for POST /v1/legs/{id}/agent/pipecat and POST /v1/rooms/{id}/agent/pipecat.

type PlaybackRequest

type PlaybackRequest struct {
	URL      string `json:"url"`
	Tone     string `json:"tone"`
	MimeType string `json:"mime_type"`
	Repeat   int    `json:"repeat"`
	Volume   int    `json:"volume"`
}

PlaybackRequest is the request body for POST /v1/legs/{id}/play and POST /v1/rooms/{id}/play.

type PlaybackStartResult added in v0.6.0

type PlaybackStartResult struct {
	PlaybackID string `json:"playback_id"`
	Status     string `json:"status"`
}

PlaybackStartResult is the success payload for starting a playback on a leg or room. The same shape is returned by leg_tts and room_tts (with "tts_id" semantics).

type PlaybackStopResult added in v0.6.0

type PlaybackStopResult struct {
	Status string `json:"status"`
}

PlaybackStopResult is the success payload for stopping a playback.

type RTTRequest added in v0.6.0

type RTTRequest struct {
	Text string `json:"text"`
}

RTTRequest is the request body for POST /v1/legs/{id}/rtt.

type RecordRequest

type RecordRequest struct {
	Storage      string `json:"storage"`
	MultiChannel bool   `json:"multi_channel"`
	S3Bucket     string `json:"s3_bucket"`
	S3Region     string `json:"s3_region"`
	S3Endpoint   string `json:"s3_endpoint"`
	S3Prefix     string `json:"s3_prefix"`
	S3AccessKey  string `json:"s3_access_key"`
	S3SecretKey  string `json:"s3_secret_key"`
}

RecordRequest is the request body for POST /v1/legs/{id}/record and POST /v1/rooms/{id}/record.

type RecordingPauseResumeResult added in v0.6.0

type RecordingPauseResumeResult struct {
	Status string `json:"status"`
}

RecordingPauseResumeResult is the success payload for pause/resume on a leg or room recording. Status is one of "paused", "already_paused", "resumed", "not_paused".

type RecordingStartResult added in v0.6.0

type RecordingStartResult struct {
	Status string `json:"status"`
	File   string `json:"file"`
}

RecordingStartResult is the success payload for starting a leg or room recording.

type RecordingStopLegResult added in v0.6.0

type RecordingStopLegResult struct {
	Status string `json:"status"`
	File   string `json:"file"`
}

RecordingStopLegResult is the success payload for stopping a leg recording.

type RecordingStopRoomResult added in v0.6.0

type RecordingStopRoomResult struct {
	Status           string                           `json:"status"`
	File             string                           `json:"file"`
	MultiChannelFile string                           `json:"multi_channel_file,omitempty"`
	Channels         map[string]recording.ChannelInfo `json:"channels,omitempty"`
}

RecordingStopRoomResult is the success payload for stopping a room recording. multi_channel_file/channels are present only when the recording was started with multi_channel=true.

type RegistrationView added in v0.8.0

type RegistrationView struct {
	AOR                   string `json:"aor"`
	Contact               string `json:"contact"`
	Socket                string `json:"socket"`
	Transport             string `json:"transport"`
	UserAgent             string `json:"user_agent,omitempty"`
	CallID                string `json:"call_id,omitempty"`
	AppID                 string `json:"app_id,omitempty"`
	CreatedAt             string `json:"created_at"`
	LastRefresh           string `json:"last_refresh"`
	ExpiresAt             string `json:"expires_at"`
	GrantedExpiresSeconds int    `json:"granted_expires_seconds"`
}

RegistrationView is the JSON shape returned by GET /v1/sip/registrations and the list_sip_registrations VSI command for a single AOR binding.

type RegistrationsResponse added in v0.8.0

type RegistrationsResponse struct {
	Bindings []RegistrationView `json:"bindings"`
}

RegistrationsResponse is the success body shape for the list endpoint.

type ResponseMeta

type ResponseMeta struct {
	Description string
	Type        interface{} // nil, or Go type instance
	// NoBody suppresses the generator's default content schema for 2xx
	// responses that have no payload (e.g. protocol upgrades like
	// WebTransport extended-CONNECT, where the response is the upgraded
	// session rather than a JSON document).
	NoBody bool
}

ResponseMeta describes a single HTTP response for an endpoint.

type RoomRoutingRequest added in v0.7.0

type RoomRoutingRequest struct {
	Matrix map[string][]string `json:"matrix"`
}

RoomRoutingRequest is the request body for PUT /v1/rooms/{id}/routing. Matrix maps a listener-role to the set of source roles that legs with that role are allowed to hear. A listener role with no entry defaults to full mesh (hears every other leg). An entry with an empty list is an explicit "hear nothing" (isolated listener role).

type RoomRoutingUpdateRequest added in v0.7.0

type RoomRoutingUpdateRequest struct {
	Updates []RoutingRowUpdate `json:"updates"`
}

RoomRoutingUpdateRequest is the request body for PATCH /v1/rooms/{id}/routing.

type RoomRoutingView added in v0.7.0

type RoomRoutingView struct {
	Matrix map[string][]string `json:"matrix"`
}

RoomRoutingView is the response body for GET/PUT/PATCH /v1/rooms/{id}/routing.

type RoomView

type RoomView struct {
	ID           string    `json:"id"`
	AppID        string    `json:"app_id,omitempty"`
	SampleRate   int       `json:"sample_rate"`
	Participants []LegView `json:"participants"`
}

RoomView is the JSON representation of a room.

type RouteMeta

type RouteMeta struct {
	Method       string
	Path         string
	OperationID  string
	Summary      string
	Description  string
	Tags         []string
	RequestType  interface{} // nil or Go type instance (e.g. CreateLegRequest{})
	OptionalBody bool        // when true, requestBody is not marked required
	Responses    map[int]ResponseMeta
}

RouteMeta describes a single API endpoint for OpenAPI generation.

func RoutesMetadata

func RoutesMetadata() []RouteMeta

RoutesMetadata returns the authoritative list of all API routes with their OpenAPI metadata. Used by cmd/openapi-gen to produce openapi.yaml.

type RoutingRowUpdate added in v0.7.0

type RoutingRowUpdate struct {
	ListenerRole string   `json:"listener_role"`
	Sources      []string `json:"sources"`
}

RoutingRowUpdate is one entry in RoomRoutingUpdateRequest.Updates. Sources == nil clears the row (full mesh for that listener role).

type SIPAuth

type SIPAuth struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password"`
}

SIPAuth holds digest authentication credentials.

type SIPRegisterTrunkSpec added in v0.9.0

type SIPRegisterTrunkSpec struct {
	RegistrarURI   string `json:"registrar_uri"`
	AOR            string `json:"aor"`
	Username       string `json:"username,omitempty"`
	Password       string `json:"password"`
	ContactUser    string `json:"contact_user,omitempty"`
	ExpiresSeconds int    `json:"expires_seconds,omitempty"`
}

SIPRegisterTrunkSpec is the per-type body for sip_register trunks. The password is required on creation but never returned in any response.

type STTRequest

type STTRequest struct {
	Language string `json:"language"`
	Partial  bool   `json:"partial"`
	Provider string `json:"provider,omitempty"`
	APIKey   string `json:"api_key,omitempty"`
}

STTRequest is the request body for POST /v1/legs/{id}/stt and POST /v1/rooms/{id}/stt.

type STTStartLegResult added in v0.6.0

type STTStartLegResult struct {
	Status string `json:"status"`
	LegID  string `json:"leg_id"`
}

STTStartLegResult is the success payload for starting STT on a leg.

type STTStartRoomResult added in v0.6.0

type STTStartRoomResult struct {
	Status string   `json:"status"`
	RoomID string   `json:"room_id"`
	LegIDs []string `json:"leg_ids"`
}

STTStartRoomResult is the success payload for starting STT on a room.

type STTStopResult added in v0.6.0

type STTStopResult struct {
	Status string `json:"status"`
}

STTStopResult is the success payload for stopping STT on a leg or room.

type Server

type Server struct {
	Router     *chi.Mux
	LegMgr     *leg.Manager
	RoomMgr    *room.Manager
	SIPEngine  *sipmod.Engine
	Bus        *events.Bus
	Webhooks   *events.WebhookRegistry
	TTS        tts.Provider
	TTSCache   *tts.Cache
	S3         storage.Backend
	Metrics    *metrics.Collector
	Config     config.Config
	AllowedIPs []netip.Prefix
	Log        *slog.Logger

	// MoQWebTransport is set by main.go when MoQ is enabled. The MoQ leg
	// handler (s.moqLeg) returns 503 if this is nil.
	MoQWebTransport *webtransport.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	legMgr *leg.Manager,
	roomMgr *room.Manager,
	engine *sipmod.Engine,
	bus *events.Bus,
	webhooks *events.WebhookRegistry,
	ttsProvider tts.Provider,
	ttsCache *tts.Cache,
	s3Backend storage.Backend,
	metricsCollector *metrics.Collector,
	cfg config.Config,
	allowedIPs []netip.Prefix,
	log *slog.Logger,
) *Server

func (*Server) HandleInboundCall

func (s *Server) HandleInboundCall(call *sipmod.InboundCall)

HandleInboundCall is called from the SIP engine for inbound INVITE requests.

func (*Server) HandleIncomingRefer added in v0.3.0

func (s *Server) HandleIncomingRefer(callID, target string, replaces *sipmod.ReplacesParams, req *sip.Request, tx sip.ServerTransaction)

HandleIncomingRefer handles inbound REFER. Default-deny via SIP_REFER_AUTO_DIAL.

func (*Server) HandleReInvite

func (s *Server) HandleReInvite(callID string, direction string) []byte

HandleReInvite processes a remote re-INVITE by finding the matching SIPLeg via Call-ID and delegating to its hold/unhold handler. Returns the SDP answer to include in the 200 OK response.

func (*Server) HandleReferNotify added in v0.3.0

func (s *Server) HandleReferNotify(callID string, statusCode int, reason string, terminated bool)

HandleReferNotify dispatches NOTIFY sipfrag updates for outbound transfers.

func (*Server) HandleUpdate added in v0.9.0

func (s *Server) HandleUpdate(callID string, direction string, hasSDP bool) []byte

HandleUpdate processes a remote in-dialog UPDATE (RFC 3311). For session- timer refresh (no SDP), it only resets the session timer. When an SDP offer is included, it reuses the re-INVITE path to renegotiate media and returns the SDP answer for the 200 OK response.

func (*Server) HasSpeakingDetector added in v0.5.0

func (s *Server) HasSpeakingDetector(legID string) bool

HasSpeakingDetector reports whether a speaking detector is currently attached to the given leg. Primarily for tests.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SetLegRoleRequest added in v0.7.0

type SetLegRoleRequest struct {
	Role string `json:"role"`
}

SetLegRoleRequest is the request body for PATCH /v1/legs/{id}/role. Empty string clears the role (full mesh for that leg).

type TTSRequest

type TTSRequest struct {
	Text     string `json:"text"`
	Voice    string `json:"voice"`
	ModelID  string `json:"model_id"`
	Language string `json:"language,omitempty"`
	Prompt   string `json:"prompt,omitempty"`
	Volume   int    `json:"volume"`
	Provider string `json:"provider,omitempty"`
	APIKey   string `json:"api_key,omitempty"`
}

TTSRequest is the request body for POST /v1/legs/{id}/tts and POST /v1/rooms/{id}/tts.

type TTSStartResult added in v0.6.0

type TTSStartResult struct {
	TTSID  string `json:"tts_id"`
	Status string `json:"status"`
}

TTSStartResult is the success payload for synthesizing TTS on a leg or room.

type TransferLegResult added in v0.6.0

type TransferLegResult struct {
	Status string `json:"status"`
}

TransferLegResult is the success payload for initiating a transfer.

type TransferRequest added in v0.3.0

type TransferRequest struct {
	Target        string `json:"target"`                    // SIP URI of the third party
	ReplacesLegID string `json:"replaces_leg_id,omitempty"` // attended transfer: existing leg whose dialog is replaced
}

TransferRequest is the body for POST /v1/legs/{id}/transfer.

type TrunksListResponse added in v0.9.0

type TrunksListResponse struct {
	Trunks []sipmod.TrunkView `json:"trunks"`
}

TrunksListResponse is the body returned by GET /v1/sip/trunks.

type UpdateRoomBridgeRequest added in v0.6.0

type UpdateRoomBridgeRequest struct {
	Direction string `json:"direction"`
}

UpdateRoomBridgeRequest is the request body for PATCH /v1/rooms/{id}/bridges/{bridgeID}.

type VAPIAgentRequest

type VAPIAgentRequest struct {
	AssistantID    string            `json:"assistant_id"`
	FirstMessage   string            `json:"first_message,omitempty"`
	VariableValues map[string]string `json:"variable_values,omitempty"`
	APIKey         string            `json:"api_key,omitempty"`
}

VAPIAgentRequest is the request body for POST /v1/legs/{id}/agent/vapi and POST /v1/rooms/{id}/agent/vapi.

type VSICommandMeta added in v0.6.0

type VSICommandMeta struct {
	Name        string
	Summary     string
	Description string
	// PayloadType is a zero-value Go instance of the inbound payload struct
	// (or nil when the command takes no payload).
	PayloadType interface{}
	// ResultType is a zero-value Go instance of the success-response data
	// struct (or nil when the response carries no data beyond `type`/`request_id`).
	ResultType interface{}
	// ErrorCodes lists the HTTP-style status codes the command can surface in
	// an "error" frame. Documentation only; not enforced.
	ErrorCodes []int
}

VSICommandMeta describes a single command accepted on the /v1/vsi WebSocket. asyncapi-gen consumes this list — every command must be registered here or it will be missing from asyncapi.yaml.

Inbound: {"type": Name, "request_id": "...", "payload": Payload} Result: {"type": Name + ".result", "request_id": "...", "data": Result} Error: {"type": "error", "request_id": "...", "data": {"code": int, "message": string}}

func VSICommandsMetadata added in v0.6.0

func VSICommandsMetadata() []VSICommandMeta

VSICommandsMetadata returns the authoritative list of VSI commands. IMPORTANT: when adding, removing, or changing the shape of a VSI command, update this list AND run `make asyncapi` so asyncapi.yaml stays in sync.

type VSILifecycleFrame added in v0.6.0

type VSILifecycleFrame struct {
	Name        string
	Direction   string // "send" (server→client) or "receive" (client→server)
	Description string
}

VSILifecycleFrames returns the special server-sent and client-sent non-command frames on the /v1/vsi WebSocket. asyncapi-gen emits these as separate operations alongside the command set.

func VSILifecycleFramesMetadata added in v0.6.0

func VSILifecycleFramesMetadata() []VSILifecycleFrame

type VolumeRequest

type VolumeRequest struct {
	Volume int `json:"volume"`
}

VolumeRequest is the request body for PATCH /v1/legs/{id}/play/{playbackID}.

type WebRTCCandidatesResult added in v0.6.0

type WebRTCCandidatesResult struct {
	Candidates []webrtc.ICECandidateInit `json:"candidates"`
	Done       bool                      `json:"done"`
}

WebRTCCandidatesResult is the response payload for webrtc_get_candidates (REST and VSI). `Done` indicates that ICE gathering has finished — once true, no further candidates will be produced.

type WebRTCOfferRequest

type WebRTCOfferRequest struct {
	SDP string `json:"sdp"`
}

WebRTCOfferRequest is the request body for POST /v1/webrtc/offer.

type WebRTCOfferResult added in v0.6.0

type WebRTCOfferResult struct {
	LegID string `json:"leg_id"`
	SDP   string `json:"sdp"`
}

WebRTCOfferResult is the response payload for webrtc_offer (REST and VSI).