https://retellai.com/?utm_source=discord&utm_medium=seo logo
how do you use the python sdk to check that a call...
# ❓・ai-evy-support
p
@AI Evy how do you use the python sdk to check that a call was successful?
a
Thanks for tagging me @PixelDrift42. I'll look through relevant sources and get back to you shortly.
### Answer To check if a call was successful using the Python SDK, you can use the
client.call.retrieve()
method to get the call details and check its status [(1) ]() .
Copy code
python
from retell import Retell

client = Retell(
    api_key="YOUR_RETELL_API_KEY",
)

# Retrieve call details by call_id
call_response = client.call.retrieve(call_id)
print(call_response)
[(2) ]() , [(1) ]() The
retrieve
method returns a
CallResponse
object that contains the call's status and other details . You can examine the response to determine if the call was successful based on the call's status information. Additionally, you can use webhooks to receive real-time notifications about call events. You can verify webhook authenticity using the provided verification method [(3) ]() :
Copy code
python
from retell import Retell
import express
from express import Request, Response

app = express()
app.use(express.json() )

app.post("/webhook", (req: Request, res: Response) => {
    if (
        !Retell.verify(
            JSON.stringify(req.body) ,
            process.env.RETELL_API_KEY,
            req.headers["x-retell-signature"] as string,
        )
    ) :
        console.error("Invalid signature")
        return
    
    const {event, call} = req.body
    # process the webhook
    # Acknowledge the receipt of the event
    res.status(204) .send()
})
​ To learn more, see the sources I considered: [[1] RetellAI/retell-python-sdk/api.md](https://github.com/RetellAI/retell-python-sdk/blob/main/api.md) [[2] Retell Python API library](https://github.com/RetellAI/retell-python-sdk/blob/main/README.md) [[3] Secure the webhook](https://docs.retellai.com/features/secure-webhook) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.