Savaraflow
Open console
← Framework guides

Python

Send a test request from Django.

Use a server-side HTTP request from a Django service or background task.

Django

Connect your application

  1. Set the server environment

    Install requests in your Django environment. Set SAVARA_HOST and SAVARA_TEST_KEY on the server.

  2. Call after your application event

    Invoke the helper from a protected service or background task. Use a stable order or event identifier and avoid blocking a database transaction on the request.

  3. Keep the response

    Record the returned status and message ID. Reuse the same idempotency key and payload for retries of that event.

Read the Django documentation
Python example
import os
import requests

def simulate_pickup(order_id):
    response = requests.post(
        os.environ["SAVARA_HOST"] + "/api/v1/messages",
        headers={
            "Authorization": "Bearer " + os.environ["SAVARA_TEST_KEY"],
            "Idempotency-Key": f"pickup-{order_id}",
        },
        json={
            "channel": "SMS",
            "to": "+256770123456",
            "body": "Your order is ready to collect.",
            "scenario": "delivered",
        },
        timeout=10,
    )
    return response.status_code, response.json()

Before sending live

Use your own SavaraFlow deployment origin without a trailing slash and a scoped key from that deployment. Switch to a live key only after enabling the route and funding the workspace. Remove the sandbox scenario, use a recipient who agreed to receive the message, and include consent: true in the request. Keep API keys in server-side configuration.

Read the complete sending workflow

Get a quote before your first live send.

Use the live quote endpoint to review the destination cost and available balance.

Read about quotes

Choose what SavaraFlow can save on this device. You can change your choice here at any time.