Bird

Verify an email address with Python

Send a verification code to your own email address, enter it in the terminal and inspect the check result.

1. Prepare the workspace

Create a Bird API key and use an email address you control. Email verification uses the shared Bird Verify sender, so this first test does not require your own sending domain. The first-verification guide covers account setup and channel choices.

2. Install and configure

Use Python 3.10 or later. In a new project directory:
Code example
python3 -m venv .venv
source .venv/bin/activate
python -m pip install messagebird-sdk
export BIRD_API_KEY="YOUR_API_KEY"
export BIRD_TEST_EMAIL="YOUR_EMAIL_ADDRESS"
Replace the environment values with your own workspace credentials and test destination. The SDK selects the API region from the key. Run this example on your server or development machine.

3. Run the example

Save as verify.py:
Code example
import os

from bird import Bird

with Bird(api_key=os.environ["BIRD_API_KEY"]) as client:
    email = os.environ["BIRD_TEST_EMAIL"]
    verification = client.verify.verifications.create(to={"email": email})
    print(verification.id, verification.status)
    code = input("Enter the code from your email: ").strip()
    result = client.verify.verifications.check(to={"email": email}, code=code)
    print("Verified:", result.success)
Code example
python verify.py

4. Inspect the outcome

The first call prints the verification ID and status. After you enter the received code, the check prints whether it succeeded. A delivered code alone does not verify the address; use the check result.
In an application, bind the intended destination and customer action to the server session. The SDK check accepts the destination and code, so do not let an untrusted browser substitute a different destination when checking. Follow signup and recovery for that complete application flow.

Next steps