signalwire.rest¶
signalwire.rest
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
SignalWire REST API client module.
__all__ = ['PhoneCallHandler', 'RestClient', 'SignalWireRestError']
module-attribute
¶
RestClient
¶
REST client for the SignalWire platform APIs.
Usage
client = RestClient( project="your-project-id", token="your-api-token", host="your-space.signalwire.com", )
Or use environment variables:¶
SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, SIGNALWIRE_SPACE¶
client = RestClient()
Use namespaced resources¶
client.fabric.ai_agents.list() client.calling.play(call_id, play=[...]) client.phone_numbers.search(area_code="512") client.video.rooms.create(name="standup") client.compat.calls.list()
fabric = FabricNamespace(self._http)
instance-attribute
¶
calling = CallingNamespace(self._http)
instance-attribute
¶
phone_numbers = PhoneNumbersResource(self._http)
instance-attribute
¶
addresses = AddressesResource(self._http)
instance-attribute
¶
queues = QueuesResource(self._http)
instance-attribute
¶
recordings = RecordingsResource(self._http)
instance-attribute
¶
number_groups = NumberGroupsResource(self._http)
instance-attribute
¶
verified_callers = VerifiedCallersResource(self._http)
instance-attribute
¶
sip_profile = SipProfileResource(self._http)
instance-attribute
¶
lookup = LookupResource(self._http)
instance-attribute
¶
short_codes = ShortCodesResource(self._http)
instance-attribute
¶
imported_numbers = ImportedNumbersResource(self._http)
instance-attribute
¶
mfa = MfaResource(self._http)
instance-attribute
¶
registry = RegistryNamespace(self._http)
instance-attribute
¶
datasphere = DatasphereNamespace(self._http)
instance-attribute
¶
video = VideoNamespace(self._http)
instance-attribute
¶
logs = LogsNamespace(self._http)
instance-attribute
¶
project = ProjectNamespace(self._http)
instance-attribute
¶
pubsub = PubSubResource(self._http)
instance-attribute
¶
chat = ChatResource(self._http)
instance-attribute
¶
compat = CompatNamespace(self._http, project)
instance-attribute
¶
__init__(project=None, token=None, host=None)
¶
SignalWireRestError
¶
PhoneCallHandler
¶
Bases: str, Enum
call_handler values for phone_numbers.update.
Each value is a str subclass, so passing the enum member directly into
phone_numbers.update(..., call_handler=PhoneCallHandler.RELAY_SCRIPT)
serializes to the wire value without .value indirection.
================= ============================= ======================= Enum member Companion field (required) Auto-creates resource ================= ============================= ======================= RELAY_SCRIPT call_relay_script_url swml_webhook LAML_WEBHOOKS call_request_url cxml_webhook LAML_APPLICATION call_laml_application_id cxml_application AI_AGENT call_ai_agent_id ai_agent CALL_FLOW call_flow_id call_flow RELAY_APPLICATION call_relay_application relay_application RELAY_TOPIC call_relay_topic (routes via RELAY) RELAY_CONTEXT call_relay_context (legacy, prefer topic) RELAY_CONNECTOR (connector config) (internal) VIDEO_ROOM call_video_room_id (routes to Video API) DIALOGFLOW call_dialogflow_agent_id (none) ================= ============================= =======================
Note: LAML_WEBHOOKS (wire value laml_webhooks) produces a cXML
handler, not a generic webhook. For SWML, use RELAY_SCRIPT.
RELAY_SCRIPT = 'relay_script'
class-attribute
instance-attribute
¶
LAML_WEBHOOKS = 'laml_webhooks'
class-attribute
instance-attribute
¶
LAML_APPLICATION = 'laml_application'
class-attribute
instance-attribute
¶
AI_AGENT = 'ai_agent'
class-attribute
instance-attribute
¶
CALL_FLOW = 'call_flow'
class-attribute
instance-attribute
¶
RELAY_APPLICATION = 'relay_application'
class-attribute
instance-attribute
¶
RELAY_TOPIC = 'relay_topic'
class-attribute
instance-attribute
¶
RELAY_CONTEXT = 'relay_context'
class-attribute
instance-attribute
¶
RELAY_CONNECTOR = 'relay_connector'
class-attribute
instance-attribute
¶
VIDEO_ROOM = 'video_room'
class-attribute
instance-attribute
¶
DIALOGFLOW = 'dialogflow'
class-attribute
instance-attribute
¶
call_handler
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
PhoneCallHandler — enum of call_handler values accepted by phone_numbers.update.
Named PhoneCallHandler (not CallHandler) to avoid colliding with the
RELAY client's inbound-call-handler callback type.
Setting a phone number's call_handler + the handler-specific companion
field routes inbound calls and auto-materializes the matching Fabric
resource on the server. See the high-level helpers on
:class:signalwire.rest.namespaces.phone_numbers.PhoneNumbersResource.
PhoneCallHandler
¶
Bases: str, Enum
call_handler values for phone_numbers.update.
Each value is a str subclass, so passing the enum member directly into
phone_numbers.update(..., call_handler=PhoneCallHandler.RELAY_SCRIPT)
serializes to the wire value without .value indirection.
================= ============================= ======================= Enum member Companion field (required) Auto-creates resource ================= ============================= ======================= RELAY_SCRIPT call_relay_script_url swml_webhook LAML_WEBHOOKS call_request_url cxml_webhook LAML_APPLICATION call_laml_application_id cxml_application AI_AGENT call_ai_agent_id ai_agent CALL_FLOW call_flow_id call_flow RELAY_APPLICATION call_relay_application relay_application RELAY_TOPIC call_relay_topic (routes via RELAY) RELAY_CONTEXT call_relay_context (legacy, prefer topic) RELAY_CONNECTOR (connector config) (internal) VIDEO_ROOM call_video_room_id (routes to Video API) DIALOGFLOW call_dialogflow_agent_id (none) ================= ============================= =======================
Note: LAML_WEBHOOKS (wire value laml_webhooks) produces a cXML
handler, not a generic webhook. For SWML, use RELAY_SCRIPT.
RELAY_SCRIPT = 'relay_script'
class-attribute
instance-attribute
¶
LAML_WEBHOOKS = 'laml_webhooks'
class-attribute
instance-attribute
¶
LAML_APPLICATION = 'laml_application'
class-attribute
instance-attribute
¶
AI_AGENT = 'ai_agent'
class-attribute
instance-attribute
¶
CALL_FLOW = 'call_flow'
class-attribute
instance-attribute
¶
RELAY_APPLICATION = 'relay_application'
class-attribute
instance-attribute
¶
RELAY_TOPIC = 'relay_topic'
class-attribute
instance-attribute
¶
RELAY_CONTEXT = 'relay_context'
class-attribute
instance-attribute
¶
RELAY_CONNECTOR = 'relay_connector'
class-attribute
instance-attribute
¶
VIDEO_ROOM = 'video_room'
class-attribute
instance-attribute
¶
DIALOGFLOW = 'dialogflow'
class-attribute
instance-attribute
¶
client
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
RestClient — top-level REST client with namespaced sub-objects.
RestClient
¶
REST client for the SignalWire platform APIs.
Usage
client = RestClient( project="your-project-id", token="your-api-token", host="your-space.signalwire.com", )
Or use environment variables:¶
SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, SIGNALWIRE_SPACE¶
client = RestClient()
Use namespaced resources¶
client.fabric.ai_agents.list() client.calling.play(call_id, play=[...]) client.phone_numbers.search(area_code="512") client.video.rooms.create(name="standup") client.compat.calls.list()
fabric = FabricNamespace(self._http)
instance-attribute
¶
calling = CallingNamespace(self._http)
instance-attribute
¶
phone_numbers = PhoneNumbersResource(self._http)
instance-attribute
¶
addresses = AddressesResource(self._http)
instance-attribute
¶
queues = QueuesResource(self._http)
instance-attribute
¶
recordings = RecordingsResource(self._http)
instance-attribute
¶
number_groups = NumberGroupsResource(self._http)
instance-attribute
¶
verified_callers = VerifiedCallersResource(self._http)
instance-attribute
¶
sip_profile = SipProfileResource(self._http)
instance-attribute
¶
lookup = LookupResource(self._http)
instance-attribute
¶
short_codes = ShortCodesResource(self._http)
instance-attribute
¶
imported_numbers = ImportedNumbersResource(self._http)
instance-attribute
¶
mfa = MfaResource(self._http)
instance-attribute
¶
registry = RegistryNamespace(self._http)
instance-attribute
¶
datasphere = DatasphereNamespace(self._http)
instance-attribute
¶
video = VideoNamespace(self._http)
instance-attribute
¶
logs = LogsNamespace(self._http)
instance-attribute
¶
project = ProjectNamespace(self._http)
instance-attribute
¶
pubsub = PubSubResource(self._http)
instance-attribute
¶
chat = ChatResource(self._http)
instance-attribute
¶
compat = CompatNamespace(self._http, project)
instance-attribute
¶
__init__(project=None, token=None, host=None)
¶
namespaces
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
addresses
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Addresses namespace — list, create, get, delete (no update).
calling
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Calling API namespace — REST-based call control via command dispatch.
All commands are sent as POST /api/calling/calls with a command field.
CallingNamespace
¶
Bases: BaseResource
REST call control — all 37 commands dispatched via single POST endpoint.
__init__(http)
¶
dial(**params)
¶
update(**params)
¶
end(call_id, **params)
¶
transfer(call_id, **params)
¶
disconnect(call_id, **params)
¶
play(call_id, **params)
¶
play_pause(call_id, **params)
¶
play_resume(call_id, **params)
¶
play_stop(call_id, **params)
¶
play_volume(call_id, **params)
¶
record(call_id, **params)
¶
record_pause(call_id, **params)
¶
record_resume(call_id, **params)
¶
record_stop(call_id, **params)
¶
collect(call_id, **params)
¶
collect_stop(call_id, **params)
¶
collect_start_input_timers(call_id, **params)
¶
detect(call_id, **params)
¶
detect_stop(call_id, **params)
¶
tap(call_id, **params)
¶
tap_stop(call_id, **params)
¶
stream(call_id, **params)
¶
stream_stop(call_id, **params)
¶
denoise(call_id, **params)
¶
denoise_stop(call_id, **params)
¶
transcribe(call_id, **params)
¶
transcribe_stop(call_id, **params)
¶
ai_message(call_id, **params)
¶
ai_hold(call_id, **params)
¶
ai_unhold(call_id, **params)
¶
ai_stop(call_id, **params)
¶
live_transcribe(call_id, **params)
¶
live_translate(call_id, **params)
¶
send_fax_stop(call_id, **params)
¶
receive_fax_stop(call_id, **params)
¶
refer(call_id, **params)
¶
user_event(call_id, **params)
¶
chat
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Chat API namespace — token creation.
compat
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Compatibility API namespace — Twilio-compatible LAML API with AccountSid scoping.
CompatAccounts
¶
CompatCalls
¶
CompatMessages
¶
CompatFaxes
¶
CompatConferences
¶
Bases: BaseResource
Compat conference management with participants, recordings, and streams.
list(**params)
¶
get(sid)
¶
update(sid, /, **kwargs)
¶
list_participants(conference_sid, **params)
¶
get_participant(conference_sid, call_sid)
¶
update_participant(conference_sid, call_sid, **kwargs)
¶
remove_participant(conference_sid, call_sid)
¶
list_recordings(conference_sid, **params)
¶
get_recording(conference_sid, recording_sid)
¶
update_recording(conference_sid, recording_sid, **kwargs)
¶
delete_recording(conference_sid, recording_sid)
¶
start_stream(conference_sid, **kwargs)
¶
stop_stream(conference_sid, stream_sid, **kwargs)
¶
CompatPhoneNumbers
¶
CompatQueues
¶
CompatRecordings
¶
CompatTranscriptions
¶
CompatTokens
¶
CompatNamespace
¶
Twilio-compatible LAML API namespace with AccountSid scoping.
accounts = CompatAccounts(http)
instance-attribute
¶
calls = CompatCalls(http, f'{base}/Calls')
instance-attribute
¶
messages = CompatMessages(http, f'{base}/Messages')
instance-attribute
¶
faxes = CompatFaxes(http, f'{base}/Faxes')
instance-attribute
¶
conferences = CompatConferences(http, f'{base}/Conferences')
instance-attribute
¶
phone_numbers = CompatPhoneNumbers(http, f'{base}/IncomingPhoneNumbers')
instance-attribute
¶
applications = CompatApplications(http, f'{base}/Applications')
instance-attribute
¶
laml_bins = CompatLamlBins(http, f'{base}/LamlBins')
instance-attribute
¶
queues = CompatQueues(http, f'{base}/Queues')
instance-attribute
¶
recordings = CompatRecordings(http, f'{base}/Recordings')
instance-attribute
¶
transcriptions = CompatTranscriptions(http, f'{base}/Transcriptions')
instance-attribute
¶
tokens = CompatTokens(http, f'{base}/tokens')
instance-attribute
¶
__init__(http, account_sid)
¶
datasphere
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Datasphere API namespace — document management and semantic search.
DatasphereDocuments
¶
fabric
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Fabric API namespace — resource composition, addresses, and tokens.
FabricResource
¶
Bases: CrudWithAddresses
Standard fabric resource with CRUD + addresses.
FabricResourcePUT
¶
Bases: CrudWithAddresses
Fabric resource that uses PUT for updates.
AutoMaterializedWebhook
¶
Bases: FabricResource
Fabric webhook resource that's normally auto-created by phone_numbers.set_*.
Exposed for backwards compatibility. The binding model for these resources
is on the phone number (see phone_numbers.set_swml_webhook /
set_cxml_webhook) — setting call_handler on a phone number
auto-materializes the webhook. Calling create here produces an orphan
resource that isn't bound to any phone number.
create(**kwargs)
¶
SwmlWebhooksResource
¶
Bases: AutoMaterializedWebhook
CxmlWebhooksResource
¶
Bases: AutoMaterializedWebhook
CallFlowsResource
¶
Bases: FabricResourcePUT
Call flows with version management.
Note: call_flow (singular) is used in address/version paths per the API spec.
ConferenceRoomsResource
¶
Bases: FabricResourcePUT
Conference rooms — uses singular 'conference_room' for sub-resource paths.
list_addresses(resource_id, **params)
¶
SubscribersResource
¶
Bases: FabricResourcePUT
Subscribers with SIP endpoint management.
CxmlApplicationsResource
¶
Bases: FabricResourcePUT
cXML applications — no create method (read/update/delete only).
create(**kwargs)
¶
GenericResources
¶
Bases: BaseResource
Generic resource operations across all fabric resource types.
list(**params)
¶
get(resource_id)
¶
delete(resource_id)
¶
list_addresses(resource_id, **params)
¶
assign_phone_route(resource_id, **kwargs)
¶
Deprecated for the common binding cases. Use phone_numbers.set_* helpers.
This endpoint (POST /api/fabric/resources/{id}/phone_routes) accepts
only a narrow set of legacy resource types as the attach target. It
does not work for swml_webhook / cxml_webhook / ai_agent
bindings — those are configured on the phone number and the Fabric
resource is auto-materialized (see phone_numbers.set_swml_webhook
etc.). The authoritative list of accepting resource types lives in the
OpenAPI spec; routing here for those types returns 404 or 422.
assign_domain_application(resource_id, **kwargs)
¶
FabricAddresses
¶
FabricTokens
¶
FabricNamespace
¶
Fabric API namespace grouping all resource types.
swml_scripts = FabricResourcePUT(http, f'{base}/swml_scripts')
instance-attribute
¶
relay_applications = FabricResourcePUT(http, f'{base}/relay_applications')
instance-attribute
¶
call_flows = CallFlowsResource(http, f'{base}/call_flows')
instance-attribute
¶
conference_rooms = ConferenceRoomsResource(http, f'{base}/conference_rooms')
instance-attribute
¶
freeswitch_connectors = FabricResourcePUT(http, f'{base}/freeswitch_connectors')
instance-attribute
¶
subscribers = SubscribersResource(http, f'{base}/subscribers')
instance-attribute
¶
sip_endpoints = FabricResourcePUT(http, f'{base}/sip_endpoints')
instance-attribute
¶
cxml_scripts = FabricResourcePUT(http, f'{base}/cxml_scripts')
instance-attribute
¶
cxml_applications = CxmlApplicationsResource(http, f'{base}/cxml_applications')
instance-attribute
¶
swml_webhooks = SwmlWebhooksResource(http, f'{base}/swml_webhooks')
instance-attribute
¶
ai_agents = FabricResource(http, f'{base}/ai_agents')
instance-attribute
¶
sip_gateways = FabricResource(http, f'{base}/sip_gateways')
instance-attribute
¶
cxml_webhooks = CxmlWebhooksResource(http, f'{base}/cxml_webhooks')
instance-attribute
¶
resources = GenericResources(http, base)
instance-attribute
¶
addresses = FabricAddresses(http, '/api/fabric/addresses')
instance-attribute
¶
tokens = FabricTokens(http)
instance-attribute
¶
__init__(http)
¶
imported_numbers
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Imported Phone Numbers namespace — create only.
logs
¶
lookup
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Phone Number Lookup namespace.
mfa
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
MFA (Multi-Factor Authentication) namespace.
number_groups
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Number Groups namespace — CRUD + membership management.
phone_numbers
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Phone Numbers namespace — list, search, purchase, get, update, release, bind.
PhoneNumbersResource
¶
Bases: CrudResource
Phone number management.
Supports the standard CRUD surface plus typed helpers for binding an
inbound call to a handler (SWML webhook, cXML webhook, AI agent, call
flow, RELAY application/topic). The binding model is: set
call_handler + the handler-specific companion field on the phone
number; the server auto-materializes the matching Fabric resource.
See :mod:signalwire.rest.call_handler for the enum, and the
porting-sdk's phone-binding.md for the full model.
__init__(http)
¶
search(**params)
¶
set_swml_webhook(resource_id, url, **extra)
¶
Route inbound calls to an SWML webhook URL.
Your backend returns an SWML document per call. The server
auto-creates a swml_webhook Fabric resource keyed off this URL.
set_cxml_webhook(resource_id, url, fallback_url=None, status_callback_url=None, **extra)
¶
Route inbound calls to a cXML (Twilio-compat / LAML) webhook.
Despite the wire value laml_webhooks being plural, this creates
a single cxml_webhook Fabric resource. fallback_url is used
when the primary URL fails; status_callback_url receives call
status updates.
set_cxml_application(resource_id, application_id, **extra)
¶
Route inbound calls to an existing cXML application by ID.
set_ai_agent(resource_id, agent_id, **extra)
¶
Route inbound calls to an AI Agent Fabric resource by ID.
set_call_flow(resource_id, flow_id, version=None, **extra)
¶
Route inbound calls to a Call Flow by ID.
version accepts "working_copy" or "current_deployed"
(server default when omitted).
set_relay_application(resource_id, name, **extra)
¶
Route inbound calls to a named RELAY application.
set_relay_topic(resource_id, topic, status_callback_url=None, **extra)
¶
Route inbound calls to a RELAY topic (client subscription).
project
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Project API namespace — API token management.
pubsub
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
PubSub API namespace — token creation.
queues
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Queues namespace — CRUD + member management.
recordings
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Recordings namespace — list, get, delete (no create/update).
registry
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
10DLC Campaign Registry namespace — brands, campaigns, orders, numbers.
RegistryBrands
¶
RegistryCampaigns
¶
RegistryNamespace
¶
10DLC Campaign Registry namespace.
brands = RegistryBrands(http, f'{base}/brands')
instance-attribute
¶
campaigns = RegistryCampaigns(http, f'{base}/campaigns')
instance-attribute
¶
orders = RegistryOrders(http, f'{base}/orders')
instance-attribute
¶
numbers = RegistryNumbers(http, f'{base}/numbers')
instance-attribute
¶
__init__(http)
¶
short_codes
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Short Codes namespace — list, get, update (no create/delete).
sip_profile
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
SIP Profile namespace — get and update project SIP profile.
verified_callers
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Verified Caller IDs namespace — CRUD + verification flow.
video
¶
Copyright (c) 2025 SignalWire
This file is part of the SignalWire SDK.
Licensed under the MIT License. See LICENSE file in the project root for full license information.
Video API namespace — rooms, sessions, recordings, conferences, tokens, streams.
VideoRooms
¶
VideoRoomSessions
¶
VideoRoomRecordings
¶
VideoConferences
¶
VideoConferenceTokens
¶
VideoStreams
¶
VideoNamespace
¶
Video API namespace.