Roaming notifications

The roaming feature allows querying and reporting information on device roaming status, so you can monitor when it's roaming or not.

Getting roaming notifications

The code snippet below will set up an HTTP server with a POST endpoint. This will allow receiving device roaming status updates. For example, you can set a notification for whenever a device is roaming or not.

Roaming notifications handler

# status_handler.py
 
# run with: uvicorn status_handler:app
 
from fastapi import FastAPI
from pydantic import BaseModel
 
app = FastAPI()
 
 
class RoamingEventDetail(BaseModel):
    roaming: bool | None
    countryCode: int | None
    countryName: List[String] | None
 
class Event(BaseModel):
    eventType: str
    eventTime: str
    eventDetail: RoamingEventDetail
 
class Notification(BaseModel):
    eventSubscriptionId: str
    event: Event
 
@app.post("/notifications")
def receive_notification(notification: Notification):
    if notification.event.eventDetail.roaming:
        print("Device is roaming")
    else:
        print("Device is not roaming")

What is a notification URL?

Learn more about the notification URL/auth token and how to create a web server for them.

Note that the snippet above assumes you have already created Device Status subscription before, which you can learn how to do here. And that you have also created a Network-as-Code client and identified your mobile network device previously.

Last updated on December 04, 2023

On this page
Getting roaming notificationsRoaming notifications handlerWhat is a notification URL?