> This page is for APIs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# Overview

> Relay is a single WebSocket connection your backend uses to control calls, send messages, run tasks, and react to real-time events.

SignalWire Relay gives your backend one persistent WebSocket connection to SignalWire. Over that single connection you place and control voice calls, send and receive messages, hand work to long-running processes, and react to real-time events the moment they happen.

That's the key difference from the [REST API](/docs/apis), where each request is its own HTTP round trip. Relay keeps the connection open, so SignalWire can push events straight to you — a call was answered, a recording finished, a message arrived — without you polling for them. You open the connection once, authenticate, then send commands and receive events over the same socket for as long as it stays open.

> **Note**
>
> This is the **Server** reference, for backend code that holds your SignalWire credentials. Building a browser or mobile app? See the [Client reference](/docs/apis/relay/client) for the Call Fabric and WebRTC surface.

## How a connection works

Every Relay session follows the same shape:

1. **Open the WebSocket** to `wss://relay.signalwire.com`.
2. **Authenticate** by sending `signalwire.connect` as your very first message. A WebSocket has no `Authorization` header, so your credentials — a project ID and API token — travel in that first message instead. See [Authentication](/docs/apis/relay/server/authentication).
3. **Send commands and receive events** over the connection — dial a call, send a message, and listen for the events each service emits.

Every response carries a result you check for success or failure. See [Errors](/docs/apis/relay/server/errors).

#### [Authentication](/docs/apis/relay/server/authentication)

Open the socket, then log in with your first message using your project ID and API token.

#### [Events and subscriptions](/docs/apis/relay/server/events)

React to server-pushed events, and subscribe to inbound ones — like an incoming call — with contexts.

#### [Connection lifecycle](/docs/apis/relay/server/connection-lifecycle)

Detect a dropped connection, rotate your API token in place, and reconnect cleanly.

#### [Errors](/docs/apis/relay/server/errors)

Every response carries a `code` and a `message`. Learn how to tell success from failure and what the common codes mean.

## Services

Relay groups its commands and events into services. They all share the one connection you open with `signalwire.connect`.

#### Signalwire

The entry point. Authenticate, open the connection, and subscribe to the contexts whose events you want to receive.

#### Calling

Control voice calls: dial and answer, bridge calls together, play and collect audio, record, run detection, and add AI agents.

#### Messaging

Send SMS and MMS, and react to incoming messages and delivery updates.

#### Tasking

Push a JSON payload to a long-running Relay client from a short-lived process such as a web request handler or a cron job.

#### Provisioning

Provision a Relay connector and receive the runtime configuration it should run with.

Browse the full command-and-event reference for each service in the API reference under this tab.

## Use Relay from an SDK

You can speak the Relay WebSocket protocol directly, but most developers use a SignalWire SDK that wraps the connection, authentication, and every command in idiomatic, type-safe methods.

The [Server SDKs](/docs/server-sdks) — the Realtime clients for backend code (Python, Node, and more) — expose the `calling`, `messaging`, and `tasking` services as native objects. See the [Realtime reference](/docs/server-sdks/reference/python/relay).

Pick the language that matches your stack, or read on to work with the protocol directly.