- language:python - sdk:compatibility - product:voice # Cancelling a Stream with the Update a Call API This guide will show you how to cancel a stream using the SignalWire Rest API. ## **Updating the Call** To cancel a stream, you need to send a POST request to the [Update a Call API](/rest/compatibility-api/endpoints/update-a-call) with a Url that returns XML to cancel the stream. Be sure to update the call-sid that started the stream. **Example using cURL to update the call**: bash curl -L -X POST https://EXAMPLE.signalwire.com/api/laml/2010-04-01/Accounts/PROJECT_ID_HERE/Calls/CALL_SID_HERE \ -H Content-Type: application/x-www-form-urlencoded \ -H Accept: application/json \ -H Authorization: Basic BASE64 TOKEN HERE \ --data-urlencode Url=https://Example.com/update ## **Cancelling the Stream** The XML returned by the Url should contain a element with a element inside it with the name of the stream you wish to stop. **Example**: xml Stopping stream Once the above XML is returned, the stream will be cancelled. ## **XML Bin Example** You can set the Url to an [XML Bin](../../creating-and-using-cxml-applications) that returns the XML to cancel the stream. Use the XML provided in the [Cancelling the Stream](#cancelling-the-stream) section above. ### Dynamic Stream Names with XML Bins If you are using dynamic stream names, you can use custom [mustache templating](/guides/adding-mustache-template-parameters-to-cxml-application-response#using-custom-mustache-templates) to dynamically set the stream name in the XML Bin. **Example**: xml Stopping stream ### Update the call Then in your POST request to the [Update a Call API](/rest/compatibility-api/endpoints/update-a-call), you can set the Url to the XML Bin endpoint and set the STREAMNAME query string to the name of the stream you wish to cancel. bash curl -L -X POST https://EXAMPLE.signalwire.com/api/laml/2010-04-01/Accounts/PROJECT_ID_HERE/Calls/CALL_SID_HERE \ -H Content-Type: application/x-www-form-urlencoded \ -H Accept: application/json \ -H Authorization: Basic BASE64 TOKEN HERE \ --data-urlencode Url=https://YOURSPACE.signalwire.com/laml-bins/xxxx-xxxx-xxxx-xxxx-xxxx?STREAMNAME=streamname ## **Server Endpoint Example** Below is a Python Flask example of a server endpoint that will return the [XML](#cancelling-the-stream) to cancel the stream. In this example we are utilizing the [SignalWire Python SDK](/compatibility-api/sdks) to generate the XML. python from flask import Flask from signalwire.voice_response import VoiceResponse, Stream, Stop app = Flask(__name__) @app.route(/update, methods=[GET, POST]) async def update_call(): response = VoiceResponse() stop = Stop() stream = Stream(name=stream) stop.append(stream) response.append(stop) response.say(Stopping stream) return response.to_xml() if __name__ == __main__: app.run(port=3000) ### Update the call Then in your POST request to the [Update a Call API](/rest/compatibility-api/endpoints/update-a-call), the Url should be set to the endpoint of this server. bash curl -L -X POST https://EXAMPLE.signalwire.com/api/laml/2010-04-01/Accounts/PROJECT_ID_HERE/Calls/CALL_SID_HERE \ -H Content-Type: application/x-www-form-urlencoded \ -H Accept: application/json \ -H Authorization: Basic BASE64 TOKEN HERE \ --data-urlencode Url=https://Example.com/update This should return the XML to cancel the stream.