unreceive

View as MarkdownOpen in Claude

Unsubscribe from contexts for inbound call and message events. Sends a signalwire.unreceive request to stop receiving events on the specified contexts. This is the inverse of receive().

After unsubscribing, inbound calls routed to those contexts will no longer trigger the @on_call handler on this client.

Parameters

contexts
list[str]Required

List of context names to unsubscribe from. If the list is empty, the method returns immediately without sending a request.

Returns

None

Example

from signalwire.relay import RelayClient
client = RelayClient(
project="your-project-id",
token="your-api-token",
contexts=["sales", "support", "billing"],
)
@client.on_call
async def handle_call(call):
await call.answer()
# Dynamically unsubscribe from "billing" after the first call
await client.unreceive(["billing"])
print("Unsubscribed from billing context")
await call.hangup()
client.run()