Overview
This article provides step-by-step instructions for closing channel automatically when host left the channel. This functionality is useful for hosts who need to manage their broadcasts and ensure that all participants are removed from the stream effectively.
Prerequisites
- Basic understanding of webhooks, Channel Management REST API. and API integration.
- A valid Agora project with the necessary access tokens.
Issue Description
Symptoms
You want to close a broadcast channel as a host, but need guidance on the API and implementation process.
Root Cause
Currently, there is no direct API call to instantly close a channel. However, you can achieve this using webhooks and the Channel Management REST API.
Resolution Steps
1. Set Up Webhook Listener
Listen to events using the Agora webhook feature. This allows you to detect when the channel needs to be closed.
2. Implement Channel Closure Functionality
Use the Channel Management API to initiate the channel closure. Follow these steps:
- Access the Channel Management REST API.
- Use the following endpoint to close the channel:
POST /v1/channels/{channel_name}/close
Replace `{channel_name}` with the actual name of the channel you want to close.
3. Confirm Channel Closure
After sending the closure request, confirm that the channel has been closed successfully. You can do this by checking the status of the channel using the following endpoint:
GET /v1/channels/{channel_name}/status