Python
Send a test request from Django.
Use a server-side HTTP request from a Django service or background task.
Connect your application
Set the server environment
Install requests in your Django environment. Set SAVARA_HOST and SAVARA_TEST_KEY on the server.
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.
Keep the response
Record the returned status and message ID. Reuse the same idempotency key and payload for retries of that event.
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.
Get a quote before your first live send.
Use the live quote endpoint to review the destination cost and available balance.