***

title: Constants
slug: /reference/typescript/relay/constants
description: RELAY constants for call states, events, and message states.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[callstateevent-endreason]: /docs/server-sdks/reference/typescript/relay/events

[connectevent-connectstate]: /docs/server-sdks/reference/typescript/relay/events

[call-on]: /docs/server-sdks/reference/typescript/relay/call

[relayevent-eventtype]: /docs/server-sdks/reference/typescript/relay/events

[message-wait]: /docs/server-sdks/reference/typescript/relay/message

[playevent-state]: /docs/server-sdks/reference/typescript/relay/events

[recordevent-state]: /docs/server-sdks/reference/typescript/relay/events

[call-detect]: /docs/server-sdks/reference/typescript/relay/call/detect

The `@signalwire/sdk` package exports string and numeric constants used
throughout the RELAY namespace for call states, end reasons, connect states, event
types, message states, media operation states, and protocol settings.

```typescript {2-7}
import {
  CALL_STATE_ANSWERED,
  CALL_STATE_ENDED,
  CONNECT_STATE_CONNECTED,
  EVENT_CALL_STATE,
  MESSAGE_STATE_DELIVERED,
} from '@signalwire/sdk';
```

## Protocol

<ParamField path="PROTOCOL_VERSION" type="Record<string, number>" toc={true}>
  RELAY protocol version. Value: `{ major: 2, minor: 0, revision: 0 }`.
</ParamField>

<ParamField path="AGENT_STRING" type="string" toc={true}>
  User agent string sent during connection. Value: `"@signalwire/sdk-typescript/2.0"`.
</ParamField>

<ParamField path="DEFAULT_RELAY_HOST" type="string" toc={true}>
  Default WebSocket host for RELAY connections. Value: `"relay.signalwire.com"`.
</ParamField>

## JSON-RPC Methods

Internal method identifiers used by the RELAY WebSocket protocol.

| Constant                       | Value                     |
| ------------------------------ | ------------------------- |
| `METHOD_SIGNALWIRE_CONNECT`    | `"signalwire.connect"`    |
| `METHOD_SIGNALWIRE_EVENT`      | `"signalwire.event"`      |
| `METHOD_SIGNALWIRE_PING`       | `"signalwire.ping"`       |
| `METHOD_SIGNALWIRE_DISCONNECT` | `"signalwire.disconnect"` |
| `METHOD_SIGNALWIRE_RECEIVE`    | `"signalwire.receive"`    |
| `METHOD_SIGNALWIRE_UNRECEIVE`  | `"signalwire.unreceive"`  |

***

## Call States

Constants representing the lifecycle states of a RELAY call. A call progresses
through these states in order: `created` -> `ringing` -> `answered` -> `ending` -> `ended`.

| Constant              | Value        | Description                        |
| --------------------- | ------------ | ---------------------------------- |
| `CALL_STATE_CREATED`  | `"created"`  | Call object has been created       |
| `CALL_STATE_RINGING`  | `"ringing"`  | Call is ringing at the destination |
| `CALL_STATE_ANSWERED` | `"answered"` | Call has been answered             |
| `CALL_STATE_ENDING`   | `"ending"`   | Call is in the process of ending   |
| `CALL_STATE_ENDED`    | `"ended"`    | Call has ended                     |

<ParamField path="CALL_STATES" type="readonly string[]" toc={true}>
  Array of all call states in lifecycle order:
  `['created', 'ringing', 'answered', 'ending', 'ended']`.
</ParamField>

## End Reasons

Constants for the reason a call ended. Available in
[`CallStateEvent.endReason`][callstateevent-endreason] when the call
reaches the `ended` state.

| Constant                  | Value            | Description                                        |
| ------------------------- | ---------------- | -------------------------------------------------- |
| `END_REASON_HANGUP`       | `"hangup"`       | Normal hangup by either party                      |
| `END_REASON_CANCEL`       | `"cancel"`       | Call was cancelled before answer                   |
| `END_REASON_BUSY`         | `"busy"`         | Destination returned busy                          |
| `END_REASON_NO_ANSWER`    | `"noAnswer"`     | No answer within timeout                           |
| `END_REASON_DECLINE`      | `"decline"`      | Call was declined                                  |
| `END_REASON_ERROR`        | `"error"`        | An error occurred                                  |
| `END_REASON_ABANDONED`    | `"abandoned"`    | Call was abandoned (e.g., caller hung up in queue) |
| `END_REASON_MAX_DURATION` | `"max_duration"` | Call exceeded maximum allowed duration             |
| `END_REASON_NOT_FOUND`    | `"not_found"`    | Destination not found                              |

***

## Connect States

Constants representing the state of a call bridge (connect) operation. Used in
[`ConnectEvent.connectState`][connectevent-connectstate].

| Constant                     | Value            | Description                  |
| ---------------------------- | ---------------- | ---------------------------- |
| `CONNECT_STATE_CONNECTING`   | `"connecting"`   | Bridge is being established  |
| `CONNECT_STATE_CONNECTED`    | `"connected"`    | Bridge is active             |
| `CONNECT_STATE_DISCONNECTED` | `"disconnected"` | Bridge has been disconnected |
| `CONNECT_STATE_FAILED`       | `"failed"`       | Bridge attempt failed        |

***

## Event Types

String constants for all RELAY event types. Use these when registering event
handlers with [`Call.on()`][call-on] or when
matching against [`RelayEvent.eventType`][relayevent-eventtype].

### Calling Events

| Constant                 | Value                        |
| ------------------------ | ---------------------------- |
| `EVENT_CALL_STATE`       | `"calling.call.state"`       |
| `EVENT_CALL_RECEIVE`     | `"calling.call.receive"`     |
| `EVENT_CALL_CONNECT`     | `"calling.call.connect"`     |
| `EVENT_CALL_PLAY`        | `"calling.call.play"`        |
| `EVENT_CALL_COLLECT`     | `"calling.call.collect"`     |
| `EVENT_CALL_RECORD`      | `"calling.call.record"`      |
| `EVENT_CALL_DETECT`      | `"calling.call.detect"`      |
| `EVENT_CALL_FAX`         | `"calling.call.fax"`         |
| `EVENT_CALL_TAP`         | `"calling.call.tap"`         |
| `EVENT_CALL_SEND_DIGITS` | `"calling.call.send_digits"` |
| `EVENT_CALL_DIAL`        | `"calling.call.dial"`        |
| `EVENT_CALL_REFER`       | `"calling.call.refer"`       |
| `EVENT_CALL_DENOISE`     | `"calling.call.denoise"`     |
| `EVENT_CALL_PAY`         | `"calling.call.pay"`         |
| `EVENT_CALL_QUEUE`       | `"calling.call.queue"`       |
| `EVENT_CALL_STREAM`      | `"calling.call.stream"`      |
| `EVENT_CALL_ECHO`        | `"calling.call.echo"`        |
| `EVENT_CALL_TRANSCRIBE`  | `"calling.call.transcribe"`  |
| `EVENT_CALL_HOLD`        | `"calling.call.hold"`        |
| `EVENT_CONFERENCE`       | `"calling.conference"`       |
| `EVENT_CALLING_ERROR`    | `"calling.error"`            |

### Messaging Events

| Constant                  | Value                 |
| ------------------------- | --------------------- |
| `EVENT_MESSAGING_RECEIVE` | `"messaging.receive"` |
| `EVENT_MESSAGING_STATE`   | `"messaging.state"`   |

### Authorization Event

| Constant                    | Value                              |
| --------------------------- | ---------------------------------- |
| `EVENT_AUTHORIZATION_STATE` | `"signalwire.authorization.state"` |

***

## Message States

Constants representing the lifecycle states of an SMS/MMS message. Outbound
messages progress through: `queued` -> `initiated` -> `sent` -> `delivered`
(or `undelivered` / `failed`). Inbound messages arrive with state `received`.

| Constant                    | Value           | Description                            |
| --------------------------- | --------------- | -------------------------------------- |
| `MESSAGE_STATE_QUEUED`      | `"queued"`      | Message has been queued for sending    |
| `MESSAGE_STATE_INITIATED`   | `"initiated"`   | Send process has started               |
| `MESSAGE_STATE_SENT`        | `"sent"`        | Message has been sent to the carrier   |
| `MESSAGE_STATE_DELIVERED`   | `"delivered"`   | Message was delivered to the recipient |
| `MESSAGE_STATE_UNDELIVERED` | `"undelivered"` | Message could not be delivered         |
| `MESSAGE_STATE_FAILED`      | `"failed"`      | Message send failed                    |
| `MESSAGE_STATE_RECEIVED`    | `"received"`    | Inbound message received               |

<ParamField path="MESSAGE_TERMINAL_STATES" type="readonly string[]" toc={true}>
  Array of terminal states that resolve a [`Message.wait()`][message-wait] call:
  `['delivered', 'undelivered', 'failed']`.
</ParamField>

## Play States

Constants for audio playback operation states. Used in
[`PlayEvent.state`][playevent-state].

| Constant              | Value        | Description             |
| --------------------- | ------------ | ----------------------- |
| `PLAY_STATE_PLAYING`  | `"playing"`  | Audio is playing        |
| `PLAY_STATE_PAUSED`   | `"paused"`   | Playback is paused      |
| `PLAY_STATE_FINISHED` | `"finished"` | Playback completed      |
| `PLAY_STATE_ERROR`    | `"error"`    | Playback error occurred |

***

## Record States

Constants for recording operation states. Used in
[`RecordEvent.state`][recordevent-state].

| Constant                 | Value         | Description             |
| ------------------------ | ------------- | ----------------------- |
| `RECORD_STATE_RECORDING` | `"recording"` | Recording is active     |
| `RECORD_STATE_PAUSED`    | `"paused"`    | Recording is paused     |
| `RECORD_STATE_FINISHED`  | `"finished"`  | Recording completed     |
| `RECORD_STATE_NO_INPUT`  | `"no_input"`  | No audio input detected |

***

## Detect Types

Constants for detection operation types. Used in the `type` field of the
`detect` parameter passed to [`call.detect()`][call-detect].

| Constant              | Value       | Description                 |
| --------------------- | ----------- | --------------------------- |
| `DETECT_TYPE_MACHINE` | `"machine"` | Answering machine detection |
| `DETECT_TYPE_FAX`     | `"fax"`     | Fax tone detection          |
| `DETECT_TYPE_DIGIT`   | `"digit"`   | DTMF digit detection        |

***

## Room States

Constants for audio/video room join/leave states.

| Constant             | Value       | Description         |
| -------------------- | ----------- | ------------------- |
| `ROOM_STATE_JOINING` | `"joining"` | Joining the room    |
| `ROOM_STATE_JOIN`    | `"join"`    | Successfully joined |
| `ROOM_STATE_LEAVING` | `"leaving"` | Leaving the room    |
| `ROOM_STATE_LEAVE`   | `"leave"`   | Successfully left   |

***

## Reconnect Settings

Configuration constants for the WebSocket reconnection strategy.

| Constant                   | Value  | Description                                        |
| -------------------------- | ------ | -------------------------------------------------- |
| `RECONNECT_MIN_DELAY`      | `1.0`  | Minimum delay between reconnect attempts (seconds) |
| `RECONNECT_MAX_DELAY`      | `30.0` | Maximum delay between reconnect attempts (seconds) |
| `RECONNECT_BACKOFF_FACTOR` | `2.0`  | Exponential backoff multiplier                     |

## **Example**

```typescript {12}
import {
  CALL_STATE_ANSWERED,
  CALL_STATE_ENDED,
  EVENT_CALL_STATE,
  MESSAGE_STATE_DELIVERED,
  MESSAGE_STATE_UNDELIVERED,
  MESSAGE_STATE_FAILED,
} from '@signalwire/sdk';
import type { CallStateEvent } from '@signalwire/sdk';

// Use in event handlers
function handleCallState(event: CallStateEvent) {
  if (event.callState === CALL_STATE_ANSWERED) {
    console.log('Call answered!');
  } else if (event.callState === CALL_STATE_ENDED) {
    console.log(`Call ended: ${event.endReason}`);
  }
}

// Check terminal message states
const TERMINAL = [MESSAGE_STATE_DELIVERED, MESSAGE_STATE_UNDELIVERED, MESSAGE_STATE_FAILED];
function handleMessageState(message: { state: string }) {
  if (TERMINAL.includes(message.state)) {
    console.log('Message delivery complete');
  }
}
```