Skip to main content

Using the nRF Cloud Message Routing Service

This guide explains how to use the nRF Cloud Message Routing Service through the nRF Cloud portal and APIs.

Prerequisites​

  • Create an nRF Cloud account.
  • Have an Owner or Admin role in your team.
  • Create a destination with your web service URL. For more information and an example, see Receiving messages from nRF Cloud.
  • Verify your destination. Before your server can start receiving messages from your team, it must be verified. See Verification for details.
  • Add one or more devices to your team.

Using the nRF Cloud portal​

This section explains message routing operations available in the nRF Cloud portal.

Managing destinations​

You can create, edit, delete, test, enable or disable, and verify destinations in the nRF Cloud portal.

After you have an HTTP server that can receive requests from nRF Cloud, finish setting up message routing by creating a new destination:

  1. Log in to the nRF Cloud portal.

  2. Select Device Management from the left sidebar.

    A panel opens to the right.

  3. Select Message Routing Service.

  4. Click the Add Destination button.

    A pop-up opens.

  5. Enter the name of the destination and URL.

  6. (Optional) Enter additional information:

    • Contact email address: You need this if you want to receive email alerts.
    • Filter Categories: Configure message filtering to control which types of messages are forwarded to your destination. See Message Filtering for details.
    • Token: Provide this if your own service requires it, or as a convenient way to identify messages from nRF Cloud. Adds x-api-key to requests with your token value.
    • Secret: Used for identity verification. Adds x-nrfcloud-signature to requests.
    • Verify Server Socket Layer toggle: Leave this as-is, unless you want to disable SSL.
    • Is Enabled toggle: Leave this on if you want the destination to be enabled on creation.
  7. Click the Create Destination button.

Using the nRF Cloud APIs​

This section explains message routing operations through the nRF Cloud APIs.

Managing destinations​

See the Message Routing Service API documentation for more information on specific endpoint requirements.

Call the CreateDestination endpoint to create a new destination.

Example request body:

{
"name": "Test Webhook",
"config": {
"type": "http",
"url": "https://example.com/webhook-endpoint",
"verifySsl": true
},
"isEnabled": true
}

The server responds with HTTP 201 and information about the newly created destination:

{
"id": "5b5d8b40-e251-41bc-a45c-f932c603f121",
"createdAt": "2024-08-07T03:38:15.040913Z",
"name": "Test Webhook",
"config": {
"type": "http",
"url": "https://example.com/webhook-endpoint",
"verifySsl": true
},
"isEnabled": true,
"errors": []
}

Message filtering​

You can optionally configure message filtering for your destinations to control which types of messages are forwarded to your destination.

Pre-defined filtering categories​

The following pre-defined filtering categories are available:

  • location: Location-related messages (AGNSS, AGPS, PGPS, Ground fix, cell positioning, Wi-Fi positioning)
  • shadow: Device shadow messages (shadow updates, state changes)
  • fota: Firmware over-the-air update messages
  • device_messages: Device-to-Cloud messages (including binary and raw data)
  • cloud_messages: Cloud-to-Device messages

Configuring message filters​

You can configure message filtering through both the nRF Cloud portal and the APIs.

Through the nRF Cloud portal​

When creating or editing a destination in the portal:

  1. In the destination configuration form, locate the Filter Categories field.
  2. Select the categories you want to forward to this destination.
  3. Only messages matching the selected categories will be sent to your endpoint.
  4. If no filters are specified, all message types will be forwarded (default behavior).

Through the APIs​

When using the CreateDestination or UpdateDestination endpoint, include a filter object in your destination configuration:

{
"name": "My Filtered Destination",
"config": {
"type": "http",
"url": "https://example.com/webhook",
"verifySsl": true
},
"filter": {
"categories": ["location", "shadow"]
},
"isEnabled": true
}

Examples​

  • To receive only location and shadow messages: ["location", "shadow"]
  • To receive only device messages: ["device_messages"]
  • To receive all messages (default), clear the filter object.