Deploy Update

Deploy update

POST https://api.upswift.io/v1/deploy_update

Using this call, you can deploy update flows on your devices. This is useful for CI/CD integrations and when you would like to deploy updates on your device fleet automatically.

Request Body

NameTypeDescription

metadata

object

A JSON object with metadata for the deployment. The object can have multiple keys: 1. "comment": "<comment>" Set the <comment> as the comment for that deployment. The value of this key is a String. The comment key is an optional key. 2. "app": {"name": "<app_name>", "version": "<app_version>"} Set the <app_name> as the name of the app you created on Upswift dashboard. Set the <app_version> as the version for this app. The app key is an optional key. Devices that will deploy the update successfully, their app version will change to the app_version you set here. The metadata object must exist but can be empty.

user_token

string

This is your account token. Can be found under the Settings category on Upswift dashboard.

flow_id

string

This is the id of the update flow you created on Upswift dashboard. You can find it at the Updates category under the Update Flows tab.

devices_filter

object

A JSON object with the filter you would like to apply on your devices fleet. This filter will be applied and the result will be the devices that receive this update. The object has multiple keys: 1. "project": {"name": "<project_name>"} set the <project_name> as your project name from Upswift dashboard. The project key must exist and the value of it is a JSON with the key name. 2. "groups": [{"name": "<group_name>"}] set the <group_name> as a group name from Upswift dashboard. The groups key is a must key but the value of it can be an empty list. The value of it is a list of JSON objects each has a key called name. If multiple groups exist, all devices within those groups will receive the update. 3. "filters": [{"type": "<filter_type>", "operand": "<operand>", "value": "<value>"}] the filters key lets you add custom filters. Set the <type> key as the type of the filter (possible types can be found under this form). Set the <operand> key as the operand for this filter (possible operands can be found under this form). Set the <value> key as the value for this filter (the value depends on the type of the filter, examples can be found under this form). You can set multiple filters, if you do so, they will all be applied on top of each other (examples can be found under this form). The filters key is a must key but the value of it can be an empty list.

{"message": "Success"}

Possible types and values:

  • devices_filter object:

    • filters key:

      • Possible values for the type key:

        • specific_device - Set this value if you want to filter one specific device. The value of the value key of this type is the ID of the device you want to filter (you can obtain the id on Upswift dashboard). The possible operand key values for this type are: is, is_not

        • tag - Set this value if you want to filter devices by a tag. The value of the value key of this type is the name of the tag you want to filter (you can obtain the tag name on Upswift dashboard). The possible operand key values for this type are: is, is_not

        • app - Set this value if you want to filter devices by the apps that are set to them. The value of the value key of this type is the app name. The possible operand key values for this type are: is, is_not.

        • device_state - Set this value if you want to filter devices by their state. The possible values of the value key of this type are: online, offline. The possible operand key value of this type is: is

        • update_status - Set this value if you want to filter devices by their last update status. The possible values of the value key of this type are: pending, in_progress, success, failed, aborted. The possible operand key value of this type is: is, is_not

All values must be of type: String.

Full payload example:

{
    "user_token": "<user token>",
    "flow_id": "73a7-1ft8",
    "devices_filter": {"project": {"name": "Demo"},
                       "groups": [{"name": "TestGroup1"}, {"name": "TestGroup2"}],
                       "filters": [{"type": "specific_device",
                                    "operand": "is",
                                    "value": "d-4ec7-1be9"}]},
    "metadata": {"comment": "test webhook 1",
                 "app": {"name": "default_app", "version": "v1.1"}}
}

Code Example

import json
import requests

#Upswift tokens
user_token = "<user token>"

json_content = {'user_token': user_token,
                'metadata': {'comment': 'test webhook 1',
                             'app': {'name': 'default_app', 'version': 'v1.1'}},
                'flow_id': '73a7-1ft8',
                'devices_filter': {'project': {'name': 'Demo'},
                                   'groups': [{'name': 'TestGroup1'}, {'name': 'TestGroup2'}],
                                   'filters': [{'type': 'specific_device',
                                                'operand': 'is',
                                                'value': 'd-4ec7-1be9'}]}
                }
                                
                             
                
call_request = requests.post("https://api.upswift.io/v1/deploy_update", json=json_content)
call_response = json.loads(call_request.text)

if call_request.status_code != 200:
    if call_request.status_code == 429:
        error = "API limit reached"
    else:
        error = call_response["error_message"]
    print(error)
else:
    response_message = call_response["message"]

Last updated