Skip to main content
This example uses Python’s standard library. It checks the operations advertised by the session, gives creation a stable idempotency key, and requests cleanup in finally. The client wait budget is independent of the phone’s selected duration. If that budget is exceeded, the example requests closure instead of leaving the phone running.
This is a real API example. Running it with a valid account key creates a metered session. The published example contains no credentials.
Copy the Python code below into phone_example.py, then run:
If closure returns cleanup_pending: true, poll the create receipt to confirm cleanup_complete: true. A failed receipt lookup is not proof that no phone was created. Preserve the request key and use the retry and recovery flow. The finite session deadline still applies if your process exits or loses its connection. In a production integration, store request keys durably and recover unfinished requests when your process restarts.