### Get Instructions for Device Type Installation (Node.js) Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Retrieves step-by-step instructions for installing a host OS onto a given device type. This method accepts either the device type slug or a contract object. It returns a Promise that resolves with an array of instruction strings. ```javascript balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { for (let instruction of instructions.values()) { console.log(instruction); } // Insert the sdcard to the host machine. // Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher. // Wait for writing of BalenaOS to complete. // Remove the sdcard from the host machine. // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W). // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device. }); ``` -------------------------------- ### Get Installation Method for Device Type (Node.js) Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Fetches the supported installation method for a specific device type identified by its slug. This can indicate how BalenaOS is typically installed on that device. It returns a Promise that resolves with the installation method as a string. ```javascript balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { console.log(method); // externalBoot }); ``` -------------------------------- ### Install Balena SDK with npm Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Installs the balena-sdk package as a dependency for your Node.js project using npm. ```bash $ npm install --save balena-sdk ``` -------------------------------- ### Create Billing Setup Intent Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Creates a Stripe setup intent, which is necessary for setting up billing information. It requires an object containing setup intent parameters, including the organization's handle or ID and optionally a reCAPTCHA response. This method is exclusive to Balena.io. Returns a promise that resolves with a partial Stripe setup intent object. ```javascript balena.models.billing.createSetupIntent(orgId).then(function(setupIntent) { console.log(setupIntent); }); ``` -------------------------------- ### Get Balena SDK Instance with Options Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Demonstrates how to get an instance of the Balena SDK, optionally providing configuration options like apiUrl and dataDirectory. Supports both ES6 imports and Node.js require. ```javascript // with es6 imports import { getSdk } from 'balena-sdk'; // or with node require const { getSdk } = require('balena-sdk'); const balena = getSdk({ apiUrl: "https://api.balena-cloud.com/", dataDirectory: "/opt/local/balena" }); ``` -------------------------------- ### Start OS Update on Device (JavaScript) Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Initiates an operating system update on one or more devices. It requires the device UUID(s) and the target OS version, which must be semver-compatible, unpublished, and greater than the currently installed version. An optional options object can specify if the update should run in detached mode (defaulting to true). The method returns a Promise that resolves with the action status. ```javascript balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) { console.log(result.status); }); ``` -------------------------------- ### Get Two-Factor Setup Key - Node.js Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Retrieves the setup key required for configuring a two-factor authentication authenticator app. This key is usually presented as a QR code or a text string. ```javascript balena.auth.twoFactor.getSetupKey() ``` -------------------------------- ### Get Two-Factor Authentication Setup Key (Node.js) Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Retrieves the setup key required for enabling two-factor authentication (2FA) for an account. This method returns a Promise that resolves to a string representing the setup key. This key is typically used with authenticator apps. ```javascript const setupKey = balena.auth.twoFactor.getSetupKey(); console.log(setupKey); ``` -------------------------------- ### Device Type API Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index This section details the API endpoints for retrieving and managing device type information. These methods allow you to fetch all supported device types, get specific device types by their slug or name, and retrieve associated metadata like display names, slugs, contracts, installation instructions, and installation methods. ```APIDOC ## GET /deviceType.getAllSupported ### Description Retrieves a list of all device types supported by the Balena platform. ### Method GET ### Endpoint /deviceType.getAllSupported ### Parameters #### Query Parameters - **options** (Object) - Optional - Extra Pine options to use for the query. ### Request Example ```javascript balena.models.deviceType.getAllSupported().then(function(deviceTypes) { console.log(deviceTypes); }); ``` ### Response #### Success Response (200) - **deviceTypes** (Object[]) - An array of supported device type objects. #### Response Example ```json [ { "id": 1, "slug": "raspberry-pi", "name": "Raspberry Pi", "is_virtual": false, "data": { "is_hidden": false } } ] ``` ## GET /deviceType.getBySlugOrName ### Description Retrieves a specific device type identified by its slug or name. ### Method GET ### Endpoint /deviceType.getBySlugOrName ### Parameters #### Query Parameters - **slugOrName** (String) - Required - The slug or name of the device type to retrieve. ### Request Example ```javascript balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) { console.log(deviceType); }); ``` ### Response #### Success Response (200) - **deviceType** (Object) - The device type object matching the provided slug or name. #### Response Example ```json { "id": 1, "slug": "raspberry-pi", "name": "Raspberry Pi", "is_virtual": false, "data": { "is_hidden": false } } ``` ## GET /deviceType.getName ### Description Retrieves the human-readable display name for a given device type slug. ### Method GET ### Endpoint /deviceType.getName ### Parameters #### Query Parameters - **deviceTypeSlug** (String) - Required - The slug of the device type. ### Request Example ```javascript balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) { console.log(deviceTypeName); }); ``` ### Response #### Success Response (200) - **deviceTypeName** (String) - The display name of the device type. #### Response Example ```json "Raspberry Pi" ``` ## GET /deviceType.getSlugByName ### Description Retrieves the unique slug for a given device type display name. ### Method GET ### Endpoint /deviceType.getSlugByName ### Parameters #### Query Parameters - **deviceTypeName** (String) - Required - The display name of the device type. ### Request Example ```javascript balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) { console.log(deviceTypeSlug); }); ``` ### Response #### Success Response (200) - **deviceTypeSlug** (String) - The slug of the device type. #### Response Example ```json "raspberry-pi" ``` ## GET /deviceType.getInterpolatedPartials ### Description Retrieves a device type contract with its partial templates resolved and interpolated. ### Method GET ### Endpoint /deviceType.getInterpolatedPartials ### Parameters #### Query Parameters - **deviceTypeSlug** (String) - Required - The slug of the device type. ### Request Example ```javascript balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) { for (const partial in contract.partials) { console.log(`${partial}: ${contract.partials[partial]}`); } }); ``` ### Response #### Success Response (200) - **contract** (Object) - The device type contract object with interpolated partials. #### Response Example ```json { "name": "raspberry-pi", "slug": "raspberry-pi", "partials": { "bootDevice": ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"] } } ``` ## GET /deviceType.getInstructions ### Description Retrieves step-by-step instructions for installing the host OS on a specified device type. ### Method GET ### Endpoint /deviceType.getInstructions ### Parameters #### Query Parameters - **deviceTypeSlugOrContract** (String | Object) - Required - The slug of the device type or the device type contract object. ### Request Example ```javascript balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) { for (let instruction of instructions.values()) { console.log(instruction); } }); ``` ### Response #### Success Response (200) - **instructions** (Object | String[]) - An object or array of strings representing the installation instructions. #### Response Example ```json [ "Insert the sdcard to the host machine.", "Write the BalenaOS file you downloaded to the sdcard. We recommend using Etcher.", "Wait for writing of BalenaOS to complete.", "Remove the sdcard from the host machine.", "Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W).", "Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device." ] ``` ## GET /deviceType.getInstallMethod ### Description Retrieves the installation method supported for a given device type. ### Method GET ### Endpoint /deviceType.getInstallMethod ### Parameters #### Query Parameters - **deviceTypeSlug** (String) - Required - The slug of the device type. ### Request Example ```javascript balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) { console.log(method); }); ``` ### Response #### Success Response (200) - **method** (String) - The installation method string (e.g., 'externalBoot'). #### Response Example ```json "externalBoot" ``` ``` -------------------------------- ### Two-Factor Authentication Management Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Manage two-factor authentication settings, including verification, setup, enabling, challenging, and disabling. ```APIDOC ## POST /auth/twoFactor/verify ### Description Verifies the two-factor authentication code. Note: This method does not automatically update the token. Use `challenge` when possible, as it handles token updates. ### Method POST ### Endpoint /auth/twoFactor/verify ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **code** (String) - Required - The two-factor authentication code. ### Request Example ```javascript const token = balena.auth.twoFactor.verify('1234'); balena.auth.loginWithToken(token); ``` ### Response #### Success Response (200) - **sessionToken** (String) - The session token upon successful verification. ``` ```APIDOC ## GET /auth/twoFactor/getSetupKey ### Description Retrieves a setup key required for enabling two-factor authentication. ### Method GET ### Endpoint /auth/twoFactor/getSetupKey ### Parameters None ### Request Example ```javascript const setupKey = balena.auth.twoFactor.getSetupKey(); console.log(setupKey); ``` ### Response #### Success Response (200) - **setupKey** (String) - The setup key for enabling 2FA. ``` ```APIDOC ## POST /auth/twoFactor/enable ### Description Enables two-factor authentication for the account. ### Method POST ### Endpoint /auth/twoFactor/enable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **code** (String) - Required - The code provided during the 2FA setup process. ### Request Example ```javascript const token = balena.auth.twoFactor.enable('1234'); balena.auth.loginWithToken(token); ``` ### Response #### Success Response (200) - **sessionToken** (String) - The session token upon successful enablement. ``` ```APIDOC ## POST /auth/twoFactor/challenge ### Description Challenges two-factor authentication and completes the login process. It is recommended to use the `login` method when possible, as it handles token persistence. ### Method POST ### Endpoint /auth/twoFactor/challenge ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **code** (String) - Required - The two-factor authentication code. ### Request Example ```javascript balena.auth.twoFactor.challenge('1234'); ``` ### Response #### Success Response (200) (No specific return value documented, implies completion of challenge. ``` ```APIDOC ## POST /auth/twoFactor/disable ### Description Disables two-factor authentication for the account. ### Method POST ### Endpoint /auth/twoFactor/disable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **password** (String) - Required - The user's current password. ### Request Example ```javascript const token = balena.auth.twoFactor.disable('1234'); balena.auth.loginWithToken(token); ``` ### Response #### Success Response (200) - **sessionToken** (String) - The session token upon successful disabling. ``` -------------------------------- ### Device Type API Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Provides methods for retrieving information about supported device types, including their capabilities and installation methods. ```APIDOC ## Device Type API ### Description Methods for retrieving information about supported device types, including capabilities and installation methods. ### Methods - **.get(idOrSlug, [options])** - **Description**: Gets a specific device type by its ID or slug. - **Returns**: `Promise` - **.getAll([options])** - **Description**: Gets all supported device types. - **Returns**: `Promise` - **.getAllSupported([options])** - **Description**: Gets all supported device types. - **Returns**: `Promise` - **.getBySlugOrName(slugOrName)** - **Description**: Gets a device type by its slug or name. - **Returns**: `Promise` - **.getName(deviceTypeSlug)** - **Description**: Gets the name of a device type from its slug. - **Returns**: `Promise` - **.getSlugByName(deviceTypeName)** - **Description**: Gets the slug of a device type from its name. - **Returns**: `Promise` - **.getInterpolatedPartials(deviceTypeSlug)** - **Description**: Gets interpolated partials for a device type. - **Returns**: `Promise` - **.getInstructions(deviceTypeSlugOrContract)** - **Description**: Gets installation instructions for a device type. - **Returns**: `Promise` - **.getInstallMethod(deviceTypeSlug)** - **Description**: Gets the installation method for a device type. - **Returns**: `Promise` ``` -------------------------------- ### Get All Configuration Settings (Node.js) Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Retrieves all available configuration settings for the Balena environment. This method returns a Promise that resolves to an object containing the configuration data. ```javascript balena.models.config.getAll().then(function(config) { console.log(config); }); ``` -------------------------------- ### GET /settings Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Retrieves Balena settings, either a specific setting by key or all available settings. This functionality is only implemented in the Node.js environment. ```APIDOC ## GET /settings ### Description Provides access to Balena settings. You can retrieve a specific setting by its key or fetch all settings as an object. Note that these methods are exclusively available in the Node.js environment. ### Method GET ### Endpoint `/settings` ### Parameters #### Query Parameters - **key** (String) - Optional - The key of the setting to retrieve. If omitted, all settings are returned. ### Request Example ```javascript // Get a specific setting balena.settings.get('apiUrl').then(function(apiUrl) { console.log(apiUrl); }); // Get all settings balena.settings.getAll().then(function(settings) { console.log(settings); }); ``` ### Response #### Success Response (200) - **settings value** (any) - If a key is provided, returns the value of that specific setting. - **settings object** (Object) - If no key is provided, returns an object containing all settings. ``` -------------------------------- ### Authentication Methods Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Provides methods for authenticating with the Balena API, including getting current user info, authenticating with credentials, and logging in via different methods. ```APIDOC ## GET /auth/whoami ### Description Retrieves information about the currently logged-in user. This method is only effective if you have previously logged in using `login` or `loginWithToken`. ### Method GET ### Endpoint /auth/whoami ### Parameters None ### Request Example ```javascript balena.auth.whoami().then(function(result) { if (!result) { console.log('I\'m not logged in!'); } else { console.log('My result is:', result); } }); ``` ### Response #### Success Response (200) - **actorInfo** (Object|undefined) - Information about the logged-in actor, or undefined if not logged in. ``` ```APIDOC ## POST /auth/authenticate ### Description Authenticates with the Balena server using provided credentials. It's recommended to use the `login` method for a more complete authentication flow, including token persistence. Extra keys in `credentials` will be discarded. ### Method POST ### Endpoint /auth/authenticate ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **credentials** (Object) - Required - An object containing authentication details. - **email** (String) - Required - The user's email address. - **password** (String) - Required - The user's password. ### Request Example ```javascript const credentials = { email: 'user@example.com', password: 'password123' }; balena.auth.authenticate(credentials).then(function(token) { console.log('My token is:', token); }); ``` ### Response #### Success Response (200) - **sessionToken** (String) - The session token obtained after successful authentication. ``` ```APIDOC ## POST /auth/login ### Description Logs the user into the Balena application. If successful, the authentication token is persisted across sessions. ### Method POST ### Endpoint /auth/login ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **credentials** (Object) - Required - An object containing login details. - **email** (String) - Required - The user's email address. - **password** (String) - Required - The user's password. ### Request Example ```javascript const credentials = { email: 'user@example.com', password: 'password123' }; balena.auth.login(credentials); ``` ### Response #### Success Response (200) (No specific return value documented, implies successful login and token persistence. ``` ```APIDOC ## POST /auth/loginWithToken ### Description Logs the user into Balena using a pre-existing session token or API key, bypassing the need for email and password credentials. ### Method POST ### Endpoint /auth/loginWithToken ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **authToken** (String) - Required - The authentication token or API key. ### Request Example ```javascript const authToken = 'your_api_or_session_token'; balena.auth.loginWithToken(authToken); ``` ### Response #### Success Response (200) (No specific return value documented, implies successful login. ``` -------------------------------- ### Configuration Methods Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Methods for retrieving device type manifests, options, and configuration schemas. ```APIDOC ## GET /config/deviceTypeManifestBySlug/:slugOrName ### Description Get a device type manifest by its slug. ### Method GET ### Endpoint `/config/deviceTypeManifestBySlug/:slugOrName` ### Parameters #### Path Parameters - **slugOrName** (String) - Required - The slug of the device type. ### Response #### Success Response (200) - **manifest** (Object) - The device type manifest. ### Response Example ```json { "manifest": { ... } } ``` ``` ```APIDOC ## GET /config/deviceOptions/:deviceType ### Description Get configuration/initialization options for a specific device type. ### Method GET ### Endpoint `/config/deviceOptions/:deviceType` ### Parameters #### Path Parameters - **deviceType** (String) - Required - The slug of the device type. ### Response #### Success Response (200) - **options** (Object[]) - An array of configuration options. ### Response Example ```json { "options": [ { ... }, { ... } ] } ``` ``` ```APIDOC ## GET /config/configVarSchema/:deviceType ### Description Get the configuration variables schema for a given device type. ### Method GET ### Endpoint `/config/configVarSchema/:deviceType` ### Parameters #### Path Parameters - **deviceType** (String) - Required - The slug of the device type. ### Response #### Success Response (200) - **schema** (Object[]) - An array representing the configuration variables schema. ### Response Example ```json { "schema": [ { ... }, { ... } ] } ``` ``` -------------------------------- ### config.getAll Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Retrieves all configuration settings for the Balena environment. This is useful for accessing global configuration parameters. ```APIDOC ## GET /config/getAll ### Description Get all configuration settings. This method retrieves the complete configuration object for the Balena environment, which may include API endpoints, feature flags, and other system-wide settings. ### Method GET ### Endpoint `/config/getAll` ### Parameters None ### Request Example ```javascript balena.models.config.getAll().then(function(config) { console.log(config); }); ``` ### Response #### Success Response (200) - **config** (Object) - The complete configuration object. #### Response Example ```json { "apiEndpoint": "https://api.balena-cloud.com", "vpnEndpoint": "vpn.balena-cloud.com", "featureFlags": { "newDashboard": true } } ``` ``` -------------------------------- ### Create Balena SDK Instance from Shared Options Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Initializes a new balena-sdk instance using the default options previously set by `setSharedOptions()`. If no shared options are set, it falls back to the SDK's default factory settings. This is useful for creating consistent SDK configurations across an application. ```javascript import { fromSharedOptions } from 'balena-sdk'; const sdk = fromSharedOptions(); ``` -------------------------------- ### Application Environment Variables API Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Manage environment variables for Balena applications. This includes getting all variables, getting a specific variable, setting a variable, and removing a variable. ```APIDOC ## GET /applications/:slugOrUuidOrId/env-vars ### Description Get all environment variables for a specific application. ### Method GET ### Endpoint `/applications/:slugOrUuidOrId/env-vars` ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - The slug, UUID, or ID of the application. #### Query Parameters - **options** (Object) - Optional - Extra Pine options to use for the query. ### Request Example ```javascript balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) { console.log(vars); }); ``` ### Response #### Success Response (200) - **Object[]** - An array of application environment variables. #### Response Example ```json [ { "name": "MY_ENV_VAR_1", "value": "value1" }, { "name": "MY_ENV_VAR_2", "value": "value2" } ] ``` ``` ```APIDOC ## GET /applications/:slugOrUuidOrId/env-vars/:key ### Description Get the value of a specific environment variable for an application. ### Method GET ### Endpoint `/applications/:slugOrUuidOrId/env-vars/:key` ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - The slug, UUID, or ID of the application. - **key** (String) - Required - The name of the environment variable. ### Request Example ```javascript balena.models.application.envVar.get('myorganization/myapp', 'MY_ENV_VAR').then(function(value) { console.log(value); }); ``` ### Response #### Success Response (200) - **String | undefined** - The value of the environment variable, or undefined if not set. #### Response Example ```json "some_value" ``` ``` ```APIDOC ## POST /applications/:slugOrUuidOrId/env-vars/:key ### Description Set the value of a specific environment variable for an application. ### Method POST ### Endpoint `/applications/:slugOrUuidOrId/env-vars/:key` ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - The slug, UUID, or ID of the application. - **key** (String) - Required - The name of the environment variable. #### Request Body - **value** (String) - Required - The new value for the environment variable. ### Request Example ```javascript balena.models.application.envVar.set('myorganization/myapp', 'MY_ENV_VAR', 'newvalue').then(function() { // ... }); ``` ### Response #### Success Response (200) Indicates that the environment variable was successfully set. #### Response Example (No specific response body provided in the source documentation, typically an empty success response or a confirmation message) ``` ```APIDOC ## DELETE /applications/:slugOrUuidOrId/env-vars/:key ### Description Clear the value of a specific environment variable for an application. ### Method DELETE ### Endpoint `/applications/:slugOrUuidOrId/env-vars/:key` ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - The slug, UUID, or ID of the application. - **key** (String) - Required - The name of the environment variable. ### Request Example ```javascript balena.models.application.envVar.remove('myorganization/myapp', 'MY_ENV_VAR').then(function() { // ... }); ``` ### Response #### Success Response (200) Indicates that the environment variable was successfully cleared. #### Response Example (No specific response body provided in the source documentation, typically an empty success response or a confirmation message) ``` -------------------------------- ### release.createFromUrl Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Creates a new release by building the project source code from a provided URL. This is useful for deploying applications from remote archives. ```APIDOC ## release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ### Description Initiates the creation of a new release by fetching and building project code from a specified URL. ### Method `POST` (Conceptual - SDK method) ### Endpoint `/v1/release` (Conceptual - SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None **Parameters** - **slugOrUuidOrId** (`String` | `Number`) - Required - The application's slug (e.g., 'myorg/myapp'), UUID, or ID. - **urlDeployOptions** (`Object`) - Required - Options for the deployment from URL. - **url** (`String`) - Required - The URL pointing to a tarball of the project source code. - **[shouldFlatten]** (`Boolean`) - Optional, defaults to `true` - Set to `true` if the tarball contains an extra root folder. ### Request Example ```javascript balena.models.release.createFromUrl('myorganization/myapp', { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { console.log(releaseId); }); balena.models.release.createFromUrl(123, { url: 'https://github.com/balena-io-projects/simple-server-node/archive/v1.0.0.tar.gz' }).then(function(releaseId) { console.log(releaseId); }); ``` ### Response #### Success Response (200) - **releaseId** (`number`) - The ID of the newly created release. #### Response Example ```json 12345 ``` ``` -------------------------------- ### Application Config Variables API Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Manage configuration variables for Balena applications. This includes getting all variables, getting a specific variable, setting a variable, and removing a variable. ```APIDOC ## GET /applications/:slugOrUuidOrId/config-vars ### Description Get all configuration variables for a specific application. ### Method GET ### Endpoint `/applications/:slugOrUuidOrId/config-vars` ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - The slug, UUID, or ID of the application. #### Query Parameters - **options** (Object) - Optional - Extra Pine options to use for the query. ### Request Example ```javascript balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) { console.log(vars); }); ``` ### Response #### Success Response (200) - **Object[]** - An array of application configuration variables. #### Response Example ```json [ { "name": "BALENA_VAR_1", "value": "value1" }, { "name": "BALENA_VAR_2", "value": "value2" } ] ``` ``` ```APIDOC ## GET /applications/:slugOrUuidOrId/config-vars/:key ### Description Get the value of a specific configuration variable for an application. ### Method GET ### Endpoint `/applications/:slugOrUuidOrId/config-vars/:key` ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - The slug, UUID, or ID of the application. - **key** (String) - Required - The name of the configuration variable. ### Request Example ```javascript balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) { console.log(value); }); ``` ### Response #### Success Response (200) - **String | undefined** - The value of the configuration variable, or undefined if not set. #### Response Example ```json "some_value" ``` ``` ```APIDOC ## POST /applications/:slugOrUuidOrId/config-vars/:key ### Description Set the value of a specific configuration variable for an application. ### Method POST ### Endpoint `/applications/:slugOrUuidOrId/config-vars/:key` ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - The slug, UUID, or ID of the application. - **key** (String) - Required - The name of the configuration variable. #### Request Body - **value** (String) - Required - The new value for the configuration variable. ### Request Example ```javascript balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() { // ... }); ``` ### Response #### Success Response (200) Indicates that the configuration variable was successfully set. #### Response Example (No specific response body provided in the source documentation, typically an empty success response or a confirmation message) ``` ```APIDOC ## DELETE /applications/:slugOrUuidOrId/config-vars/:key ### Description Clear the value of a specific configuration variable for an application. ### Method DELETE ### Endpoint `/applications/:slugOrUuidOrId/config-vars/:key` ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - The slug, UUID, or ID of the application. - **key** (String) - Required - The name of the configuration variable. ### Request Example ```javascript balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() { // ... }); ``` ### Response #### Success Response (200) Indicates that the configuration variable was successfully cleared. #### Response Example (No specific response body provided in the source documentation, typically an empty success response or a confirmation message) ``` -------------------------------- ### Application Build Environment Variables API Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Manage build-time environment variables for a specific balena application. This includes getting all variables, getting a specific variable, setting a variable, and removing a variable. ```APIDOC ## GET /v1/applications/{slugOrUuidOrId}/build-variables ### Description Get all build environment variables for an application. ### Method GET ### Endpoint /v1/applications/{slugOrUuidOrId}/build-variables ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - Application slug, UUID, or ID. #### Query Parameters - **options** (Object) - Optional - Extra pine options to use for the query. ### Response #### Success Response (200) - **variables** (Object[]) - An array of build environment variable objects. - **name** (String) - The name of the build environment variable. - **value** (String) - The value of the build environment variable. #### Response Example ```json [ { "name": "VAR1", "value": "value1" }, { "name": "VAR2", "value": "value2" } ] ``` ## GET /v1/applications/{slugOrUuidOrId}/build-variables/{key} ### Description Get the value of a specific build environment variable for an application. ### Method GET ### Endpoint /v1/applications/{slugOrUuidOrId}/build-variables/{key} ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - Application slug, UUID, or ID. - **key** (String) - Required - The name of the build environment variable. ### Response #### Success Response (200) - **value** (String) - The value of the build environment variable. #### Response Example ```json { "value": "some_build_value" } ``` ## PUT /v1/applications/{slugOrUuidOrId}/build-variables/{key} ### Description Set the value of a specific build environment variable for an application. ### Method PUT ### Endpoint /v1/applications/{slugOrUuidOrId}/build-variables/{key} ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - Application slug, UUID, or ID. - **key** (String) - Required - The name of the build environment variable. #### Request Body - **value** (String) - Required - The new value for the build environment variable. ### Request Example ```json { "value": "new_build_value" } ``` ## DELETE /v1/applications/{slugOrUuidOrId}/build-variables/{key} ### Description Clear the value of a specific build environment variable for an application. ### Method DELETE ### Endpoint /v1/applications/{slugOrUuidOrId}/build-variables/{key} ### Parameters #### Path Parameters - **slugOrUuidOrId** (String | Number) - Required - Application slug, UUID, or ID. - **key** (String) - Required - The name of the build environment variable to remove. ### Response #### Success Response (204) No content returned on successful deletion. ``` -------------------------------- ### Login User - Node.js Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Logs a user into the Balena system using their credentials. This method initiates a session for the user and returns a promise upon completion. ```javascript balena.auth.login(credentials) ``` -------------------------------- ### Config Management API Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index APIs for managing device configuration variables and schemas. ```APIDOC ## GET /config ### Description Retrieves all configuration variables for the current context. ### Method GET ### Endpoint /config ### Parameters #### Path Parameters None #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - An object containing key-value pairs of configuration variables. #### Response Example ```json { "CONFIG_VAR_1": "value1", "CONFIG_VAR_2": "value2" } ``` ## GET /config/device-types/options ### Description Retrieves configuration options for a specific device type. ### Method GET ### Endpoint /config/device-types/options ### Parameters #### Path Parameters None #### Query Parameters - **deviceType** (string) - Required - The device type slug or name. ### Request Example ```json { "deviceType": "raspberrypi3" } ``` ### Response #### Success Response (200) - An object containing configuration options for the specified device type. #### Response Example ```json { "option1": "valueA", "option2": "valueB" } ``` ## GET /config/device-types/schema ### Description Retrieves the configuration variable schema for a specific device type. ### Method GET ### Endpoint /config/device-types/schema ### Parameters #### Path Parameters None #### Query Parameters - **deviceType** (string) - Required - The device type slug or name. ### Request Example ```json { "deviceType": "raspberrypi3" } ``` ### Response #### Success Response (200) - A JSON schema object defining the configuration variables for the specified device type. #### Response Example ```json { "type": "object", "properties": { "SOME_CONFIG_VAR": { "type": "string", "description": "A sample configuration variable." } } } ``` ``` -------------------------------- ### Get Application Dashboard URL (JavaScript) Source: https://docs.balena.io/reference/sdk/node-sdk/latest/index Retrieves the dashboard URL for a specific Balena application using its ID. This method requires the `balena` SDK to be initialized and an application object to be fetched first to get its ID. It returns a string representing the URL. ```javascript balena.models.application.get('myorganization/myapp').then(function(application) { const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id); console.log(dashboardApplicationUrl); }); ```