QoD notifications and life cycle

QoD session life cycleheader link

When you first create a session, its status will become REQUESTED until the quality of service requested through the desired QoS profiles is provided by the network. If the allocation of resources by the network is successful, the QoD status will change to AVAILABLE, and the QoD session will be ready to use for the amount of time specified during creation, or until it is deleted or interrupted. When the QoD session duration expires or if the session is deleted, the QoD status will become UNAVAILABLE. The reason for the QoD session termination will also be specified in the notification callback, through the statusInfo string.

QoD statusesheader link

QoD session statusDescription
REQUESTEDA QoD session was requested and it is waiting to be provided by the network.
AVAILABLEResource allocation in the network was successful and the QoD session is active.
UNAVAILABLEThe QoD session was terminated because its duration expired, or it was deleted.
QoD session status informationDescription
DURATION_EXPIREDThe QoD session duration expired and the session was automatically terminated.
DELETE_REQUESTEDThe QoD session was deleted by the user.
NETWORK_TERMINATEDThe QoD session was terminated due to the network before the duration expired.

Session notificationsheader link

You can optionally configure a notification (webhook) URL to receive QoD session updates. This way, you or your client can be notified of important session events, such as creation, deletion, etc. Learn more about the notification URL/auth token and how to create an HTTP server with a POST endpoint for session notifications.

With a notification URL, you can also keep track of different QoD session statuses.

Creating a session with a notification URLheader link

Create a QoD session providing parameters for your API endpoint and password (authorization token) to identify the sender of the notifications.

import network_as_code as nac

from network_as_code.models.device import DeviceIpv4Addr

# Begin by creating a client for Network as Code:
client = nac.NetworkAsCodeClient(
    token="<your-application-key-here>",
)

# Then, create a device object.
# Remember to assign its phone number and current IP address(es):
my_device = client.devices.get(
    ipv4_address=DeviceIpv4Addr(
        public_address="233.252.0.2",
        private_address="192.0.2.25",
        public_port=80
    ),
    ipv6_address="2001:db8:1234:5678:9abc:def0:fedc:ba98",
    # The phone number does not accept spaces or parentheses
    phone_number="+36721601234567"
)

# Create a QoD session with QOS_L (large bandwidth)
# and get notifications
my_session = my_device.create_qod_session(
    service_ipv4="233.252.0.2",
    service_ipv6="2001:db8:1234:5678:9abc:def0:fedc:ba98",
    profile="QOS_L",
    duration=3600,
    # Use HTTPS to send notifications
    notification_url="https://notify.me/here",
    notification_auth_token="replace-with-your-auth-token"
)

# Show a list of all the QoD sessions associated with a device
print(my_device.sessions())

Setting up a web serverheader link

The code snippet below will set up an HTTP server with a POST endpoint, so you can get session-event updates:

import time

from fastapi import FastAPI, Header

from pydantic import BaseModel

from typing_extensions import Annotated
from typing import Union

# Our web server for receiving QoD notifications
app = FastAPI()

class EventDetail(BaseModel):
    sessionId: str
    qosStatus: str
    statusInfo: str

class Event(BaseModel):
    eventType: str
    eventTime: str
    eventDetail: EventDetail

class Notification(BaseModel):
    id: str
    source: str
    type: str
    specversion: str
    datacontenttype: str
    time: str
    event: Event
    data: EventDetail

@app.post("/qod")
def receive_notification(
    notification: Notification,
    authorization: Annotated[Union[str, None], Header]
):
    if authorization == "Bearer my-token":
        # We can now react to the notifications
        # based on the Notification object
        print(notification)

Session notification parametersheader link

The Session object is created with a specific duration, representing a new session for the device. The following parameters can be passed to this method:

ParametersTypeDescriptionMandatory or Optional
profilestringThe QoS profile that indicates the connection type to be prioritized between two points.Mandatory
service_ipv4stringThe service identified by the application IPv4 address.Mandatory (if no IPv6)
service_ipv6stringThe service identified by the application IPv6 address.Mandatory (if no IPv4)
durationintegerThe length of the QoD session in seconds (maximum: 86400 seconds = 24 hours).Mandatory
notification_urlstringThe recipient's HTTP endpoint, which is a web server configured to receive POST requests.Mandatory
notification_auth_tokenstringThe password used to identify the sender of the notification.Optional

Quality-of-service-on-Demand (QoD) notification schemaheader link

Here you will find the JSON schema for QoD notifications, which purpose is to monitor changes made to sessionId, qosStatus and statusInfo. Underneath the JSON schema, there is a table with further information on the specific keyword values.

Remember that the string values represented below are just examples that can be used. So, they should contain your real QoD session values.

{
   "id":"string",
   "source":"string",
   "type":"org.camaraproject.qod.v0.qos-status-changed",
   "specversion":"1.0",
   "datacontenttype":"application/json",
   "time":"2024-04-30T13:05:29.189Z",
   "data":{
      "sessionId":"string",
      "qosStatus":"UNAVAILABLE",
      "statusInfo":"DELETE_REQUESTED"
   }
}
QoD-keyword valuesTypeDescription
idstringThe event subscription identifier.
sourcestringIdentifies the source where the event happened. It contains the Network as Code API implementation and subscription ID.
typestringValue returned by the API with different statuses.
specversionstringRepresents the specification version.
datacontenttypestringIt indicates the media type for the event payload encoding. It must be "application/json" in the context of CAMARA APIs
timestringTime when the event occurred. Date and time are specified in ISO 8601 format, e.g.: "2023-08-20T21:01:02.345Z".
sessionIdstringThe session resource ID. It can be a session name or number, which is attributed when you create a session.
qosStatusstringThe QoD session status, whether it is REQUESTED, AVAILABLE, UNAVAILABLE.
statusInfostringProvides information on the QoD session expiration or termination. The accepted values are: DURATION_EXPIRED, DELETE_REQUESTED, NETWORK_TERMINATED or it can also be empty (null).

Simulated QoD notification scenariosheader link

The Network as Code simulators have been configured to provide specific QoD notifications for specific simulated devices based on their device identifier. This will be helpful in testing your code against the different responses, including possible errors, by simply substituting the device identifier in your code.

The device identifiers and their responses can be found in the following table:

Device identifier typeDevice identifierHTTP status codeHTTP status code descriptionResponse description
Network Access Identifier[email protected]200Success"QOS_STATUS_CHANGED notification with status UNAVAILABLE, No status information"
Network Access Identifier[email protected]200Success"QOS_STATUS_CHANGED notification with status UNAVAILABLE, Status info = NETWORK_TERMINATED"
Network Access Identifier[email protected]200Success"QOS_STATUS_CHANGED notification with status AVAILABLE, No status information"

Last updated November 05, 2025