Skip to content
The Things Stack documentation home
Getting Started Concepts Cloud Enterprise Integrations API Hardware
Getting Started Concepts
Cloud Enterprise
Integrations API Hardware
Get The Things Stack

    Recent searches

      Popular pages

      • Getting Started
      • Adding Gateways
      • Adding Devices
      • Payload Formatters
      • Webhooks
      • Authentication

      No results for “”.

      • Check the spelling, or try fewer or more general words.
      • Ask the community on The Things Network Forum
      • Contact support
      ↑↓ to navigate ↵ to open Esc to close

      Integrations

      • Overview
      • Adding Applications
      • Data Formats
      • Payload Formatters
      • Webhooks
      • Storage Integration
      • Integrate with popular IoT platforms
      • Other integrations
      • Application Packages
        • Managing Application Packages using the CLI
        • Managing Application Packages using the API
        • LoRa Cloud Modem and Geolocation Services
      • Examples

      Managing Application Packages using the CLI

      Updated 20 January 2025 Edit on GitHub
      Copy page
      • View as MarkdownThis page as plain text
      • Open in ChatGPTAsk questions about this page
      • Open in ClaudeAsk questions about this page

      To interact with the available application packages, you can use The Things Stack CLI.

      Note:

      This section considers default associations only. However, all of the commands for managing associations and default associations are symmetric, and may be switched one with another. Check ttn-lw-cli applications packages for more info.

      Command-line interface only

      The instructions below use the command-line interface (CLI).

      Learn how to install the CLI

      We first define some user parameters used below:

      APP_ID="app1"
      DEVICE_ID="dev1"
      

      Make sure to modify these according to your setup.

      Listing the Available Packages

      The application packages available for a given device dev1 of application app1 can be obtained as follows:

      ttn-lw-cli applications packages list $APP_ID $DEVICE_ID
      

      This gives the result in the JSON format:

      {
        "packages": [
          {
            "name": "test-package",
            "default_f_port": 20
          }
        ]
      }
      

      Creating and Updating an Association

      In order to associate a given application package to a FPort of an application, you can use the default-associations set command:

      F_PORT=25
      APP_PACKAGE_NAME="test-package"
      ttn-lw-cli applications packages default-associations set $APP_ID $F_PORT --package-name $APP_PACKAGE_NAME
      

      This will associate FPort 25 of application app1 with the application package test-package, as shown by the command output:

      {
        "ids": {
          "application_ids": {
            "application_id": "app1"
          },
          "f_port": 25
        },
        "created_at": "2019-12-18T21:28:12.775879582Z",
        "updated_at": "2019-12-18T21:29:08.445380588Z",
        "package_name": "test-package"
      }
      

      Some application packages are stateful, and as such their state can be updated using the data-* parameters:

      # Create a JSON formatted file containing package data
      echo '{ "api_key": "AQEA8+q0v..." }' > package-data.json
      # Update the association with the new package data
      ttn-lw-cli applications packages default-associations set $APP_ID $F_PORT --data-local-file package-data.json
      

      This will update the association to use the given api_key:

      {
        "ids": {
          "application_ids": {
            "application_id": "app1"
          },
          "f_port": 25
        },
        "created_at": "2019-12-18T21:28:12.775879582Z",
        "updated_at": "2019-12-18T21:37:16.470742803Z",
        "package_name": "test-package",
        "data": {
          "api_key": "AQEA8+q0v..."
        }
      }
      

      Listing the Associations

      The package associations of a given device can be listed using the default-associations list command:

      ttn-lw-cli applications packages default-associations list $APP_ID
      
      Output
      {
        "associations": [
          {
            "ids": {
              "application_ids": {
                "application_id": "app1"
              },
              "f_port": 25
            },
            "created_at": "2019-12-18T21:28:12.775879582Z",
            "updated_at": "2019-12-18T21:29:08.445380588Z",
            "package_name": "test-package"
          }
        ]
      }
      

      Retrieving an Association

      The associations can be retrieved using the default-associations get command:

      ttn-lw-cli applications packages default-associations get $APP_ID $F_PORT --data
      
      Output
      {
        "ids": {
          "application_ids": {
            "application_id": "app1"
          },
          "f_port": 25
        },
        "created_at": "2019-12-18T21:28:12.775879582Z",
        "updated_at": "2019-12-18T21:37:16.470742803Z",
        "package_name": "test-package",
        "data": {
          "api_key": "AQEA8+q0v..."
        }
      }
      

      Deleting an Association

      The associations can be deleted using the default-associations delete command:

      ttn-lw-cli applications packages associations delete $APP_ID $F_PORT
      
      ← Application Packages Managing Application Packages using the API →

      On this page

      • Listing the Available Packages
      • Creating and Updating an Association
      • Listing the Associations
      • Retrieving an Association
      • Deleting an Association

      Sections

      Getting Started

      Concepts

      Cloud

      Enterprise

      Integrations

      API

      Hardware

      Sitemap

      View our Sitemap

      Contributing

      GitHub

      About Us

      The Things Industries

      Privacy Policy

      Cookie settings

      Cookie Settings

      We use cookies to enhance your experience, analyze site traffic and deliver personalized content. Read our Privacy Policy.

      Cookie categories