# Latest

## v23.1.17

## Installation

Install the balena SDK by running:

```sh
$ npm install --save balena-sdk
```

### Bundling for browsers

If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built `balena-browser.min.js` bundle.

If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle:

* fs
* path
* balena-settings-client
* node-localstorage
* fs/promises
* mime

### Bundling with pkg

The balena SDK includes builds for various ECMAScript versions that are dynamically selected at runtime (using [@balena/es-version](https://github.com/balena-io-modules/balena-es-version)). For this reason, packagers like [pkg](https://github.com/vercel/pkg) are not able to automatically detect which assets to include in the output package. The following sample `pkg` section should be added to your application's `package.json` file to instruct `pkg` to bundle the required assets:

```json
  "pkg": {
    "scripts": [
      "node_modules/balena-sdk/**/*.js"
    ],
    "assets": [
      "node_modules/pinejs-client-core/**/*"
    ]
  }
```

For more information, please refer to the respective [documentation from the `pkg` project](https://github.com/vercel/pkg#config).

## Trying balenaSDK in the browser

BalenaSDK is widely utilized in the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. To use it, head to the [balenaCloud dashboard](https://dashboard.balena-cloud.com/) and open the [browser developer console](https://support.monday.com/hc/en-us/articles/360002197259-How-to-Open-the-Developer-Console). There, you will find balenaSDK initialized in the console and ready to run SDK queries.

![](https://user-images.githubusercontent.com/22801822/157650701-d47ee5bc-28e4-4ca9-9aba-e208d47698c3.png)

If you feel something is missing, not clear or could be improved, please don't hesitate to open an [issue in GitHub](https://github.com/balena-io/balena-sdk/issues/new), we'll be happy to help.

## Modules

[balena-sdk](#module_balena-sdk)

## Objects

[balena](#balena) : `object`

## Functions

[listImagesFromTargetState(targetState)](#listImagesFromTargetState) ⇒

## balena-sdk

* [balena-sdk](#module_balena-sdk)
  * [\~fromSharedOptions()](#module_balena-sdk..fromSharedOptions)
  * [\~getSdk()](#module_balena-sdk..getSdk)
  * [\~setSharedOptions(options)](#module_balena-sdk..setSharedOptions)

***

### balena-sdk\~fromSharedOptions()

Create an SDK instance using shared default options set using the `setSharedOptions()` method. If options have not been set using this method, then this method will use the same defaults as the main SDK factory function.

**Kind**: inner method of [`balena-sdk`](#module_balena-sdk)\
**Summary**: Create an SDK instance using shared default options\
**Access**: public\
**Example**

```js
import { fromSharedOptions } from 'balena-sdk';
const sdk = fromSharedOptions();
```

***

### balena-sdk\~getSdk()

The module exports a single factory function.

**Kind**: inner method of [`balena-sdk`](#module_balena-sdk)\
**Summary**: Creates a new SDK instance using the default or the provided options.\
**Example**

```js
// 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"
});
```

***

### balena-sdk\~setSharedOptions(options)

Set options that are used by calls to `fromSharedOptions()`. The options accepted are the same as those used in the main SDK factory function. If you use this method, it should be called as soon as possible during app startup and before any calls to `fromSharedOptions()` are made.

**Kind**: inner method of [`balena-sdk`](#module_balena-sdk)\
**Summary**: Set shared default options\
**Access**: public

| Param                               | Type                    | Default                               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------------------- | ----------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options                             | `Object`                |                                       | The shared default options                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| \[options.apiUrl]                   | `String`                | `'https://api.balena-cloud.com/'`     | the balena API url to use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| \[options.builderUrl]               | `String`                | `'https://builder.balena-cloud.com/'` | the balena builder url to use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| \[options.deviceUrlsBase]           | `String`                | `'balena-devices.com'`                | the base balena device API url to use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| \[options.requestLimit]             | `Number`                |                                       | the number of requests per requestLimitInterval that the SDK should respect.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| \[options.requestLimitInterval]     | `Number`                | `60000`                               | the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| \[options.retryRateLimitedRequests] | `Boolean` \| `function` | `false`                               | <p>Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header.</p><ul><li>If <code>false</code>, rate-limited requests will not be retried, and the rate limit error will be propagated.</li><li>If <code>true</code>, all rate-limited requests will be retried after the duration specified by the <code>Retry-After</code> header.</li><li>If a function <code>(retryAfterMs: number) => boolean</code> is provided, it will be called with the retry duration in ms and the request will be retried only when <code>true</code> is returned.</li></ul> |
| \[options.dataDirectory]            | `String` \| `False`     | `'$HOME/.balena'`                     | *ignored in the browser unless false*, the directory where the user settings are stored, normally retrieved like `require('balena-settings-client').get('dataDirectory')`. Providing `false` creates an isolated in-memory instance.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| \[options.isBrowser]                | `Boolean`               |                                       | the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global `window` value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| \[options.debug]                    | `Boolean`               |                                       | when set will print some extra debug information.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

**Example**

```js
import { setSharedOptions } from 'balena-sdk';
setSharedOptions({
	apiUrl: 'https://api.balena-cloud.com/',
	builderUrl: 'https://builder.balena-cloud.com/',
	isBrowser: true,
});
```

***

## listImagesFromTargetState(targetState) ⇒

**Kind**: global function\
**Returns**: array containing all images for all services for all releases for all apps for the device

| Param       |
| ----------- |
| targetState |

***

## balena : `object`

**Kind**: global namespace

* [balena](#balena) : `object`
  * [.errors](#balena.errors) : `Object`
  * [.interceptors](#balena.interceptors) : `Array.<Interceptor>`
    * [.Interceptor](#balena.interceptors.Interceptor) : `object`
  * [.pine](#balena.pine) : `Object`
  * [.request](#balena.request) : `Object`
  * [.utils](#balena.utils) : `Object`
  * [.auth](#balena.auth) : `object`
    * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ `Promise`
    * [.getActorId()](#balena.auth.getActorId) ⇒ `Promise`
    * [.getToken()](#balena.auth.getToken) ⇒ `Promise`
    * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ `Promise`
    * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ `Promise`
    * [.login(credentials)](#balena.auth.login) ⇒ `Promise`
    * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ `Promise`
    * [.logout()](#balena.auth.logout) ⇒ `Promise`
    * [.register(credentials)](#balena.auth.register) ⇒ `Promise`
    * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ `Promise`
    * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ `Promise`
    * [.whoami()](#balena.auth.whoami) ⇒ `Promise`
    * [.twoFactor](#balena.auth.twoFactor) : `object`
      * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ `Promise`
      * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ `Promise`
      * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ `Promise`
      * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ `Promise`
      * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ `Promise`
      * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ `Promise`
      * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ `Promise`
  * [.logs](#balena.logs) : `object`
    * [.history(uuidOrId, \[options\])](#balena.logs.history) ⇒ `Promise`
    * [.subscribe(uuidOrId, \[options\])](#balena.logs.subscribe) ⇒ `Promise.<LogSubscription>`
    * [.LogSubscription](#balena.logs.LogSubscription) : `EventEmitter`
      * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe)
      * ["error"](#balena.logs.LogSubscription.event_error)
      * ["line"](#balena.logs.LogSubscription.event_line)
  * [.models](#balena.models) : `object`
    * [.apiKey](#balena.models.apiKey) : `object`
      * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ `Promise`
      * [.getAll(\[options\])](#balena.models.apiKey.getAll) ⇒ `Promise`
      * [.getAllNamedUserApiKeys(\[options\])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ `Promise`
      * [.getDeviceApiKeysByDevice(uuidOrId, \[options\])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ `Promise`
      * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, \[options\])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ `Promise`
      * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ `Promise`
      * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ `Promise`
    * [.application](#balena.models.application) : `object`
      * [.create(options)](#balena.models.application.create) ⇒ `Promise`
      * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ `Promise`
      * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ `Promise`
      * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ `Promise`
      * [.get(slugOrUuidOrId, \[options\], \[context\])](#balena.models.application.get) ⇒ `Promise`
      * [.getAll(\[options\], \[context\])](#balena.models.application.getAll) ⇒ `Promise`
      * [.getAllByOrganization(orgHandleOrId, \[options\])](#balena.models.application.getAllByOrganization) ⇒ `Promise`
      * [.getAllDirectlyAccessible(\[options\])](#balena.models.application.getAllDirectlyAccessible) ⇒ `Promise`
      * [.getAppByName(appName, \[options\], \[context\])](#balena.models.application.getAppByName) ⇒ `Promise`
      * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ `String`
      * [.getDirectlyAccessible(slugOrUuidOrId, \[options\])](#balena.models.application.getDirectlyAccessible) ⇒ `Promise`
      * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ `Promise`
      * [.getWithDeviceServiceDetails(slugOrUuidOrId, \[options\])](#balena.models.application.getWithDeviceServiceDetails) ⇒ `Promise`
      * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ `Promise`
      * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ `Promise`
      * [.hasAny()](#balena.models.application.hasAny) ⇒ `Promise`
      * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ `Promise`
      * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ `Promise`
      * [.purge(appId)](#balena.models.application.purge) ⇒ `Promise`
      * [.reboot(appId, \[options\])](#balena.models.application.reboot) ⇒ `Promise`
      * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ `Promise`
      * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ `Promise`
      * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ `Promise`
      * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ `Promise`
      * [.shutdown(appId, \[options\])](#balena.models.application.shutdown) ⇒ `Promise`
      * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ `Promise`
      * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ `Promise`
      * [.buildVar](#balena.models.application.buildVar) : `object`
        * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.buildVar.getAllByApplication) ⇒ `Promise`
        * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ `Promise`
        * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ `Promise`
      * [.configVar](#balena.models.application.configVar) : `object`
        * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.configVar.getAllByApplication) ⇒ `Promise`
        * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ `Promise`
        * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ `Promise`
      * [.envVar](#balena.models.application.envVar) : `object`
        * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.envVar.getAllByApplication) ⇒ `Promise`
        * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ `Promise`
        * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ `Promise`
      * [.invite](#balena.models.application.invite) : `object`
        * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ `Promise`
        * [.create(slugOrUuidOrId, options, \[message\])](#balena.models.application.invite.create) ⇒ `Promise`
        * [.getAll(\[options\])](#balena.models.application.invite.getAll) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.invite.getAllByApplication) ⇒ `Promise`
        * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ `Promise`
      * [.membership](#balena.models.application.membership) : `object`
        * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ `Promise`
        * [.create(options)](#balena.models.application.membership.create) ⇒ `Promise`
        * [.get(membershipId, \[options\])](#balena.models.application.membership.get) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.membership.getAllByApplication) ⇒ `Promise`
        * [.getAllByUser(usernameOrId, \[options\])](#balena.models.application.membership.getAllByUser) ⇒ `Promise`
        * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ `Promise`
      * [.tags](#balena.models.application.tags) : `object`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.tags.getAllByApplication) ⇒ `Promise`
        * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ `Promise`
        * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ `Promise`
    * [.billing](#balena.models.billing) : `object`
      * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ `Promise`
      * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ `Promise`
      * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ `Promise`
      * [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ `Promise`
      * [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ `Promise`
      * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ `Promise`
      * [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ `Promise`
      * [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ `Promise`
      * [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo)
      * [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ `Promise`
    * [.config](#balena.models.config) : `object`
      * [.getAll()](#balena.models.config.getAll) ⇒ `Promise`
      * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ `Promise`
      * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ `Promise`
      * [~~.getDeviceTypeManifestBySlug(slugOrName)~~](#balena.models.config.getDeviceTypeManifestBySlug) ~~⇒ `Promise`~~
      * [~~.getDeviceTypes()~~](#balena.models.config.getDeviceTypes) ~~⇒ `Promise`~~
    * [.creditBundle](#balena.models.creditBundle) : `object`
      * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ `Promise`
      * [.getAllByOrg(organization, \[options\])](#balena.models.creditBundle.getAllByOrg) ⇒ `Promise`
    * [.device](#balena.models.device) : `object`
      * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ `Promise`
      * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ `Promise`
      * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ `Promise`
      * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ `Promise`
      * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ `Promise`
      * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ `Promise`
      * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ `Promise`
      * [.generateDeviceKey(uuidOrId, \[keyName\], \[keyDescription\])](#balena.models.device.generateDeviceKey) ⇒ `Promise`
      * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ `String`
      * [.get(uuidOrId, \[options\])](#balena.models.device.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.getAllByApplication) ⇒ `Promise`
      * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.device.getAllByOrganization) ⇒ `Promise`
      * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ `Promise`
      * [.getByName(name)](#balena.models.device.getByName) ⇒ `Promise`
      * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ `String`
      * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ `Promise`
      * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ `Promise`
      * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ `Object`
      * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ `Promise`
      * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ `Promise`
      * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ `Promise`
      * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ `String`
      * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ `Promise`
      * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ `Promise`
      * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ `Promise`
      * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ `Promise`
      * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ `Promise`
      * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ `Promise`
      * [.getWithServiceDetails(uuidOrId, \[options\])](#balena.models.device.getWithServiceDetails) ⇒ `Promise`
      * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ `Promise`
      * [.has(uuidOrId)](#balena.models.device.has) ⇒ `Promise`
      * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ `Promise`
      * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ `Promise`
      * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ `Promise`
      * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ `Promise`
      * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ `Promise`
      * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ `Promise`
      * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ `Promise`
      * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ `Promise`
      * [.pinToOsRelease(uuidOrIdOrArray, osVersionOrId)](#balena.models.device.pinToOsRelease) ⇒ `Promise`
      * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ `Promise`
      * [.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.pinToSupervisorRelease) ⇒ `Promise`
      * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ `Promise`
      * [.reboot(uuidOrId, \[options\])](#balena.models.device.reboot) ⇒ `Promise`
      * [.register(applicationSlugOrUuidOrId, uuid, \[deviceTypeSlug\])](#balena.models.device.register) ⇒ `Promise`
      * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ `Promise`
      * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ `Promise`
      * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ `Promise`
      * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ `Promise`
      * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ `Promise`
      * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ `Promise`
      * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ `Promise`
      * [.shutdown(uuidOrId, \[options\])](#balena.models.device.shutdown) ⇒ `Promise`
      * [.startOsUpdate(uuidOrUuids, targetOsVersion, \[options\])](#balena.models.device.startOsUpdate) ⇒ `Promise`
      * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ `Promise`
      * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ `Promise`
      * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ `Promise`
      * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ `Promise`
      * [.update(uuidOrId, \[options\])](#balena.models.device.update) ⇒ `Promise`
      * [.configVar](#balena.models.device.configVar) : `object`
        * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.configVar.getAllByApplication) ⇒ `Promise`
        * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.configVar.getAllByDevice) ⇒ `Promise`
        * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ `Promise`
        * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ `Promise`
      * [.envVar](#balena.models.device.envVar) : `object`
        * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.envVar.getAllByApplication) ⇒ `Promise`
        * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.envVar.getAllByDevice) ⇒ `Promise`
        * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ `Promise`
        * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ `Promise`
      * [.history](#balena.models.device.history) : `object`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.history.getAllByApplication) ⇒ `Promise`
        * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.history.getAllByDevice) ⇒ `Promise`
      * [.serviceVar](#balena.models.device.serviceVar) : `object`
        * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.serviceVar.getAllByApplication) ⇒ `Promise`
        * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.serviceVar.getAllByDevice) ⇒ `Promise`
        * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ `Promise`
        * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ `Promise`
      * [.tags](#balena.models.device.tags) : `object`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.tags.getAllByApplication) ⇒ `Promise`
        * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.tags.getAllByDevice) ⇒ `Promise`
        * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ `Promise`
        * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ `Promise`
    * [.deviceType](#balena.models.deviceType) : `object`
      * [.get(idOrSlug, \[options\])](#balena.models.deviceType.get) ⇒ `Promise`
      * [.getAll(\[options\])](#balena.models.deviceType.getAll) ⇒ `Promise`
      * [.getAllSupported(\[options\])](#balena.models.deviceType.getAllSupported) ⇒ `Promise`
      * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ `Promise`
      * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ `Promise`
      * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ `Promise`
      * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ `Promise`
      * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ `Promise`
      * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ `Promise`
    * [.image](#balena.models.image) : `object`
      * [.get(id, \[options\])](#balena.models.image.get) ⇒ `Promise`
      * [.getLogs(id)](#balena.models.image.getLogs) ⇒ `Promise`
    * [.key](#balena.models.key) : `object`
      * [.create(title, key)](#balena.models.key.create) ⇒ `Promise`
      * [.get(id)](#balena.models.key.get) ⇒ `Promise`
      * [.getAll(\[options\])](#balena.models.key.getAll) ⇒ `Promise`
      * [.remove(id)](#balena.models.key.remove) ⇒ `Promise`
    * [.organization](#balena.models.organization) : `object`
      * [.create(options)](#balena.models.organization.create) ⇒ `Promise`
      * [.get(handleOrId, \[options\])](#balena.models.organization.get) ⇒ `Promise`
      * [.getAll(\[options\])](#balena.models.organization.getAll) ⇒ `Promise`
      * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ `Promise`
      * [.invite](#balena.models.organization.invite) : `object`
        * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ `Promise`
        * [.create(handleOrId, options, \[message\])](#balena.models.organization.invite.create) ⇒ `Promise`
        * [.getAll(\[options\])](#balena.models.organization.invite.getAll) ⇒ `Promise`
        * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.organization.invite.getAllByOrganization) ⇒ `Promise`
        * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ `Promise`
      * [.membership](#balena.models.organization.membership) : `object`
        * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ `Promise`
        * [.get(membershipId, \[options\])](#balena.models.organization.membership.get) ⇒ `Promise`
        * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.organization.membership.getAllByOrganization) ⇒ `Promise`
        * [.getAllByUser(usernameOrId, \[options\])](#balena.models.organization.membership.getAllByUser) ⇒ `Promise`
        * [.remove(id)](#balena.models.organization.membership.remove) ⇒ `Promise`
    * [.os](#balena.models.os) : `object`
      * [.download(options)](#balena.models.os.download) ⇒ `Promise`
      * [.getAllOsVersions(deviceTypes, \[options\])](#balena.models.os.getAllOsVersions) ⇒ `Promise`
      * [.getAvailableOsVersions(deviceTypes, \[pineOptions\], \[extraOptions\])](#balena.models.os.getAvailableOsVersions) ⇒ `Promise`
      * [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ `Promise`
      * [.getDownloadSize(deviceType, \[version\])](#balena.models.os.getDownloadSize) ⇒ `Promise`
      * [.getMaxSatisfyingVersion(deviceType, versionOrRange, \[osType\])](#balena.models.os.getMaxSatisfyingVersion) ⇒ `Promise`
      * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ `Promise`
      * [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, \[options\])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ `Promise.<String>`
      * [.getSupportedOsUpdateVersions(deviceType, currentVersion, \[options\])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ `Promise`
      * [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ `Boolean`
      * [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ `Promise`
    * [.release](#balena.models.release) : `object`
      * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ `Promise`
      * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ `Promise`
      * [.get(commitOrIdOrRawVersion, \[options\])](#balena.models.release.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.getAllByApplication) ⇒ `Promise`
      * [.getLatestByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.getLatestByApplication) ⇒ `Promise`
      * [.getWithImageDetails(commitOrIdOrRawVersion, \[options\])](#balena.models.release.getWithImageDetails) ⇒ `Promise`
      * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ `Promise`
      * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ `Promise`
      * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ `Promise`
      * [.asset](#balena.models.release.asset) : `object`
        * [.download(id)](#balena.models.release.asset.download) ⇒ `Promise`
        * [.get(id, \[options\])](#balena.models.release.asset.get) ⇒ `Promise`
        * [.getAllByRelease(commitOrIdOrRawVersion, \[options\])](#balena.models.release.asset.getAllByRelease) ⇒ `Promise`
        * [.remove(id)](#balena.models.release.asset.remove) ⇒ `Promise`
        * [.upload(uploadParams, \[options\])](#balena.models.release.asset.upload) ⇒ `Promise`
      * [.tags](#balena.models.release.tags) : `object`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.tags.getAllByApplication) ⇒ `Promise`
        * [.getAllByRelease(commitOrIdOrRawVersion, \[options\])](#balena.models.release.tags.getAllByRelease) ⇒ `Promise`
        * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ `Promise`
        * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ `Promise`
    * [.service](#balena.models.service) : `object`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.service.getAllByApplication) ⇒ `Promise`
      * [.var](#balena.models.service.var) : `object`
        * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ `Promise`
        * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.service.var.getAllByApplication) ⇒ `Promise`
        * [.getAllByService(serviceIdOrNaturalKey, \[options\])](#balena.models.service.var.getAllByService) ⇒ `Promise`
        * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ `Promise`
        * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ `Promise`
    * [.team](#balena.models.team) : `object`
      * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ `Promise`
      * [.get(teamId, \[options\])](#balena.models.team.get) ⇒ `Promise`
      * [.getAllByOrganization(organizationSlugOrId, \[options\])](#balena.models.team.getAllByOrganization) ⇒ `Promise`
      * [.remove(teamId)](#balena.models.team.remove) ⇒ `Promise`
      * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ `Promise`
      * [.applicationAccess](#balena.models.team.applicationAccess) : `object`
        * [.get(teamApplicationAccessId, \[options\])](#balena.models.team.applicationAccess.get) ⇒ `Promise`
        * [.getAllByTeam(teamId, \[options\])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ `Promise`
        * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ `Promise`
        * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ `Promise`
  * [.settings](#balena.settings) : `object`
    * [.get(\[key\])](#balena.settings.get) ⇒ `Promise`
    * [.getAll()](#balena.settings.getAll) ⇒ `Promise`
  * [.utils](#balena.utils) : `object`

***

### balena.errors : `Object`

The balena-errors module used internally. This is provided primarily for convenience, and to avoid the necessity for separate balena-errors dependencies. You'll want to use this if you need to match on the specific type of error thrown by the SDK.

**Kind**: static property of [`balena`](#balena)\
**Summary**: Balena errors module\
**Access**: public\
**Example**

```js
balena.models.device.get(123).catch(function (error) {
  if (error.code === balena.errors.BalenaDeviceNotFound.prototype.code) {
    ...
  } else if (error.code === balena.errors.BalenaRequestError.prototype.code) {
    ...
  }
});
```

***

### balena.interceptors : `Array.<Interceptor>`

The current array of interceptors to use. Interceptors intercept requests made internally and are executed in the order they appear in this array for requests, and in the reverse order for responses.

**Kind**: static property of [`balena`](#balena)\
**Summary**: Array of interceptors\
**Access**: public\
**Example**

```js
balena.interceptors.push({
	responseError: function (error) {
		console.log(error);
		throw error;
	})
});
```

***

#### interceptors.Interceptor : `object`

An interceptor implements some set of the four interception hook callbacks. To continue processing, each function should return a value or a promise that successfully resolves to a value.

To halt processing, each function should throw an error or return a promise that rejects with an error.

**Kind**: static typedef of [`interceptors`](#balena.interceptors)\
**Properties**

| Name             | Type       | Description                                                                                                                                                                                                                                                                                        |
| ---------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \[request]       | `function` | Callback invoked before requests are made. Called with the request options, should return (or resolve to) new request options, or throw/reject.                                                                                                                                                    |
| \[response]      | `function` | Callback invoked before responses are returned. Called with the response, should return (or resolve to) a new response, or throw/reject.                                                                                                                                                           |
| \[requestError]  | `function` | Callback invoked if an error happens before a request. Called with the error itself, caused by a preceeding request interceptor rejecting/throwing an error for the request, or a failing in preflight token validation. Should return (or resolve to) new request options, or throw/reject.       |
| \[responseError] | `function` | Callback invoked if an error happens in the response. Called with the error itself, caused by a preceeding response interceptor rejecting/throwing an error for the request, a network error, or an error response from the server. Should return (or resolve to) a new response, or throw/reject. |

***

### balena.pine : `Object`

The pinejs-client instance used internally. This should not be necessary in normal usage, but can be useful if you want to directly make pine queries to the api for some resource that isn't directly supported in the SDK.

**Kind**: static property of [`balena`](#balena)\
**Summary**: Balena pine instance\
**Access**: public\
**Example**

```js
balena.pine.get({
	resource: 'release',
	options: {
		$count: {
			$filter: { belongs_to__application: applicationId }
		}
	}
});
```

***

### balena.request : `Object`

The balena-request instance used internally. This should not be necessary in normal usage, but can be useful if you want to make an API request directly, using the same token and hooks as the SDK.

**Kind**: static property of [`balena`](#balena)\
**Summary**: Balena request instance\
**Access**: public\
**Example**

```js
balena.request.send({ url: 'http://api.balena-cloud.com/ping' });
```

***

### balena.utils : `Object`

The utils instance offers some convenient features for clients.

**Kind**: static property of [`balena`](#balena)\
**Summary**: Balena utils instance\
**Access**: public\
**Example**

```js
balena.utils.mergePineOptions(
 { $expand: { device: { $select: ['id'] } } },
 { $expand: { device: { $select: ['name'] } } },
);
```

***

### balena.auth : `object`

**Kind**: static namespace of [`balena`](#balena)

* [.auth](#balena.auth) : `object`
  * [.authenticate(credentials)](#balena.auth.authenticate) ⇒ `Promise`
  * [.getActorId()](#balena.auth.getActorId) ⇒ `Promise`
  * [.getToken()](#balena.auth.getToken) ⇒ `Promise`
  * [.getUserInfo()](#balena.auth.getUserInfo) ⇒ `Promise`
  * [.isLoggedIn()](#balena.auth.isLoggedIn) ⇒ `Promise`
  * [.login(credentials)](#balena.auth.login) ⇒ `Promise`
  * [.loginWithToken(authToken)](#balena.auth.loginWithToken) ⇒ `Promise`
  * [.logout()](#balena.auth.logout) ⇒ `Promise`
  * [.register(credentials)](#balena.auth.register) ⇒ `Promise`
  * [.requestVerificationEmail()](#balena.auth.requestVerificationEmail) ⇒ `Promise`
  * [.verifyEmail(verificationPayload)](#balena.auth.verifyEmail) ⇒ `Promise`
  * [.whoami()](#balena.auth.whoami) ⇒ `Promise`
  * [.twoFactor](#balena.auth.twoFactor) : `object`
    * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ `Promise`
    * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ `Promise`
    * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ `Promise`
    * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ `Promise`
    * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ `Promise`
    * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ `Promise`
    * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ `Promise`

***

#### auth.authenticate(credentials) ⇒ `Promise`

You should use [login](#balena.auth.login) when possible, as it takes care of saving the token and email as well.

Notice that if `credentials` contains extra keys, they'll be discarted by the server automatically.

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Authenticate with the server\
**Access**: protected\
**Fulfil**: `String` - session token

| Param                | Type     | Description                    |
| -------------------- | -------- | ------------------------------ |
| credentials          | `Object` | in the form of email, password |
| credentials.email    | `String` | the email                      |
| credentials.password | `String` | the password                   |

**Example**

```js
balena.auth.authenticate(credentials).then(function(token) {
	console.log('My token is:', token);
});
```

***

#### auth.getActorId() ⇒ `Promise`

This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in.

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Get current logged in actor id\
**Access**: public\
**Fulfil**: `Number` - actor id\
**Example**

```js
balena.auth.getActorId().then(function(actorId) {
	console.log(actorId);
});
```

***

#### auth.getToken() ⇒ `Promise`

This will only work if you used [login](#balena.auth.login) to log in.

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Get current logged in user's raw API key or session token\
**Access**: public\
**Fulfil**: `String` - raw API key or session token\
**Example**

```js
balena.auth.getToken().then(function(token) {
	console.log(token);
});
```

***

#### auth.getUserInfo() ⇒ `Promise`

This will only work if you used [login](#balena.auth.login) to log in.

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Get current logged in user's info\
**Access**: public\
**Fulfil**: `Object` - user info\
**Example**

```js
balena.auth.getUserInfo().then(function(userInfo) {
	console.log(userInfo);
});
```

***

#### auth.isLoggedIn() ⇒ `Promise`

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Check if you're logged in\
**Access**: public\
**Fulfil**: `Boolean` - is logged in\
**Example**

```js
balena.auth.isLoggedIn().then(function(isLoggedIn) {
	if (isLoggedIn) {
		console.log('I\'m in!');
	} else {
		console.log('Too bad!');
	}
});
```

***

#### auth.login(credentials) ⇒ `Promise`

If the login is successful, the token is persisted between sessions.

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Login\
**Access**: public

| Param                | Type     | Description                    |
| -------------------- | -------- | ------------------------------ |
| credentials          | `Object` | in the form of email, password |
| credentials.email    | `String` | the email                      |
| credentials.password | `String` | the password                   |

**Example**

```js
balena.auth.login(credentials);
```

***

#### auth.loginWithToken(authToken) ⇒ `Promise`

Login to balena with a session token or api key instead of with credentials.

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Login with a token or api key\
**Access**: public

| Param     | Type     | Description    |
| --------- | -------- | -------------- |
| authToken | `String` | the auth token |

**Example**

```js
balena.auth.loginWithToken(authToken);
```

***

#### auth.logout() ⇒ `Promise`

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Logout\
**Access**: public\
**Example**

```js
balena.auth.logout();
```

***

#### auth.register(credentials) ⇒ `Promise`

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Register a user account\
**Access**: public\
**Fulfil**: `String` - session token

| Param                                 | Type                    | Description                                 |
| ------------------------------------- | ----------------------- | ------------------------------------------- |
| credentials                           | `Object`                | in the form of username, password and email |
| credentials.email                     | `String`                | the email                                   |
| credentials.password                  | `String`                | the password                                |
| \[credentials.'g-recaptcha-response'] | `String` \| `undefined` | the captcha response                        |

**Example**

```js
balena.auth.register({
	email: 'johndoe@gmail.com',
	password: 'secret'
}).then(function(token) {
	console.log(token);
});
```

***

#### auth.requestVerificationEmail() ⇒ `Promise`

This will only work if you used [login](#balena.auth.login) to log in.

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Re-send verification email to the user\
**Access**: public\
**Example**

```js
balena.auth.requestVerificationEmail().then(function() {
	console.log('Requesting verification email operation complete!');
})
```

***

#### auth.verifyEmail(verificationPayload) ⇒ `Promise`

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Verifies an email\
**Access**: public\
**Fulfil**: `String` - session token

| Param                     | Type     | Description                     |
| ------------------------- | -------- | ------------------------------- |
| verificationPayload       | `Object` | in the form of email, and token |
| verificationPayload.email | `String` | the email                       |
| verificationPayload.token | `String` | the verification token          |

**Example**

```js
balena.auth.verifyEmail({
	email: 'johndoe@gmail.com',
	token: '5bb11d90eefb34a70318f06a43ef063f'
}).then(function(jwt) {
	console.log(jwt);
});
```

***

#### auth.whoami() ⇒ `Promise`

This will only work if you used [login](#balena.auth.login) or [loginWithToken](#balena.auth.loginWithToken) to log in.

**Kind**: static method of [`auth`](#balena.auth)\
**Summary**: Return current logged in information\
**Access**: public\
**Fulfil**: `(Object|undefined)` - actor information, if it exists\
**Example**

```js
balena.auth.whoami().then(function(result) {
	if (!result) {
		console.log('I\'m not logged in!');
	} else {
		console.log('My result is:', result);
	}
});
```

***

#### auth.twoFactor : `object`

**Kind**: static namespace of [`auth`](#balena.auth)

* [.twoFactor](#balena.auth.twoFactor) : `object`
  * [.challenge(code)](#balena.auth.twoFactor.challenge) ⇒ `Promise`
  * [.disable(password)](#balena.auth.twoFactor.disable) ⇒ `Promise`
  * [.enable(code)](#balena.auth.twoFactor.enable) ⇒ `Promise`
  * [.getSetupKey()](#balena.auth.twoFactor.getSetupKey) ⇒ `Promise`
  * [.isEnabled()](#balena.auth.twoFactor.isEnabled) ⇒ `Promise`
  * [.isPassed()](#balena.auth.twoFactor.isPassed) ⇒ `Promise`
  * [.verify(code)](#balena.auth.twoFactor.verify) ⇒ `Promise`

***

**twoFactor.challenge(code) ⇒ `Promise`**

You should use [login](#balena.auth.login) when possible, as it takes care of saving the token and email as well.

**Kind**: static method of [`twoFactor`](#balena.auth.twoFactor)\
**Summary**: Challenge two factor authentication and complete login\
**Access**: public

| Param | Type     | Description |
| ----- | -------- | ----------- |
| code  | `String` | code        |

**Example**

```js
balena.auth.twoFactor.challenge('1234');
```

***

**twoFactor.disable(password) ⇒ `Promise`**

Disables two factor authentication.

**Kind**: static method of [`twoFactor`](#balena.auth.twoFactor)\
**Summary**: Disable two factor authentication\
**Access**: public\
**Fulfil**: `String` - session token

| Param    | Type     | Description |
| -------- | -------- | ----------- |
| password | `String` | password    |

**Example**

```js
const token = balena.auth.twoFactor.disable('1234');
balena.auth.loginWithToken(token);
```

***

**twoFactor.enable(code) ⇒ `Promise`**

Enables two factor authentication.

**Kind**: static method of [`twoFactor`](#balena.auth.twoFactor)\
**Summary**: Enable two factor authentication\
**Access**: public\
**Fulfil**: `String` - session token

| Param | Type     | Description |
| ----- | -------- | ----------- |
| code  | `String` | code        |

**Example**

```js
const token = balena.auth.twoFactor.enable('1234');
balena.auth.loginWithToken(token);
```

***

**twoFactor.getSetupKey() ⇒ `Promise`**

Retrieves a setup key for enabling two factor authentication.

**Kind**: static method of [`twoFactor`](#balena.auth.twoFactor)\
**Summary**: Get two factor authentication setup key\
**Access**: public\
**Fulfil**: `String` - setup key\
**Example**

```js
const setupKey = balena.auth.twoFactor.getSetupKey();
console.log(setupKey);
```

***

**twoFactor.isEnabled() ⇒ `Promise`**

**Kind**: static method of [`twoFactor`](#balena.auth.twoFactor)\
**Summary**: Check if two factor authentication is enabled\
**Access**: public\
**Fulfil**: `Boolean` - whether 2fa is enabled\
**Example**

```js
balena.auth.twoFactor.isEnabled().then(function(isEnabled) {
	if (isEnabled) {
		console.log('2FA is enabled for this account');
	}
});
```

***

**twoFactor.isPassed() ⇒ `Promise`**

**Kind**: static method of [`twoFactor`](#balena.auth.twoFactor)\
**Summary**: Check if two factor authentication challenge was passed\
**Access**: public\
**Fulfil**: `Boolean` - whether 2fa challenge was passed\
**Example**

```js
balena.auth.twoFactor.isPassed().then(function(isPassed) {
	if (isPassed) {
		console.log('2FA challenge passed');
	}
});
```

***

**twoFactor.verify(code) ⇒ `Promise`**

Verifies two factor authentication. Note that this method not update the token automatically. You should use [challenge](#balena.auth.twoFactor.challenge) when possible, as it takes care of that as well.

**Kind**: static method of [`twoFactor`](#balena.auth.twoFactor)\
**Summary**: Verify two factor authentication\
**Access**: public\
**Fulfil**: `String` - session token

| Param | Type     | Description |
| ----- | -------- | ----------- |
| code  | `String` | code        |

**Example**

```js
const token = balena.auth.twoFactor.verify('1234');
balena.auth.loginWithToken(token);
```

***

### balena.logs : `object`

**Kind**: static namespace of [`balena`](#balena)

* [.logs](#balena.logs) : `object`
  * [.history(uuidOrId, \[options\])](#balena.logs.history) ⇒ `Promise`
  * [.subscribe(uuidOrId, \[options\])](#balena.logs.subscribe) ⇒ `Promise.<LogSubscription>`
  * [.LogSubscription](#balena.logs.LogSubscription) : `EventEmitter`
    * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe)
    * ["error"](#balena.logs.LogSubscription.event_error)
    * ["line"](#balena.logs.LogSubscription.event_line)

***

#### logs.history(uuidOrId, \[options]) ⇒ `Promise`

Get an array of the latest log messages for a given device.

**Kind**: static method of [`logs`](#balena.logs)\
**Summary**: Get device logs history\
**Access**: public\
**Fulfil**: `Object[]` - history lines

| Param            | Type                 | Default | Description                                                                  |
| ---------------- | -------------------- | ------- | ---------------------------------------------------------------------------- |
| uuidOrId         | `String` \| `Number` |         | device uuid (string) or id (number)                                          |
| \[options]       | `Object`             |         | options                                                                      |
| \[options.count] | `Number` \| `'all'`  | `1000`  | number of log messages to return (or 'all')                                  |
| \[options.start] | `Number` \| `String` |         | the timestamp or ISO Date string after which to retrieve historical messages |

**Example**

```js
balena.logs.history('7cf02a69e4d34c9da573914963cf54fd').then(function(lines) {
	lines.forEach(function(line) {
		console.log(line);
	});
});
```

**Example**

```js
balena.logs.history(123).then(function(lines) {
	lines.forEach(function(line) {
		console.log(line);
	});
});
```

**Example**

```js
const oneDayAgoTimestamp = Date.now() - 24*60*60*1000;
balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoTimestamp }).then(function(lines) {
	lines.forEach(function(line) {
		console.log(line);
	});
});
```

**Example**

```js
const oneDayAgoIsoDateString = new Date(Date.now() - 24*60*60*1000).toISOString();
balena.logs.history('7cf02a69e4d34c9da573914963cf54fd', { start: oneDayAgoIsoDateString }).then(function(lines) {
	lines.forEach(function(line) {
		console.log(line);
	});
});
```

***

#### logs.subscribe(uuidOrId, \[options]) ⇒ `Promise.<LogSubscription>`

Connects to the stream of devices logs, returning a LogSubscription, which can be used to listen for logs as they appear, line by line.

**Kind**: static method of [`logs`](#balena.logs)\
**Summary**: Subscribe to device logs\
**Access**: public\
**Fulfil**: [`LogSubscription`](#balena.logs.LogSubscription)

| Param            | Type                 | Default | Description                                                                                                                                  |
| ---------------- | -------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| uuidOrId         | `String` \| `Number` |         | device uuid (string) or id (number)                                                                                                          |
| \[options]       | `Object`             |         | options                                                                                                                                      |
| \[options.count] | `Number` \| `'all'`  | `0`     | number of historical messages to include (or 'all')                                                                                          |
| \[options.start] | `Number` \| `String` |         | the timestamp or ISO Date string after which to retrieve historical messages. When specified, the count parameter needs to also be provided. |

**Example**

```js
balena.logs.subscribe('7cf02a69e4d34c9da573914963cf54fd').then(function(logs) {
	logs.on('line', function(line) {
		console.log(line);
	});
});
```

**Example**

```js
balena.logs.subscribe(123).then(function(logs) {
	logs.on('line', function(line) {
		console.log(line);
	});
});
```

***

#### logs.LogSubscription : `EventEmitter`

The log subscription emits events as log data arrives. You can get a LogSubscription for a given device by calling `balena.logs.subscribe(deviceId)`

**Kind**: static typedef of [`logs`](#balena.logs)

* [.LogSubscription](#balena.logs.LogSubscription) : `EventEmitter`
  * [.unsubscribe()](#balena.logs.LogSubscription.unsubscribe)
  * ["error"](#balena.logs.LogSubscription.event_error)
  * ["line"](#balena.logs.LogSubscription.event_line)

***

**LogSubscription.unsubscribe()**

Disconnect from the logs feed and stop receiving any future events on this emitter.

**Kind**: static method of [`LogSubscription`](#balena.logs.LogSubscription)\
**Summary**: Unsubscribe from device logs\
**Access**: public\
**Example**

```js
logs.unsubscribe();
```

***

**"error"**

**Kind**: event emitted by [`LogSubscription`](#balena.logs.LogSubscription)\
**Summary**: Event fired when an error has occured reading the device logs\
**Example**

```js
logs.on('error', function(error) {
	console.error(error);
});
```

***

**"line"**

**Kind**: event emitted by [`LogSubscription`](#balena.logs.LogSubscription)\
**Summary**: Event fired when a new line of log output is available\
**Example**

```js
logs.on('line', function(line) {
	console.log(line);
});
```

***

### balena.models : `object`

**Kind**: static namespace of [`balena`](#balena)

* [.models](#balena.models) : `object`
  * [.apiKey](#balena.models.apiKey) : `object`
    * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ `Promise`
    * [.getAll(\[options\])](#balena.models.apiKey.getAll) ⇒ `Promise`
    * [.getAllNamedUserApiKeys(\[options\])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ `Promise`
    * [.getDeviceApiKeysByDevice(uuidOrId, \[options\])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ `Promise`
    * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, \[options\])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ `Promise`
    * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ `Promise`
    * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ `Promise`
  * [.application](#balena.models.application) : `object`
    * [.create(options)](#balena.models.application.create) ⇒ `Promise`
    * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ `Promise`
    * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ `Promise`
    * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ `Promise`
    * [.get(slugOrUuidOrId, \[options\], \[context\])](#balena.models.application.get) ⇒ `Promise`
    * [.getAll(\[options\], \[context\])](#balena.models.application.getAll) ⇒ `Promise`
    * [.getAllByOrganization(orgHandleOrId, \[options\])](#balena.models.application.getAllByOrganization) ⇒ `Promise`
    * [.getAllDirectlyAccessible(\[options\])](#balena.models.application.getAllDirectlyAccessible) ⇒ `Promise`
    * [.getAppByName(appName, \[options\], \[context\])](#balena.models.application.getAppByName) ⇒ `Promise`
    * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ `String`
    * [.getDirectlyAccessible(slugOrUuidOrId, \[options\])](#balena.models.application.getDirectlyAccessible) ⇒ `Promise`
    * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ `Promise`
    * [.getWithDeviceServiceDetails(slugOrUuidOrId, \[options\])](#balena.models.application.getWithDeviceServiceDetails) ⇒ `Promise`
    * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ `Promise`
    * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ `Promise`
    * [.hasAny()](#balena.models.application.hasAny) ⇒ `Promise`
    * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ `Promise`
    * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ `Promise`
    * [.purge(appId)](#balena.models.application.purge) ⇒ `Promise`
    * [.reboot(appId, \[options\])](#balena.models.application.reboot) ⇒ `Promise`
    * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ `Promise`
    * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ `Promise`
    * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ `Promise`
    * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ `Promise`
    * [.shutdown(appId, \[options\])](#balena.models.application.shutdown) ⇒ `Promise`
    * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ `Promise`
    * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ `Promise`
    * [.buildVar](#balena.models.application.buildVar) : `object`
      * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.buildVar.getAllByApplication) ⇒ `Promise`
      * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ `Promise`
      * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ `Promise`
    * [.configVar](#balena.models.application.configVar) : `object`
      * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.configVar.getAllByApplication) ⇒ `Promise`
      * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ `Promise`
      * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ `Promise`
    * [.envVar](#balena.models.application.envVar) : `object`
      * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.envVar.getAllByApplication) ⇒ `Promise`
      * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ `Promise`
      * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ `Promise`
    * [.invite](#balena.models.application.invite) : `object`
      * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ `Promise`
      * [.create(slugOrUuidOrId, options, \[message\])](#balena.models.application.invite.create) ⇒ `Promise`
      * [.getAll(\[options\])](#balena.models.application.invite.getAll) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.invite.getAllByApplication) ⇒ `Promise`
      * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ `Promise`
    * [.membership](#balena.models.application.membership) : `object`
      * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ `Promise`
      * [.create(options)](#balena.models.application.membership.create) ⇒ `Promise`
      * [.get(membershipId, \[options\])](#balena.models.application.membership.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.membership.getAllByApplication) ⇒ `Promise`
      * [.getAllByUser(usernameOrId, \[options\])](#balena.models.application.membership.getAllByUser) ⇒ `Promise`
      * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ `Promise`
    * [.tags](#balena.models.application.tags) : `object`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.tags.getAllByApplication) ⇒ `Promise`
      * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ `Promise`
      * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ `Promise`
  * [.billing](#balena.models.billing) : `object`
    * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ `Promise`
    * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ `Promise`
    * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ `Promise`
    * [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ `Promise`
    * [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ `Promise`
    * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ `Promise`
    * [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ `Promise`
    * [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ `Promise`
    * [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo)
    * [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ `Promise`
  * [.config](#balena.models.config) : `object`
    * [.getAll()](#balena.models.config.getAll) ⇒ `Promise`
    * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ `Promise`
    * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ `Promise`
    * [~~.getDeviceTypeManifestBySlug(slugOrName)~~](#balena.models.config.getDeviceTypeManifestBySlug) ~~⇒ `Promise`~~
    * [~~.getDeviceTypes()~~](#balena.models.config.getDeviceTypes) ~~⇒ `Promise`~~
  * [.creditBundle](#balena.models.creditBundle) : `object`
    * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ `Promise`
    * [.getAllByOrg(organization, \[options\])](#balena.models.creditBundle.getAllByOrg) ⇒ `Promise`
  * [.device](#balena.models.device) : `object`
    * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ `Promise`
    * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ `Promise`
    * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ `Promise`
    * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ `Promise`
    * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ `Promise`
    * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ `Promise`
    * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ `Promise`
    * [.generateDeviceKey(uuidOrId, \[keyName\], \[keyDescription\])](#balena.models.device.generateDeviceKey) ⇒ `Promise`
    * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ `String`
    * [.get(uuidOrId, \[options\])](#balena.models.device.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.getAllByApplication) ⇒ `Promise`
    * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.device.getAllByOrganization) ⇒ `Promise`
    * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ `Promise`
    * [.getByName(name)](#balena.models.device.getByName) ⇒ `Promise`
    * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ `String`
    * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ `Promise`
    * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ `Promise`
    * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ `Object`
    * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ `Promise`
    * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ `Promise`
    * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ `Promise`
    * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ `String`
    * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ `Promise`
    * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ `Promise`
    * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ `Promise`
    * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ `Promise`
    * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ `Promise`
    * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ `Promise`
    * [.getWithServiceDetails(uuidOrId, \[options\])](#balena.models.device.getWithServiceDetails) ⇒ `Promise`
    * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ `Promise`
    * [.has(uuidOrId)](#balena.models.device.has) ⇒ `Promise`
    * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ `Promise`
    * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ `Promise`
    * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ `Promise`
    * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ `Promise`
    * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ `Promise`
    * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ `Promise`
    * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ `Promise`
    * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ `Promise`
    * [.pinToOsRelease(uuidOrIdOrArray, osVersionOrId)](#balena.models.device.pinToOsRelease) ⇒ `Promise`
    * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ `Promise`
    * [.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.pinToSupervisorRelease) ⇒ `Promise`
    * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ `Promise`
    * [.reboot(uuidOrId, \[options\])](#balena.models.device.reboot) ⇒ `Promise`
    * [.register(applicationSlugOrUuidOrId, uuid, \[deviceTypeSlug\])](#balena.models.device.register) ⇒ `Promise`
    * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ `Promise`
    * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ `Promise`
    * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ `Promise`
    * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ `Promise`
    * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ `Promise`
    * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ `Promise`
    * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ `Promise`
    * [.shutdown(uuidOrId, \[options\])](#balena.models.device.shutdown) ⇒ `Promise`
    * [.startOsUpdate(uuidOrUuids, targetOsVersion, \[options\])](#balena.models.device.startOsUpdate) ⇒ `Promise`
    * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ `Promise`
    * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ `Promise`
    * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ `Promise`
    * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ `Promise`
    * [.update(uuidOrId, \[options\])](#balena.models.device.update) ⇒ `Promise`
    * [.configVar](#balena.models.device.configVar) : `object`
      * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.configVar.getAllByApplication) ⇒ `Promise`
      * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.configVar.getAllByDevice) ⇒ `Promise`
      * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ `Promise`
      * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ `Promise`
    * [.envVar](#balena.models.device.envVar) : `object`
      * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.envVar.getAllByApplication) ⇒ `Promise`
      * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.envVar.getAllByDevice) ⇒ `Promise`
      * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ `Promise`
      * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ `Promise`
    * [.history](#balena.models.device.history) : `object`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.history.getAllByApplication) ⇒ `Promise`
      * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.history.getAllByDevice) ⇒ `Promise`
    * [.serviceVar](#balena.models.device.serviceVar) : `object`
      * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.serviceVar.getAllByApplication) ⇒ `Promise`
      * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.serviceVar.getAllByDevice) ⇒ `Promise`
      * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ `Promise`
      * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ `Promise`
    * [.tags](#balena.models.device.tags) : `object`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.tags.getAllByApplication) ⇒ `Promise`
      * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.tags.getAllByDevice) ⇒ `Promise`
      * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ `Promise`
      * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ `Promise`
  * [.deviceType](#balena.models.deviceType) : `object`
    * [.get(idOrSlug, \[options\])](#balena.models.deviceType.get) ⇒ `Promise`
    * [.getAll(\[options\])](#balena.models.deviceType.getAll) ⇒ `Promise`
    * [.getAllSupported(\[options\])](#balena.models.deviceType.getAllSupported) ⇒ `Promise`
    * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ `Promise`
    * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ `Promise`
    * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ `Promise`
    * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ `Promise`
    * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ `Promise`
    * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ `Promise`
  * [.image](#balena.models.image) : `object`
    * [.get(id, \[options\])](#balena.models.image.get) ⇒ `Promise`
    * [.getLogs(id)](#balena.models.image.getLogs) ⇒ `Promise`
  * [.key](#balena.models.key) : `object`
    * [.create(title, key)](#balena.models.key.create) ⇒ `Promise`
    * [.get(id)](#balena.models.key.get) ⇒ `Promise`
    * [.getAll(\[options\])](#balena.models.key.getAll) ⇒ `Promise`
    * [.remove(id)](#balena.models.key.remove) ⇒ `Promise`
  * [.organization](#balena.models.organization) : `object`
    * [.create(options)](#balena.models.organization.create) ⇒ `Promise`
    * [.get(handleOrId, \[options\])](#balena.models.organization.get) ⇒ `Promise`
    * [.getAll(\[options\])](#balena.models.organization.getAll) ⇒ `Promise`
    * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ `Promise`
    * [.invite](#balena.models.organization.invite) : `object`
      * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ `Promise`
      * [.create(handleOrId, options, \[message\])](#balena.models.organization.invite.create) ⇒ `Promise`
      * [.getAll(\[options\])](#balena.models.organization.invite.getAll) ⇒ `Promise`
      * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.organization.invite.getAllByOrganization) ⇒ `Promise`
      * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ `Promise`
    * [.membership](#balena.models.organization.membership) : `object`
      * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ `Promise`
      * [.get(membershipId, \[options\])](#balena.models.organization.membership.get) ⇒ `Promise`
      * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.organization.membership.getAllByOrganization) ⇒ `Promise`
      * [.getAllByUser(usernameOrId, \[options\])](#balena.models.organization.membership.getAllByUser) ⇒ `Promise`
      * [.remove(id)](#balena.models.organization.membership.remove) ⇒ `Promise`
  * [.os](#balena.models.os) : `object`
    * [.download(options)](#balena.models.os.download) ⇒ `Promise`
    * [.getAllOsVersions(deviceTypes, \[options\])](#balena.models.os.getAllOsVersions) ⇒ `Promise`
    * [.getAvailableOsVersions(deviceTypes, \[pineOptions\], \[extraOptions\])](#balena.models.os.getAvailableOsVersions) ⇒ `Promise`
    * [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ `Promise`
    * [.getDownloadSize(deviceType, \[version\])](#balena.models.os.getDownloadSize) ⇒ `Promise`
    * [.getMaxSatisfyingVersion(deviceType, versionOrRange, \[osType\])](#balena.models.os.getMaxSatisfyingVersion) ⇒ `Promise`
    * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ `Promise`
    * [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, \[options\])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ `Promise.<String>`
    * [.getSupportedOsUpdateVersions(deviceType, currentVersion, \[options\])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ `Promise`
    * [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ `Boolean`
    * [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ `Promise`
  * [.release](#balena.models.release) : `object`
    * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ `Promise`
    * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ `Promise`
    * [.get(commitOrIdOrRawVersion, \[options\])](#balena.models.release.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.getAllByApplication) ⇒ `Promise`
    * [.getLatestByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.getLatestByApplication) ⇒ `Promise`
    * [.getWithImageDetails(commitOrIdOrRawVersion, \[options\])](#balena.models.release.getWithImageDetails) ⇒ `Promise`
    * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ `Promise`
    * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ `Promise`
    * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ `Promise`
    * [.asset](#balena.models.release.asset) : `object`
      * [.download(id)](#balena.models.release.asset.download) ⇒ `Promise`
      * [.get(id, \[options\])](#balena.models.release.asset.get) ⇒ `Promise`
      * [.getAllByRelease(commitOrIdOrRawVersion, \[options\])](#balena.models.release.asset.getAllByRelease) ⇒ `Promise`
      * [.remove(id)](#balena.models.release.asset.remove) ⇒ `Promise`
      * [.upload(uploadParams, \[options\])](#balena.models.release.asset.upload) ⇒ `Promise`
    * [.tags](#balena.models.release.tags) : `object`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.tags.getAllByApplication) ⇒ `Promise`
      * [.getAllByRelease(commitOrIdOrRawVersion, \[options\])](#balena.models.release.tags.getAllByRelease) ⇒ `Promise`
      * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ `Promise`
      * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ `Promise`
  * [.service](#balena.models.service) : `object`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.service.getAllByApplication) ⇒ `Promise`
    * [.var](#balena.models.service.var) : `object`
      * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ `Promise`
      * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.service.var.getAllByApplication) ⇒ `Promise`
      * [.getAllByService(serviceIdOrNaturalKey, \[options\])](#balena.models.service.var.getAllByService) ⇒ `Promise`
      * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ `Promise`
      * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ `Promise`
  * [.team](#balena.models.team) : `object`
    * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ `Promise`
    * [.get(teamId, \[options\])](#balena.models.team.get) ⇒ `Promise`
    * [.getAllByOrganization(organizationSlugOrId, \[options\])](#balena.models.team.getAllByOrganization) ⇒ `Promise`
    * [.remove(teamId)](#balena.models.team.remove) ⇒ `Promise`
    * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ `Promise`
    * [.applicationAccess](#balena.models.team.applicationAccess) : `object`
      * [.get(teamApplicationAccessId, \[options\])](#balena.models.team.applicationAccess.get) ⇒ `Promise`
      * [.getAllByTeam(teamId, \[options\])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ `Promise`
      * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ `Promise`
      * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ `Promise`

***

#### models.apiKey : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.apiKey](#balena.models.apiKey) : `object`
  * [.create(createApiKeyParams)](#balena.models.apiKey.create) ⇒ `Promise`
  * [.getAll(\[options\])](#balena.models.apiKey.getAll) ⇒ `Promise`
  * [.getAllNamedUserApiKeys(\[options\])](#balena.models.apiKey.getAllNamedUserApiKeys) ⇒ `Promise`
  * [.getDeviceApiKeysByDevice(uuidOrId, \[options\])](#balena.models.apiKey.getDeviceApiKeysByDevice) ⇒ `Promise`
  * [.getProvisioningApiKeysByApplication(slugOrUuidOrId, \[options\])](#balena.models.apiKey.getProvisioningApiKeysByApplication) ⇒ `Promise`
  * [.revoke(id)](#balena.models.apiKey.revoke) ⇒ `Promise`
  * [.update(id, apiKeyInfo)](#balena.models.apiKey.update) ⇒ `Promise`

***

**apiKey.create(createApiKeyParams) ⇒ `Promise`**

This method registers a new api key for the current user with the name given.

**Kind**: static method of [`apiKey`](#balena.models.apiKey)\
**Summary**: Creates a new user API key\
**Access**: public\
**Fulfil**: `String` - API key

| Param                             | Type     | Default | Description                                                        |
| --------------------------------- | -------- | ------- | ------------------------------------------------------------------ |
| createApiKeyParams                | `Object` |         | an object containing the parameters for the creation of an API key |
| createApiKeyParams.name           | `String` |         | the API key name                                                   |
| createApiKeyParams.expiryDate     | `String` |         | the API key expiry date                                            |
| \[createApiKeyParams.description] | `String` |         | the API key description                                            |

**Example**

```js
balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12}).then(function(apiKey) {
	console.log(apiKey);
});
```

**Example**

```js
balena.models.apiKey.create({name: apiKeyName, expiryDate: 2030-10-12, description: apiKeyDescription}).then(function(apiKey) {
	console.log(apiKey);
});
```

***

**apiKey.getAll(\[options]) ⇒ `Promise`**

**Kind**: static method of [`apiKey`](#balena.models.apiKey)\
**Summary**: Get all accessible API keys\
**Access**: public\
**Fulfil**: `Object[]` - apiKeys

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.apiKey.getAll().then(function(apiKeys) {
	console.log(apiKeys);
});
```

***

**apiKey.getAllNamedUserApiKeys(\[options]) ⇒ `Promise`**

**Kind**: static method of [`apiKey`](#balena.models.apiKey)\
**Summary**: Get all named user API keys of the current user\
**Access**: public\
**Fulfil**: `Object[]` - apiKeys

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.apiKey.getAllNamedUserApiKeys().then(function(apiKeys) {
	console.log(apiKeys);
});
```

***

**apiKey.getDeviceApiKeysByDevice(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`apiKey`](#balena.models.apiKey)\
**Summary**: Get all API keys for a device\
**Access**: public\
**Fulfil**: `Object[]` - apiKeys

| Param      | Type                 | Default | Description                          |
| ---------- | -------------------- | ------- | ------------------------------------ |
| uuidOrId   | `String` \| `Number` |         | device, uuid (string) or id (number) |
| \[options] | `Object`             | `{}`    | extra pine options to use            |

**Example**

```js
balena.models.apiKey.getDeviceApiKeysByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(apiKeys) {
	console.log(apiKeys);
});
```

***

**apiKey.getProvisioningApiKeysByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`apiKey`](#balena.models.apiKey)\
**Summary**: Get all provisioning API keys for an application\
**Access**: public\
**Fulfil**: `Object[]` - apiKeys

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.apiKey.getProvisioningApiKeysByApplication('myorganization/myapp').then(function(apiKeys) {
	console.log(apiKeys);
});
```

***

**apiKey.revoke(id) ⇒ `Promise`**

**Kind**: static method of [`apiKey`](#balena.models.apiKey)\
**Summary**: Revoke an API key\
**Access**: public

| Param | Type     | Description |
| ----- | -------- | ----------- |
| id    | `Number` | API key id  |

**Example**

```js
balena.models.apiKey.revoke(123);
```

***

**apiKey.update(id, apiKeyInfo) ⇒ `Promise`**

**Kind**: static method of [`apiKey`](#balena.models.apiKey)\
**Summary**: Update the details of an API key\
**Access**: public

| Param      | Type     | Description                                              |
| ---------- | -------- | -------------------------------------------------------- |
| id         | `Number` | API key id                                               |
| apiKeyInfo | `Object` | an object with the updated name\|description\|expiryDate |

**Example**

```js
balena.models.apiKey.update(123, { name: 'updatedName' });
```

**Example**

```js
balena.models.apiKey.update(123, { description: 'updated description' });
```

**Example**

```js
balena.models.apiKey.update(123, { expiryDate: '2022-04-29' });
```

**Example**

```js
balena.models.apiKey.update(123, { name: 'updatedName', description: 'updated description' });
```

***

#### models.application : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.application](#balena.models.application) : `object`
  * [.create(options)](#balena.models.application.create) ⇒ `Promise`
  * [.disableDeviceUrls(slugOrUuidOrId)](#balena.models.application.disableDeviceUrls) ⇒ `Promise`
  * [.enableDeviceUrls(slugOrUuidOrId)](#balena.models.application.enableDeviceUrls) ⇒ `Promise`
  * [.generateProvisioningKey(generateProvisioningKeyParams)](#balena.models.application.generateProvisioningKey) ⇒ `Promise`
  * [.get(slugOrUuidOrId, \[options\], \[context\])](#balena.models.application.get) ⇒ `Promise`
  * [.getAll(\[options\], \[context\])](#balena.models.application.getAll) ⇒ `Promise`
  * [.getAllByOrganization(orgHandleOrId, \[options\])](#balena.models.application.getAllByOrganization) ⇒ `Promise`
  * [.getAllDirectlyAccessible(\[options\])](#balena.models.application.getAllDirectlyAccessible) ⇒ `Promise`
  * [.getAppByName(appName, \[options\], \[context\])](#balena.models.application.getAppByName) ⇒ `Promise`
  * [.getDashboardUrl(id)](#balena.models.application.getDashboardUrl) ⇒ `String`
  * [.getDirectlyAccessible(slugOrUuidOrId, \[options\])](#balena.models.application.getDirectlyAccessible) ⇒ `Promise`
  * [.getTargetReleaseHash(slugOrUuidOrId)](#balena.models.application.getTargetReleaseHash) ⇒ `Promise`
  * [.getWithDeviceServiceDetails(slugOrUuidOrId, \[options\])](#balena.models.application.getWithDeviceServiceDetails) ⇒ `Promise`
  * [.grantSupportAccess(slugOrUuidOrId, expiryTimestamp)](#balena.models.application.grantSupportAccess) ⇒ `Promise`
  * [.has(slugOrUuidOrId)](#balena.models.application.has) ⇒ `Promise`
  * [.hasAny()](#balena.models.application.hasAny) ⇒ `Promise`
  * [.isTrackingLatestRelease(slugOrUuidOrId)](#balena.models.application.isTrackingLatestRelease) ⇒ `Promise`
  * [.pinToRelease(slugOrUuidOrId, fullReleaseHash)](#balena.models.application.pinToRelease) ⇒ `Promise`
  * [.purge(appId)](#balena.models.application.purge) ⇒ `Promise`
  * [.reboot(appId, \[options\])](#balena.models.application.reboot) ⇒ `Promise`
  * [.remove(slugOrUuidOrIdOrIds)](#balena.models.application.remove) ⇒ `Promise`
  * [.rename(slugOrUuidOrId, newName)](#balena.models.application.rename) ⇒ `Promise`
  * [.restart(slugOrUuidOrId)](#balena.models.application.restart) ⇒ `Promise`
  * [.revokeSupportAccess(slugOrUuidOrId)](#balena.models.application.revokeSupportAccess) ⇒ `Promise`
  * [.shutdown(appId, \[options\])](#balena.models.application.shutdown) ⇒ `Promise`
  * [.trackLatestRelease(slugOrUuidOrId)](#balena.models.application.trackLatestRelease) ⇒ `Promise`
  * [.willTrackNewReleases(slugOrUuidOrId)](#balena.models.application.willTrackNewReleases) ⇒ `Promise`
  * [.buildVar](#balena.models.application.buildVar) : `object`
    * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.buildVar.getAllByApplication) ⇒ `Promise`
    * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ `Promise`
    * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ `Promise`
  * [.configVar](#balena.models.application.configVar) : `object`
    * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.configVar.getAllByApplication) ⇒ `Promise`
    * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ `Promise`
    * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ `Promise`
  * [.envVar](#balena.models.application.envVar) : `object`
    * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.envVar.getAllByApplication) ⇒ `Promise`
    * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ `Promise`
    * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ `Promise`
  * [.invite](#balena.models.application.invite) : `object`
    * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ `Promise`
    * [.create(slugOrUuidOrId, options, \[message\])](#balena.models.application.invite.create) ⇒ `Promise`
    * [.getAll(\[options\])](#balena.models.application.invite.getAll) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.invite.getAllByApplication) ⇒ `Promise`
    * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ `Promise`
  * [.membership](#balena.models.application.membership) : `object`
    * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ `Promise`
    * [.create(options)](#balena.models.application.membership.create) ⇒ `Promise`
    * [.get(membershipId, \[options\])](#balena.models.application.membership.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.membership.getAllByApplication) ⇒ `Promise`
    * [.getAllByUser(usernameOrId, \[options\])](#balena.models.application.membership.getAllByUser) ⇒ `Promise`
    * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ `Promise`
  * [.tags](#balena.models.application.tags) : `object`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.tags.getAllByApplication) ⇒ `Promise`
    * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ `Promise`
    * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ `Promise`

***

**application.create(options) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Create an application\
**Access**: public\
**Fulfil**: `Object` - application

| Param                       | Type                 | Description                                                                                    |
| --------------------------- | -------------------- | ---------------------------------------------------------------------------------------------- |
| options                     | `Object`             | application creation parameters                                                                |
| options.name                | `String`             | application name                                                                               |
| options.organization        | `String` \| `Number` | handle (string) or id (number) of the organization that the application will belong to or null |
| \[options.uuid]             | `String`             | application uuid                                                                               |
| \[options.applicationClass] | `String`             | application class: 'app' \| 'fleet' \| 'block'                                                 |
| options.deviceType          | `String`             | device type slug                                                                               |

**Example**

```js
balena.models.application.create({ name: 'My App', organization: 'myorganization', deviceType: 'raspberry-pi' }).then(function(application) {
	console.log(application);
});
```

**Example**

```js
balena.models.application.create({ name: 'My Block', organization: 'myorganization', applicationClass: 'block', deviceType: 'raspberry-pi' }).then(function(application) {
	console.log(application);
});
```

***

**application.disableDeviceUrls(slugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Disable device urls for all devices that belong to an application\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.disableDeviceUrls('myorganization/myapp');
```

**Example**

```js
balena.models.application.disableDeviceUrls(123);
```

***

**application.enableDeviceUrls(slugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Enable device urls for all devices that belong to an application\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.enableDeviceUrls('myorganization/myapp');
```

**Example**

```js
balena.models.application.enableDeviceUrls(123);
```

***

**application.generateProvisioningKey(generateProvisioningKeyParams) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Generate a device provisioning key for a specific application\
**Access**: public\
**Fulfil**: `String` - device provisioning key

| Param                                           | Type                 | Description                                                             |
| ----------------------------------------------- | -------------------- | ----------------------------------------------------------------------- |
| generateProvisioningKeyParams                   | `Object`             | an object containing the parameters for the provisioning key generation |
| generateProvisioningKeyParams.slugOrUuidOrId    | `String` \| `Number` | application slug (string), uuid (string) or id (number)                 |
| generateProvisioningKeyParams.keyExpiryDate     | `String`             | Expiry Date for provisioning key                                        |
| \[generateProvisioningKeyParams.keyName]        | `String`             | Provisioning key name                                                   |
| \[generateProvisioningKeyParams.keyDescription] | `String`             | Description for provisioning key                                        |

**Example**

```js
balena.models.application.generateProvisioningKey({slugOrUuidOrId: 'myorganization/myapp', keyExpiryDate: '2030-10-12'}).then(function(key) {
	console.log(key);
});
```

**Example**

```js
balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12'}).then(function(key) {
	console.log(key);
});
```

**Example**

```js
balena.models.application.generateProvisioningKey({slugOrUuidOrId: 123, keyExpiryDate: '2030-10-12', keyName: 'api key name', keyDescription: 'api key long description'}).then(function(key) {
	console.log(key);
});
```

***

**application.get(slugOrUuidOrId, \[options], \[context]) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get a single application\
**Access**: public\
**Fulfil**: `Object` - application

| Param          | Type                 | Default | Description                                               |
| -------------- | -------------------- | ------- | --------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number)   |
| \[options]     | `Object`             | `{}`    | extra pine options to use                                 |
| \[context]     | `String`             |         | extra access filters, undefined or 'directly\_accessible' |

**Example**

```js
balena.models.application.get('myorganization/myapp').then(function(application) {
	console.log(application);
});
```

**Example**

```js
balena.models.application.get('1bf99a68cf9e4266986e6dec7a6e8f46').then(function(application) {
	console.log(application);
});
```

**Example**

```js
balena.models.application.get(123).then(function(application) {
	console.log(application);
});
```

***

**application.getAll(\[options], \[context]) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get all applications\
**Access**: public\
**Fulfil**: `Object[]` - applications

| Param      | Type     | Default | Description                                               |
| ---------- | -------- | ------- | --------------------------------------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use                                 |
| \[context] | `String` |         | extra access filters, undefined or 'directly\_accessible' |

**Example**

```js
balena.models.application.getAll().then(function(applications) {
	console.log(applications);
});
```

***

**application.getAllByOrganization(orgHandleOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get all applications of an organization\
**Access**: public\
**Fulfil**: `Object[]` - applications

| Param         | Type                 | Default | Description                                 |
| ------------- | -------------------- | ------- | ------------------------------------------- |
| orgHandleOrId | `Number` \| `String` |         | organization handle (string) or id (number) |
| \[options]    | `Object`             | `{}`    | extra pine options to use                   |

**Example**

```js
balena.models.application.getAllByOrganization('myorganization').then(function(applications) {
	console.log(applications);
});
```

**Example**

```js
const applications = await sdk.models.application.getAllByOrganization('myorganization', {
		$select: ['app_name', 'slug'],
		$expand: {
			owns__device: {
				$select: ['uuid', 'overall_status', 'is_connected_to_vpn', 'api_heartbeat_state'],
			},
		},
	});
```

***

**application.getAllDirectlyAccessible(\[options]) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get all applications directly accessible by the user\
**Access**: public\
**Fulfil**: `Object[]` - applications

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.application.getAllDirectlyAccessible().then(function(applications) {
	console.log(applications);
});
```

***

**application.getAppByName(appName, \[options], \[context]) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get a single application using the appname and the handle of the owning organization\
**Access**: public\
**Fulfil**: `Object` - application

| Param      | Type     | Default | Description                                               |
| ---------- | -------- | ------- | --------------------------------------------------------- |
| appName    | `String` |         | application name                                          |
| \[options] | `Object` | `{}`    | extra pine options to use                                 |
| \[context] | `String` |         | extra access filters, undefined or 'directly\_accessible' |

**Example**

```js
balena.models.application.getAppByName('MyApp').then(function(application) {
	console.log(application);
});
```

***

**application.getDashboardUrl(id) ⇒ `String`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get Dashboard URL for a specific application\
**Returns**: `String` - - Dashboard URL for the specific application\
**Throws**:

* Exception if the id is not a finite number

| Param | Type     | Description    |
| ----- | -------- | -------------- |
| id    | `Number` | Application id |

**Example**

```js
balena.models.application.get('myorganization/myapp').then(function(application) {
	const dashboardApplicationUrl = balena.models.application.getDashboardUrl(application.id);
	console.log(dashboardApplicationUrl);
});
```

***

**application.getDirectlyAccessible(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get a single application directly accessible by the user\
**Access**: public\
**Fulfil**: `Object` - application

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.application.getDirectlyAccessible('myorganization/myapp').then(function(application) {
	console.log(application);
});
```

**Example**

```js
balena.models.application.getDirectlyAccessible(123).then(function(application) {
	console.log(application);
});
```

***

**application.getTargetReleaseHash(slugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get the hash of the current release for a specific application\
**Access**: public\
**Fulfil**: `String|undefined` - The release hash of the current release

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.getTargetReleaseHash('myorganization/myapp').then(function(release) {
	console.log(release);
});
```

**Example**

```js
balena.models.application.getTargetReleaseHash(123).then(function(release) {
	console.log(release);
});
```

**Example**

```js
balena.models.application.getTargetReleaseHash('myorganization/myapp', function(release) {
	console.log(release);
});
```

***

**application.getWithDeviceServiceDetails(slugOrUuidOrId, \[options]) ⇒ `Promise`**

This method does not map exactly to the underlying model: it runs a larger prebuilt query, and reformats it into an easy to use and understand format. If you want more control, or to see the raw model directly, use `application.get(uuidOrId, options)` instead.

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get a single application and its devices, along with each device's associated services' essential details\
**Access**: public\
**Fulfil**: `Object` - application

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.application.getWithDeviceServiceDetails('myorganization/myapp').then(function(device) {
	console.log(device);
})
```

**Example**

```js
balena.models.application.getWithDeviceServiceDetails(123).then(function(device) {
	console.log(device);
})
```

***

**application.grantSupportAccess(slugOrUuidOrId, expiryTimestamp) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Grant support access to an application until a specified time\
**Access**: public

| Param           | Type                 | Description                                               |
| --------------- | -------------------- | --------------------------------------------------------- |
| slugOrUuidOrId  | `String` \| `Number` | application slug (string), uuid (string) or id (number)   |
| expiryTimestamp | `Number`             | a timestamp in ms for when the support access will expire |

**Example**

```js
balena.models.application.grantSupportAccess('myorganization/myapp', Date.now() + 3600 * 1000);
```

**Example**

```js
balena.models.application.grantSupportAccess(123, Date.now() + 3600 * 1000);
```

***

**application.has(slugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Check if an application exists\
**Access**: public\
**Fulfil**: `Boolean` - has application

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.has('myorganization/myapp').then(function(hasApp) {
	console.log(hasApp);
});
```

**Example**

```js
balena.models.application.has(123).then(function(hasApp) {
	console.log(hasApp);
});
```

***

**application.hasAny() ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Check if the user has access to any applications\
**Access**: public\
**Fulfil**: `Boolean` - has any applications\
**Example**

```js
balena.models.application.hasAny().then(function(hasAny) {
	console.log('Has any?', hasAny);
});
```

***

**application.isTrackingLatestRelease(slugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get whether the application is up to date and is tracking the latest finalized release for updates\
**Access**: public\
**Fulfil**: `Boolean` - is tracking the latest release

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.isTrackingLatestRelease('myorganization/myapp').then(function(isEnabled) {
	console.log(isEnabled);
});
```

**Example**

```js
balena.models.application.isTrackingLatestRelease(123).then(function(isEnabled) {
	console.log(isEnabled);
});
```

***

**application.pinToRelease(slugOrUuidOrId, fullReleaseHash) ⇒ `Promise`**

Configures the application to run a particular release and not get updated when the latest release changes.

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Set a specific application to run a particular release\
**Access**: public

| Param           | Type                 | Description                                             |
| --------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId  | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| fullReleaseHash | `String`             | the hash of a successful release (string)               |

**Example**

```js
balena.models.application.pinToRelease('myorganization/myapp', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() {
	...
});
```

**Example**

```js
balena.models.application.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() {
	...
});
```

***

**application.purge(appId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Purge devices by application id\
**Access**: public

| Param | Type     | Description    |
| ----- | -------- | -------------- |
| appId | `Number` | application id |

**Example**

```js
balena.models.application.purge(123);
```

***

**application.reboot(appId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Reboot devices by application id\
**Access**: public

| Param            | Type      | Default | Description          |
| ---------------- | --------- | ------- | -------------------- |
| appId            | `Number`  |         | application id       |
| \[options]       | `Object`  |         | options              |
| \[options.force] | `Boolean` | `false` | override update lock |

**Example**

```js
balena.models.application.reboot(123);
```

***

**application.remove(slugOrUuidOrIdOrIds) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Remove application\
**Access**: public

| Param               | Type                                     | Description                                                             |
| ------------------- | ---------------------------------------- | ----------------------------------------------------------------------- |
| slugOrUuidOrIdOrIds | `String` \| `Number` \| `Array.<Number>` | application slug (string), uuid (string) or id (number) or array of ids |

**Example**

```js
balena.models.application.remove('myorganization/myapp');
```

**Example**

```js
balena.models.application.remove(123);
```

***

**application.rename(slugOrUuidOrId, newName) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Rename application\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| newName        | `String`             | new application name (string)                           |

**Example**

```js
balena.models.application.rename('myorganization/myapp', 'MyRenamedApp');
```

**Example**

```js
balena.models.application.rename(123, 'MyRenamedApp');
```

***

**application.restart(slugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Restart application\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.restart('myorganization/myapp');
```

**Example**

```js
balena.models.application.restart(123);
```

***

**application.revokeSupportAccess(slugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Revoke support access to an application\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.revokeSupportAccess('myorganization/myapp');
```

**Example**

```js
balena.models.application.revokeSupportAccess(123);
```

***

**application.shutdown(appId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Shutdown devices by application id\
**Access**: public

| Param            | Type      | Default | Description          |
| ---------------- | --------- | ------- | -------------------- |
| appId            | `Number`  |         | application id       |
| \[options]       | `Object`  |         | options              |
| \[options.force] | `Boolean` | `false` | override update lock |

**Example**

```js
balena.models.application.shutdown(123);
```

***

**application.trackLatestRelease(slugOrUuidOrId) ⇒ `Promise`**

The application's current release will be updated with each new successfully built release.

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Configure a specific application to track the latest finalized available release\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.trackLatestRelease('myorganization/myapp').then(function() {
	...
});
```

**Example**

```js
balena.models.application.trackLatestRelease(123).then(function() {
	...
});
```

***

**application.willTrackNewReleases(slugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`application`](#balena.models.application)\
**Summary**: Get whether the application is configured to receive updates whenever a new release is available\
**Access**: public\
**Fulfil**: `Boolean` - is tracking the latest release

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |

**Example**

```js
balena.models.application.willTrackNewReleases('myorganization/myapp').then(function(isEnabled) {
	console.log(isEnabled);
});
```

**Example**

```js
balena.models.application.willTrackNewReleases(123).then(function(isEnabled) {
	console.log(isEnabled);
});
```

***

**application.buildVar : `object`**

**Kind**: static namespace of [`application`](#balena.models.application)

* [.buildVar](#balena.models.application.buildVar) : `object`
  * [.get(slugOrUuidOrId, key)](#balena.models.application.buildVar.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.buildVar.getAllByApplication) ⇒ `Promise`
  * [.remove(slugOrUuidOrId, key)](#balena.models.application.buildVar.remove) ⇒ `Promise`
  * [.set(slugOrUuidOrId, key, value)](#balena.models.application.buildVar.set) ⇒ `Promise`

***

**buildVar.get(slugOrUuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`buildVar`](#balena.models.application.buildVar)\
**Summary**: Get the value of a specific build environment variable\
**Access**: public\
**Fulfil**: `String|undefined` - the build environment variable value (or undefined)

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | build environment variable name                         |

**Example**

```js
balena.models.application.buildVar.get('myorganization/myapp', 'VAR').then(function(value) {
	console.log(value);
});
```

**Example**

```js
balena.models.application.buildVar.get(999999, 'VAR').then(function(value) {
	console.log(value);
});
```

***

**buildVar.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`buildVar`](#balena.models.application.buildVar)\
**Summary**: Get all build environment variables for an application\
**Access**: public\
**Fulfil**: `Object[]` - application build environment variables

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.application.buildVar.getAllByApplication('myorganization/myapp').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.application.buildVar.getAllByApplication(999999).then(function(vars) {
	console.log(vars);
});
```

***

**buildVar.remove(slugOrUuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`buildVar`](#balena.models.application.buildVar)\
**Summary**: Clear the value of a specific build environment variable\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | build environment variable name                         |

**Example**

```js
balena.models.application.buildVar.remove('myorganization/myapp', 'VAR').then(function() {
	...
});
```

**Example**

```js
balena.models.application.buildVar.remove(999999, 'VAR').then(function() {
	...
});
```

***

**buildVar.set(slugOrUuidOrId, key, value) ⇒ `Promise`**

**Kind**: static method of [`buildVar`](#balena.models.application.buildVar)\
**Summary**: Set the value of a specific build environment variable\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | build environment variable name                         |
| value          | `String`             | build environment variable value                        |

**Example**

```js
balena.models.application.buildVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() {
	...
});
```

**Example**

```js
balena.models.application.buildVar.set(999999, 'VAR', 'newvalue').then(function() {
	...
});
```

***

**application.configVar : `object`**

**Kind**: static namespace of [`application`](#balena.models.application)

* [.configVar](#balena.models.application.configVar) : `object`
  * [.get(slugOrUuidOrId, key)](#balena.models.application.configVar.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.configVar.getAllByApplication) ⇒ `Promise`
  * [.remove(slugOrUuidOrId, key)](#balena.models.application.configVar.remove) ⇒ `Promise`
  * [.set(slugOrUuidOrId, key, value)](#balena.models.application.configVar.set) ⇒ `Promise`

***

**configVar.get(slugOrUuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.application.configVar)\
**Summary**: Get the value of a specific config variable\
**Access**: public\
**Fulfil**: `String|undefined` - the config variable value (or undefined)

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | config variable name                                    |

**Example**

```js
balena.models.application.configVar.get('myorganization/myapp', 'BALENA_VAR').then(function(value) {
	console.log(value);
});
```

**Example**

```js
balena.models.application.configVar.get(999999, 'BALENA_VAR').then(function(value) {
	console.log(value);
});
```

***

**configVar.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.application.configVar)\
**Summary**: Get all config variables for an application\
**Access**: public\
**Fulfil**: `Object[]` - application config variables

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.application.configVar.getAllByApplication('myorganization/myapp').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.application.configVar.getAllByApplication(999999).then(function(vars) {
	console.log(vars);
});
```

***

**configVar.remove(slugOrUuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.application.configVar)\
**Summary**: Clear the value of a specific config variable\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | config variable name                                    |

**Example**

```js
balena.models.application.configVar.remove('myorganization/myapp', 'BALENA_VAR').then(function() {
	...
});
```

**Example**

```js
balena.models.application.configVar.remove(999999, 'BALENA_VAR').then(function() {
	...
});
```

***

**configVar.set(slugOrUuidOrId, key, value) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.application.configVar)\
**Summary**: Set the value of a specific config variable\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | config variable name                                    |
| value          | `String`             | config variable value                                   |

**Example**

```js
balena.models.application.configVar.set('myorganization/myapp', 'BALENA_VAR', 'newvalue').then(function() {
	...
});
```

**Example**

```js
balena.models.application.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() {
	...
});
```

***

**application.envVar : `object`**

**Kind**: static namespace of [`application`](#balena.models.application)

* [.envVar](#balena.models.application.envVar) : `object`
  * [.get(slugOrUuidOrId, key)](#balena.models.application.envVar.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.envVar.getAllByApplication) ⇒ `Promise`
  * [.remove(slugOrUuidOrId, key)](#balena.models.application.envVar.remove) ⇒ `Promise`
  * [.set(slugOrUuidOrId, key, value)](#balena.models.application.envVar.set) ⇒ `Promise`

***

**envVar.get(slugOrUuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.application.envVar)\
**Summary**: Get the value of a specific environment variable\
**Access**: public\
**Fulfil**: `String|undefined` - the environment variable value (or undefined)

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | environment variable name                               |

**Example**

```js
balena.models.application.envVar.get('myorganization/myapp', 'VAR').then(function(value) {
	console.log(value);
});
```

**Example**

```js
balena.models.application.envVar.get(999999, 'VAR').then(function(value) {
	console.log(value);
});
```

***

**envVar.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.application.envVar)\
**Summary**: Get all environment variables for an application\
**Access**: public\
**Fulfil**: `Object[]` - application environment variables

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.application.envVar.getAllByApplication('myorganization/myapp').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.application.envVar.getAllByApplication(999999).then(function(vars) {
	console.log(vars);
});
```

***

**envVar.remove(slugOrUuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.application.envVar)\
**Summary**: Clear the value of a specific environment variable\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | environment variable name                               |

**Example**

```js
balena.models.application.envVar.remove('myorganization/myapp', 'VAR').then(function() {
	...
});
```

**Example**

```js
balena.models.application.envVar.remove(999999, 'VAR').then(function() {
	...
});
```

***

**envVar.set(slugOrUuidOrId, key, value) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.application.envVar)\
**Summary**: Set the value of a specific environment variable\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| key            | `String`             | environment variable name                               |
| value          | `String`             | environment variable value                              |

**Example**

```js
balena.models.application.envVar.set('myorganization/myapp', 'VAR', 'newvalue').then(function() {
	...
});
```

**Example**

```js
balena.models.application.envVar.set(999999, 'VAR', 'newvalue').then(function() {
	...
});
```

***

**application.invite : `object`**

**Kind**: static namespace of [`application`](#balena.models.application)

* [.invite](#balena.models.application.invite) : `object`
  * [.accept(invitationToken)](#balena.models.application.invite.accept) ⇒ `Promise`
  * [.create(slugOrUuidOrId, options, \[message\])](#balena.models.application.invite.create) ⇒ `Promise`
  * [.getAll(\[options\])](#balena.models.application.invite.getAll) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.invite.getAllByApplication) ⇒ `Promise`
  * [.revoke(id)](#balena.models.application.invite.revoke) ⇒ `Promise`

***

**invite.accept(invitationToken) ⇒ `Promise`**

This method adds the calling user to the application.

**Kind**: static method of [`invite`](#balena.models.application.invite)\
**Summary**: Accepts an invite\
**Access**: public

| Param           | Type     | Description  |
| --------------- | -------- | ------------ |
| invitationToken | `String` | invite token |

**Example**

```js
balena.models.application.invite.accept("qwerty-invitation-token");
```

***

**invite.create(slugOrUuidOrId, options, \[message]) ⇒ `Promise`**

This method invites a user by their email to an application.

**Kind**: static method of [`invite`](#balena.models.application.invite)\
**Summary**: Creates a new invite for an application\
**Access**: public\
**Fulfil**: `String` - application invite

| Param               | Type                 | Default       | Description                                             |
| ------------------- | -------------------- | ------------- | ------------------------------------------------------- |
| slugOrUuidOrId      | `String` \| `Number` |               | application slug (string), uuid (string) or id (number) |
| options             | `Object`             |               | invite creation parameters                              |
| options.invitee     | `String`             |               | the email of the invitee                                |
| \[options.roleName] | `String`             | `"developer"` | the role name to be granted to the invitee              |
| \[message]          | `String`             |               | the message to send along with the invite               |

**Example**

```js
balena.models.application.invite.create('myorganization/myapp', { invitee: "invitee@example.org", roleName: "developer", message: "join my app" }).then(function(invite) {
	console.log(invite);
});
```

***

**invite.getAll(\[options]) ⇒ `Promise`**

This method returns all invites.

**Kind**: static method of [`invite`](#balena.models.application.invite)\
**Summary**: Get all invites\
**Access**: public\
**Fulfil**: `Object[]` - invites

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.application.invite.getAll().then(function(invites) {
	console.log(invites);
});
```

***

**invite.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

This method returns all invites for a specific application.

**Kind**: static method of [`invite`](#balena.models.application.invite)\
**Summary**: Get all invites by application\
**Access**: public\
**Fulfil**: `Object[]` - invites

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.application.invite.getAllByApplication('myorganization/myapp').then(function(invites) {
	console.log(invites);
});
```

**Example**

```js
balena.models.application.invite.getAllByApplication(123).then(function(invites) {
	console.log(invites);
});
```

***

**invite.revoke(id) ⇒ `Promise`**

**Kind**: static method of [`invite`](#balena.models.application.invite)\
**Summary**: Revoke an invite\
**Access**: public

| Param | Type     | Description           |
| ----- | -------- | --------------------- |
| id    | `Number` | application invite id |

**Example**

```js
balena.models.application.invite.revoke(123);
```

***

**application.membership : `object`**

**Kind**: static namespace of [`application`](#balena.models.application)

* [.membership](#balena.models.application.membership) : `object`
  * [.changeRole(idOrUniqueKey, roleName)](#balena.models.application.membership.changeRole) ⇒ `Promise`
  * [.create(options)](#balena.models.application.membership.create) ⇒ `Promise`
  * [.get(membershipId, \[options\])](#balena.models.application.membership.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.membership.getAllByApplication) ⇒ `Promise`
  * [.getAllByUser(usernameOrId, \[options\])](#balena.models.application.membership.getAllByUser) ⇒ `Promise`
  * [.remove(idOrUniqueKey)](#balena.models.application.membership.remove) ⇒ `Promise`

***

**membership.changeRole(idOrUniqueKey, roleName) ⇒ `Promise`**

This method changes the role of an application member.

**Kind**: static method of [`membership`](#balena.models.application.membership)\
**Summary**: Changes the role of an application member\
**Access**: public

| Param         | Type                 | Description                                                                                                                  |
| ------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| idOrUniqueKey | `Number` \| `Object` | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be changed |
| roleName      | `String`             | the role name to be granted to the membership                                                                                |

**Example**

```js
balena.models.application.membership.changeRole(123, "member").then(function() {
	console.log('OK');
});
```

**Example**

```js
balena.models.application.membership.changeRole({
	user: 123,
	is_member_of__application: 125,
}, "member").then(function() {
	console.log('OK');
});
```

***

**membership.create(options) ⇒ `Promise`**

This method adds a user to an application by their username if they are a member of the organization.

**Kind**: static method of [`membership`](#balena.models.application.membership)\
**Summary**: Creates a new membership for an application\
**Access**: public\
**Fulfil**: `Object` - application membership

| Param               | Type                 | Default    | Description                                               |
| ------------------- | -------------------- | ---------- | --------------------------------------------------------- |
| options             | `Object`             |            | membership creation parameters                            |
| options.application | `String` \| `Number` |            | application handle (string), or id (number)               |
| options.username    | `String`             |            | the username of the balena user that will become a member |
| \[options.roleName] | `String`             | `"member"` | the role name to be granted to the membership             |

**Example**

```js
balena.models.application.membership.create({ application: "myApp", username: "user123", roleName: "member" }).then(function(membership) {
	console.log(membership);
});
```

***

**membership.get(membershipId, \[options]) ⇒ `Promise`**

This method returns a single application membership.

**Kind**: static method of [`membership`](#balena.models.application.membership)\
**Summary**: Get a single application membership\
**Access**: public\
**Fulfil**: `Object` - application membership

| Param        | Type                 | Default | Description                                                                                             |
| ------------ | -------------------- | ------- | ------------------------------------------------------------------------------------------------------- |
| membershipId | `number` \| `Object` |         | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership |
| \[options]   | `Object`             | `{}`    | extra pine options to use                                                                               |

**Example**

```js
balena.models.application.membership.get(5).then(function(memberships) {
	console.log(memberships);
});
```

***

**membership.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

This method returns all application memberships for a specific application.

**Kind**: static method of [`membership`](#balena.models.application.membership)\
**Summary**: Get all memberships by application\
**Access**: public\
**Fulfil**: `Object[]` - application memberships

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.application.membership.getAllByApplication('myorganization/myapp').then(function(memberships) {
	console.log(memberships);
});
```

**Example**

```js
balena.models.application.membership.getAllByApplication(123).then(function(memberships) {
	console.log(memberships);
});
```

***

**membership.getAllByUser(usernameOrId, \[options]) ⇒ `Promise`**

This method returns all application memberships for a specific user.

**Kind**: static method of [`membership`](#balena.models.application.membership)\
**Summary**: Get all memberships by user\
**Access**: public\
**Fulfil**: `Object[]` - application memberships

| Param        | Type                 | Default | Description                                 |
| ------------ | -------------------- | ------- | ------------------------------------------- |
| usernameOrId | `String` \| `Number` |         | the user's username (string) or id (number) |
| \[options]   | `Object`             | `{}`    | extra pine options to use                   |

**Example**

```js
balena.models.application.membership.getAllByUser('balena_os').then(function(memberships) {
	console.log(memberships);
});
```

**Example**

```js
balena.models.application.membership.getAllByUser(123).then(function(memberships) {
	console.log(memberships);
});
```

***

**membership.remove(idOrUniqueKey) ⇒ `Promise`**

**Kind**: static method of [`membership`](#balena.models.application.membership)\
**Summary**: Remove a membership\
**Access**: public

| Param         | Type                 | Description                                                                                                                  |
| ------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| idOrUniqueKey | `Number` \| `Object` | the id or an object with the unique `user` & `is_member_of__application` numeric pair of the membership that will be removed |

**Example**

```js
balena.models.application.membership.remove(123);
```

**Example**

```js
balena.models.application.membership.remove({
	user: 123,
	is_member_of__application: 125,
});
```

***

**application.tags : `object`**

**Kind**: static namespace of [`application`](#balena.models.application)

* [.tags](#balena.models.application.tags) : `object`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.application.tags.getAllByApplication) ⇒ `Promise`
  * [.remove(slugOrUuidOrId, tagKey)](#balena.models.application.tags.remove) ⇒ `Promise`
  * [.set(slugOrUuidOrId, tagKey, value)](#balena.models.application.tags.set) ⇒ `Promise`

***

**tags.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.application.tags)\
**Summary**: Get all application tags for an application\
**Access**: public\
**Fulfil**: `Object[]` - application tags

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.application.tags.getAllByApplication('myorganization/myapp').then(function(tags) {
	console.log(tags);
});
```

**Example**

```js
balena.models.application.tags.getAllByApplication(999999).then(function(tags) {
	console.log(tags);
});
```

***

**tags.remove(slugOrUuidOrId, tagKey) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.application.tags)\
**Summary**: Remove an application tag\
**Access**: public

| Param          | Type                 | Description                                             |
| -------------- | -------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| tagKey         | `String`             | tag key                                                 |

**Example**

```js
balena.models.application.tags.remove('myorganization/myapp', 'EDITOR');
```

***

**tags.set(slugOrUuidOrId, tagKey, value) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.application.tags)\
**Summary**: Set an application tag\
**Access**: public

| Param          | Type                    | Description                                             |
| -------------- | ----------------------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number`    | application slug (string), uuid (string) or id (number) |
| tagKey         | `String`                | tag key                                                 |
| value          | `String` \| `undefined` | tag value                                               |

**Example**

```js
balena.models.application.tags.set('myorganization/myapp', 'EDITOR', 'vim');
```

**Example**

```js
balena.models.application.tags.set(123, 'EDITOR', 'vim');
```

***

#### models.billing : `object`

**Note!** The billing methods are available on Balena.io exclusively.

**Kind**: static namespace of [`models`](#balena.models)

* [.billing](#balena.models.billing) : `object`
  * [.changePlan(organization, planChangeOptions)](#balena.models.billing.changePlan) ⇒ `Promise`
  * [.createSetupIntent(setupIntentParams)](#balena.models.billing.createSetupIntent) ⇒ `Promise`
  * [.downloadInvoice(organization)](#balena.models.billing.downloadInvoice) ⇒ `Promise`
  * [.getAccount(organization)](#balena.models.billing.getAccount) ⇒ `Promise`
  * [.getBillingInfo(organization)](#balena.models.billing.getBillingInfo) ⇒ `Promise`
  * [.getInvoices(organization)](#balena.models.billing.getInvoices) ⇒ `Promise`
  * [.getPlan(organization)](#balena.models.billing.getPlan) ⇒ `Promise`
  * [.removeBillingInfo(organization)](#balena.models.billing.removeBillingInfo) ⇒ `Promise`
  * [.updateAccountInfo(organization, accountInfo)](#balena.models.billing.updateAccountInfo)
  * [.updateBillingInfo(organization, billingInfo)](#balena.models.billing.updateBillingInfo) ⇒ `Promise`

***

**billing.changePlan(organization, planChangeOptions) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Change the current billing plan\
**Access**: public

| Param                           | Type                 | Description                                                |
| ------------------------------- | -------------------- | ---------------------------------------------------------- |
| organization                    | `String` \| `Number` | handle (string) or id (number) of the target organization. |
| planChangeOptions               | `Object`             | an object containing the billing plan change options       |
| billingInfo.tier                | `String`             | the code of the target billing plan                        |
| billingInfo.cycle               | `String`             | the billing cycle                                          |
| \[billingInfo.planChangeReason] | `String`             | the reason for changing the current plan                   |

**Example**

```js
balena.models.billing.changePlan(orgId, { billingCode: 'prototype-v2', cycle: 'annual' }).then(function() {
	console.log('Plan changed!');
});
```

***

**billing.createSetupIntent(setupIntentParams) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Create a Stripe setup intent required for setting billing information\
**Access**: public\
**Fulfil**: `Object` - partial stripe setup intent object

| Param                                 | Type                    | Description                                                       |
| ------------------------------------- | ----------------------- | ----------------------------------------------------------------- |
| setupIntentParams                     | `Object`                | an object containing the parameters for the setup intent creation |
| extraParams.organization              | `String` \| `Number`    | handle (string) or id (number) of the target organization.        |
| \[extraParams.'g-recaptcha-response'] | `String` \| `undefined` | the captcha response                                              |

**Example**

```js
balena.models.billing.createSetupIntent(orgId).then(function(setupIntent) {
	console.log(setupIntent);
});
```

***

**billing.downloadInvoice(organization) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Download a specific invoice\
**Access**: public\
**Fulfil**: `Blob|ReadableStream` - blob on the browser, download stream on node

| Param        | Type                 | Description                                                |
| ------------ | -------------------- | ---------------------------------------------------------- |
| organization | `String` \| `Number` | handle (string) or id (number) of the target organization. |
|              | `String`             | an invoice number                                          |

**Example**

```js
# Browser
balena.models.billing.downloadInvoice(orgId, '0000').then(function(blob) {
	console.log(blob);
});
# Node
balena.models.billing.downloadInvoice(orgId, '0000').then(function(stream) {
	stream.pipe(fs.createWriteStream('foo/bar/invoice-0000.pdf'));
});
```

***

**billing.getAccount(organization) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Get the user's billing account\
**Access**: public\
**Fulfil**: `Object` - billing account

| Param        | Type                 | Description                                                |
| ------------ | -------------------- | ---------------------------------------------------------- |
| organization | `String` \| `Number` | handle (string) or id (number) of the target organization. |

**Example**

```js
balena.models.billing.getAccount(orgId).then(function(billingAccount) {
	console.log(billingAccount);
});
```

***

**billing.getBillingInfo(organization) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Get the current billing information\
**Access**: public\
**Fulfil**: `Object` - billing information

| Param        | Type                 | Description                                                |
| ------------ | -------------------- | ---------------------------------------------------------- |
| organization | `String` \| `Number` | handle (string) or id (number) of the target organization. |

**Example**

```js
balena.models.billing.getBillingInfo(orgId).then(function(billingInfo) {
	console.log(billingInfo);
});
```

***

**billing.getInvoices(organization) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Get the available invoices\
**Access**: public\
**Fulfil**: `Object` - invoices

| Param        | Type                 | Description                                                |
| ------------ | -------------------- | ---------------------------------------------------------- |
| organization | `String` \| `Number` | handle (string) or id (number) of the target organization. |

**Example**

```js
balena.models.billing.getInvoices(orgId).then(function(invoices) {
	console.log(invoices);
});
```

***

**billing.getPlan(organization) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Get the current billing plan\
**Access**: public\
**Fulfil**: `Object` - billing plan

| Param        | Type                 | Description                                                |
| ------------ | -------------------- | ---------------------------------------------------------- |
| organization | `String` \| `Number` | handle (string) or id (number) of the target organization. |

**Example**

```js
balena.models.billing.getPlan(orgId).then(function(billingPlan) {
	console.log(billingPlan);
});
```

***

**billing.removeBillingInfo(organization) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Remove an organization's billing information\
**Access**: public

| Param        | Type                 | Description                                                |
| ------------ | -------------------- | ---------------------------------------------------------- |
| organization | `String` \| `Number` | handle (string) or id (number) of the target organization. |

**Example**

```js
balena.models.billing.removeBillingInfo(orgId).then(function() {
	console.log("Success");
});
```

***

**billing.updateAccountInfo(organization, accountInfo)**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Update the current billing account information\
**Access**: public

| Param        | Type                 | Description                                                |
| ------------ | -------------------- | ---------------------------------------------------------- |
| organization | `String` \| `Number` | handle (string) or id (number) of the target organization. |
| accountInfo  | `AccountInfo`        | an object containing billing account info                  |

**Example**

```js
balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' })
```

**Example**

```js
balena.models.billing.updateAccountInfo(orgId, { email: 'hello@balena.io' })
```

***

**billing.updateBillingInfo(organization, billingInfo) ⇒ `Promise`**

**Kind**: static method of [`billing`](#balena.models.billing)\
**Summary**: Update the current billing information\
**Access**: public\
**Fulfil**: `Object` - billing information

| Param                                 | Type                    | Description                                                |
| ------------------------------------- | ----------------------- | ---------------------------------------------------------- |
| organization                          | `String` \| `Number`    | handle (string) or id (number) of the target organization. |
| billingInfo                           | `Object`                | an object containing a billing info token\_id              |
| billingInfo.token\_id                 | `String`                | the token id generated for the billing info form           |
| \[billingInfo.'g-recaptcha-response'] | `String` \| `undefined` | the captcha response                                       |
| \[billingInfo.token\_type]            | `String` \| `undefined` | token type                                                 |

**Example**

```js
balena.models.billing.updateBillingInfo(orgId, { token_id: 'xxxxxxx' }).then(function(billingInfo) {
	console.log(billingInfo);
});
```

***

#### models.config : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.config](#balena.models.config) : `object`
  * [.getAll()](#balena.models.config.getAll) ⇒ `Promise`
  * [.getConfigVarSchema(deviceType)](#balena.models.config.getConfigVarSchema) ⇒ `Promise`
  * [.getDeviceOptions(deviceType)](#balena.models.config.getDeviceOptions) ⇒ `Promise`
  * [~~.getDeviceTypeManifestBySlug(slugOrName)~~](#balena.models.config.getDeviceTypeManifestBySlug) ~~⇒ `Promise`~~
  * [~~.getDeviceTypes()~~](#balena.models.config.getDeviceTypes) ~~⇒ `Promise`~~

***

**config.getAll() ⇒ `Promise`**

**Kind**: static method of [`config`](#balena.models.config)\
**Summary**: Get all configuration\
**Access**: public\
**Fulfil**: `Object` - configuration\
**Example**

```js
balena.models.config.getAll().then(function(config) {
	console.log(config);
});
```

***

**config.getConfigVarSchema(deviceType) ⇒ `Promise`**

**Kind**: static method of [`config`](#balena.models.config)\
**Summary**: Get configuration variables schema for a device type\
**Access**: public\
**Fulfil**: `Object[]` - configuration options

| Param      | Type     | Description      |
| ---------- | -------- | ---------------- |
| deviceType | `String` | device type slug |

**Example**

```js
balena.models.config.getConfigVarSchema('raspberry-pi').then(function(options) {
	console.log(options);
});
```

***

**config.getDeviceOptions(deviceType) ⇒ `Promise`**

**Kind**: static method of [`config`](#balena.models.config)\
**Summary**: Get configuration/initialization options for a device type\
**Access**: public\
**Fulfil**: `Object[]` - configuration options

| Param      | Type     | Description      |
| ---------- | -------- | ---------------- |
| deviceType | `String` | device type slug |

**Example**

```js
balena.models.config.getDeviceOptions('raspberry-pi').then(function(options) {
	console.log(options);
});
```

***

~~**config.getDeviceTypeManifestBySlug(slugOrName) ⇒****&#x20;****`Promise`**~~

***use balena.models.deviceType.getBySlugOrName***

**Kind**: static method of [`config`](#balena.models.config)\
**Summary**: Get a device type manifest by slug\
**Access**: public\
**Fulfil**: `Object` - device type manifest

| Param      | Type     | Description      |
| ---------- | -------- | ---------------- |
| slugOrName | `String` | device type slug |

**Example**

```js
balena.models.config.getDeviceTypeManifestBySlug('raspberry-pi').then(function(manifest) {
	console.log(manifest);
});
```

***

~~**config.getDeviceTypes() ⇒****&#x20;****`Promise`**~~

***use balena.models.deviceType.getAll***

**Kind**: static method of [`config`](#balena.models.config)\
**Summary**: Get device types\
**Access**: public\
**Fulfil**: `Object[]` - device types\
**Example**

```js
balena.models.config.getDeviceTypes().then(function(deviceTypes) {
	console.log(deviceTypes);
});
```

***

#### models.creditBundle : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.creditBundle](#balena.models.creditBundle) : `object`
  * [.create(organization, featureId, creditsToPurchase)](#balena.models.creditBundle.create) ⇒ `Promise`
  * [.getAllByOrg(organization, \[options\])](#balena.models.creditBundle.getAllByOrg) ⇒ `Promise`

***

**creditBundle.create(organization, featureId, creditsToPurchase) ⇒ `Promise`**

**Kind**: static method of [`creditBundle`](#balena.models.creditBundle)\
**Summary**: Purchase a credit bundle for the given feature and org of the given quantity\
**Access**: public\
**Fulfil**: `Object[]` - credit bundles

| Param             | Type                 | Description                                                       |
| ----------------- | -------------------- | ----------------------------------------------------------------- |
| organization      | `String` \| `Number` | handle (string) or id (number) of the target organization.        |
| featureId         | `Number`             | id (number) of the feature for which credits are being purchased. |
| creditsToPurchase | `Number`             | number of credits being purchased.                                |

**Example**

```js
balena.models.creditBundle.create(orgId, featureId, creditsToPurchase).then(function(creditBundle) {
	console.log(creditBundle);
});
```

***

**creditBundle.getAllByOrg(organization, \[options]) ⇒ `Promise`**

**Kind**: static method of [`creditBundle`](#balena.models.creditBundle)\
**Summary**: Get all of the credit bundles purchased by the given org\
**Access**: public\
**Fulfil**: `Object[]` - credit bundles

| Param        | Type                 | Default | Description                                                |
| ------------ | -------------------- | ------- | ---------------------------------------------------------- |
| organization | `String` \| `Number` |         | handle (string) or id (number) of the target organization. |
| \[options]   | `Object`             | `{}`    | extra pine options to use                                  |

**Example**

```js
balena.models.creditBundle.getAllByOrg(orgId).then(function(creditBundles) {
	console.log(creditBundles);
});
```

***

#### models.device : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.device](#balena.models.device) : `object`
  * [.deactivate(uuidOrIdOrArray)](#balena.models.device.deactivate) ⇒ `Promise`
  * [.disableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.disableDeviceUrl) ⇒ `Promise`
  * [.disableLocalMode(uuidOrId)](#balena.models.device.disableLocalMode) ⇒ `Promise`
  * [.disableLockOverride(uuidOrId)](#balena.models.device.disableLockOverride) ⇒ `Promise`
  * [.enableDeviceUrl(uuidOrIdOrArray)](#balena.models.device.enableDeviceUrl) ⇒ `Promise`
  * [.enableLocalMode(uuidOrId)](#balena.models.device.enableLocalMode) ⇒ `Promise`
  * [.enableLockOverride(uuidOrId)](#balena.models.device.enableLockOverride) ⇒ `Promise`
  * [.generateDeviceKey(uuidOrId, \[keyName\], \[keyDescription\])](#balena.models.device.generateDeviceKey) ⇒ `Promise`
  * [.generateUniqueKey()](#balena.models.device.generateUniqueKey) ⇒ `String`
  * [.get(uuidOrId, \[options\])](#balena.models.device.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.getAllByApplication) ⇒ `Promise`
  * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.device.getAllByOrganization) ⇒ `Promise`
  * [.getApplicationName(uuidOrId)](#balena.models.device.getApplicationName) ⇒ `Promise`
  * [.getByName(name)](#balena.models.device.getByName) ⇒ `Promise`
  * [.getDashboardUrl(uuid)](#balena.models.device.getDashboardUrl) ⇒ `String`
  * [.getDeviceUrl(uuidOrId)](#balena.models.device.getDeviceUrl) ⇒ `Promise`
  * [.getLocalIPAddresses(uuidOrId)](#balena.models.device.getLocalIPAddresses) ⇒ `Promise`
  * [.getLocalModeSupport(device)](#balena.models.device.getLocalModeSupport) ⇒ `Object`
  * [.getMACAddresses(uuidOrId)](#balena.models.device.getMACAddresses) ⇒ `Promise`
  * [.getMetrics(uuidOrId)](#balena.models.device.getMetrics) ⇒ `Promise`
  * [.getName(uuidOrId)](#balena.models.device.getName) ⇒ `Promise`
  * [.getOsVersion(device)](#balena.models.device.getOsVersion) ⇒ `String`
  * [.getProgress(uuidOrId)](#balena.models.device.getProgress) ⇒ `Promise`
  * [.getStatus(uuidOrId)](#balena.models.device.getStatus) ⇒ `Promise`
  * [.getSupervisorState(uuidOrId)](#balena.models.device.getSupervisorState) ⇒ `Promise`
  * [.getSupervisorTargetState(uuidOrId, version)](#balena.models.device.getSupervisorTargetState) ⇒ `Promise`
  * [.getSupervisorTargetStateForApp(uuidOrId, release)](#balena.models.device.getSupervisorTargetStateForApp) ⇒ `Promise`
  * [.getTargetReleaseHash(uuidOrId)](#balena.models.device.getTargetReleaseHash) ⇒ `Promise`
  * [.getWithServiceDetails(uuidOrId, \[options\])](#balena.models.device.getWithServiceDetails) ⇒ `Promise`
  * [.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp)](#balena.models.device.grantSupportAccess) ⇒ `Promise`
  * [.has(uuidOrId)](#balena.models.device.has) ⇒ `Promise`
  * [.hasDeviceUrl(uuidOrId)](#balena.models.device.hasDeviceUrl) ⇒ `Promise`
  * [.hasLockOverride(uuidOrId)](#balena.models.device.hasLockOverride) ⇒ `Promise`
  * [.identify(uuidOrId)](#balena.models.device.identify) ⇒ `Promise`
  * [.isInLocalMode(uuidOrId)](#balena.models.device.isInLocalMode) ⇒ `Promise`
  * [.isOnline(uuidOrId)](#balena.models.device.isOnline) ⇒ `Promise`
  * [.isTrackingApplicationRelease(uuidOrId)](#balena.models.device.isTrackingApplicationRelease) ⇒ `Promise`
  * [.move(uuidOrIdOrArray, applicationSlugOrUuidOrId)](#balena.models.device.move) ⇒ `Promise`
  * [.ping(uuidOrId)](#balena.models.device.ping) ⇒ `Promise`
  * [.pinToOsRelease(uuidOrIdOrArray, osVersionOrId)](#balena.models.device.pinToOsRelease) ⇒ `Promise`
  * [.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId)](#balena.models.device.pinToRelease) ⇒ `Promise`
  * [.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId)](#balena.models.device.pinToSupervisorRelease) ⇒ `Promise`
  * [.purge(uuidOrId)](#balena.models.device.purge) ⇒ `Promise`
  * [.reboot(uuidOrId, \[options\])](#balena.models.device.reboot) ⇒ `Promise`
  * [.register(applicationSlugOrUuidOrId, uuid, \[deviceTypeSlug\])](#balena.models.device.register) ⇒ `Promise`
  * [.remove(uuidOrIdOrArray)](#balena.models.device.remove) ⇒ `Promise`
  * [.rename(uuidOrId, newName)](#balena.models.device.rename) ⇒ `Promise`
  * [.restartApplication(uuidOrId)](#balena.models.device.restartApplication) ⇒ `Promise`
  * [.restartService(uuidOrId, imageId)](#balena.models.device.restartService) ⇒ `Promise`
  * [.revokeSupportAccess(uuidOrIdOrArray)](#balena.models.device.revokeSupportAccess) ⇒ `Promise`
  * [.setCustomLocation(uuidOrIdOrArray, location)](#balena.models.device.setCustomLocation) ⇒ `Promise`
  * [.setNote(uuidOrIdOrArray, note)](#balena.models.device.setNote) ⇒ `Promise`
  * [.shutdown(uuidOrId, \[options\])](#balena.models.device.shutdown) ⇒ `Promise`
  * [.startOsUpdate(uuidOrUuids, targetOsVersion, \[options\])](#balena.models.device.startOsUpdate) ⇒ `Promise`
  * [.startService(uuidOrId, imageId)](#balena.models.device.startService) ⇒ `Promise`
  * [.stopService(uuidOrId, imageId)](#balena.models.device.stopService) ⇒ `Promise`
  * [.trackApplicationRelease(uuidOrIdOrArray)](#balena.models.device.trackApplicationRelease) ⇒ `Promise`
  * [.unsetCustomLocation(uuidOrIdOrArray)](#balena.models.device.unsetCustomLocation) ⇒ `Promise`
  * [.update(uuidOrId, \[options\])](#balena.models.device.update) ⇒ `Promise`
  * [.configVar](#balena.models.device.configVar) : `object`
    * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.configVar.getAllByApplication) ⇒ `Promise`
    * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.configVar.getAllByDevice) ⇒ `Promise`
    * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ `Promise`
    * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ `Promise`
  * [.envVar](#balena.models.device.envVar) : `object`
    * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.envVar.getAllByApplication) ⇒ `Promise`
    * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.envVar.getAllByDevice) ⇒ `Promise`
    * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ `Promise`
    * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ `Promise`
  * [.history](#balena.models.device.history) : `object`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.history.getAllByApplication) ⇒ `Promise`
    * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.history.getAllByDevice) ⇒ `Promise`
  * [.serviceVar](#balena.models.device.serviceVar) : `object`
    * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.serviceVar.getAllByApplication) ⇒ `Promise`
    * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.serviceVar.getAllByDevice) ⇒ `Promise`
    * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ `Promise`
    * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ `Promise`
  * [.tags](#balena.models.device.tags) : `object`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.tags.getAllByApplication) ⇒ `Promise`
    * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.tags.getAllByDevice) ⇒ `Promise`
    * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ `Promise`
    * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ `Promise`

***

**device.deactivate(uuidOrIdOrArray) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Deactivate device\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |

**Example**

```js
balena.models.device.deactivate('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.deactivate(123);
```

***

**device.disableDeviceUrl(uuidOrIdOrArray) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Disable device url for a device\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |

**Example**

```js
balena.models.device.disableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.disableDeviceUrl(123);
```

***

**device.disableLocalMode(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Disable local mode\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.disableLocalMode('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.disableLocalMode(123);
```

***

**device.disableLockOverride(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Disable lock override\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.disableLockOverride('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.disableLockOverride(123);
```

***

**device.enableDeviceUrl(uuidOrIdOrArray) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Enable device url for a device\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |

**Example**

```js
balena.models.device.enableDeviceUrl('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.enableDeviceUrl(123);
```

***

**device.enableLocalMode(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Enable local mode\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.enableLocalMode('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.enableLocalMode(123);
```

***

**device.enableLockOverride(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Enable lock override\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.enableLockOverride('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.enableLockOverride(123);
```

***

**device.generateDeviceKey(uuidOrId, \[keyName], \[keyDescription]) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Generate a device key\
**Access**: public

| Param             | Type                 | Description                         |
| ----------------- | -------------------- | ----------------------------------- |
| uuidOrId          | `String` \| `Number` | device uuid (string) or id (number) |
| \[keyName]        | `String`             | Device key name                     |
| \[keyDescription] | `String`             | Description for device key          |

**Example**

```js
balena.models.device.generateDeviceKey('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceApiKey) {
	console.log(deviceApiKey);
});
```

**Example**

```js
balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) {
	console.log(deviceApiKey);
});
```

***

**device.generateUniqueKey() ⇒ `String`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Generate a random key, useful for both uuid and api key.\
**Returns**: `String` - A generated key\
**Access**: public\
**Example**

```js
randomKey = balena.models.device.generateUniqueKey();
// randomKey is a randomly generated key that can be used as either a uuid or an api key
console.log(randomKey);
```

***

**device.get(uuidOrId, \[options]) ⇒ `Promise`**

This method returns a single device by id or uuid. In order to have the following computed properties in the result you have to explicitly define them in a `$select` in the extra options:

* `overall_status`
* `overall_progress`
* `should_be_running__release`

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get a single device\
**Access**: public\
**Fulfil**: `Object` - device

| Param      | Type                 | Default | Description                         |
| ---------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId   | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options] | `Object`             | `{}`    | extra pine options to use           |

**Example**

```js
balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) {
	console.log(device);
})
```

**Example**

```js
balena.models.device.get(123).then(function(device) {
	console.log(device);
})
```

**Example**

```js
balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd', { $select: ['overall_status', 'overall_progress'] }).then(function(device) {
	console.log(device);
})
```

***

**device.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

This method returns all devices of a specific application. In order to have the following computed properties in the result you have to explicitly define them in a `$select` in the extra options:

* `overall_status`
* `overall_progress`
* `should_be_running__release`

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get all devices by application\
**Access**: public\
**Fulfil**: `Object[]` - devices

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.device.getAllByApplication('myorganization/myapp').then(function(devices) {
	console.log(devices);
});
```

**Example**

```js
balena.models.device.getAllByApplication(123).then(function(devices) {
	console.log(devices);
});
```

**Example**

```js
balena.models.device.getAllByApplication('myorganization/myapp', { $select: ['overall_status', 'overall_progress'] }).then(function(device) {
	console.log(device);
})
```

***

**device.getAllByOrganization(handleOrId, \[options]) ⇒ `Promise`**

This method returns all devices of a specific application. In order to have the following computed properties in the result you have to explicitly define them in a `$select` in the extra options:

* `overall_status`
* `overall_progress`
* `should_be_running__release`

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get all devices by organization\
**Access**: public\
**Fulfil**: `Object[]` - devices

| Param      | Type                 | Default | Description                                  |
| ---------- | -------------------- | ------- | -------------------------------------------- |
| handleOrId | `String` \| `Number` |         | organization handle (string) or id (number). |
| \[options] | `Object`             | `{}`    | extra pine options to use                    |

**Example**

```js
balena.models.device.getAllByOrganization('myorganization').then(function(devices) {
	console.log(devices);
});
```

**Example**

```js
balena.models.device.getAllByOrganization(123).then(function(devices) {
	console.log(devices);
});
```

**Example**

```js
balena.models.device.getAllByOrganization('myorganization', { $select: ['overall_status', 'overall_progress'] }).then(function(device) {
	console.log(device);
})
```

***

**device.getApplicationName(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get application name\
**Access**: public\
**Fulfil**: `String` - application name

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getApplicationName('7cf02a69e4d34c9da573914963cf54fd').then(function(applicationName) {
	console.log(applicationName);
});
```

**Example**

```js
balena.models.device.getApplicationName(123).then(function(applicationName) {
	console.log(applicationName);
});
```

***

**device.getByName(name) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get devices by name\
**Access**: public\
**Fulfil**: `Object[]` - devices

| Param | Type     | Description |
| ----- | -------- | ----------- |
| name  | `String` | device name |

**Example**

```js
balena.models.device.getByName('MyDevice').then(function(devices) {
	console.log(devices);
});
```

***

**device.getDashboardUrl(uuid) ⇒ `String`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get Dashboard URL for a specific device\
**Returns**: `String` - - Dashboard URL for the specific device\
**Throws**:

* Exception if the uuid is empty

| Param | Type     | Description |
| ----- | -------- | ----------- |
| uuid  | `String` | Device uuid |

**Example**

```js
dashboardDeviceUrl = balena.models.device.getDashboardUrl('a44b544b8cc24d11b036c659dfeaccd8')
```

***

**device.getDeviceUrl(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get a device url\
**Access**: public\
**Fulfil**: `String` - device url

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(url) {
	console.log(url);
});
```

**Example**

```js
balena.models.device.getDeviceUrl(123).then(function(url) {
	console.log(url);
});
```

***

**device.getLocalIPAddresses(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the local IP addresses of a device\
**Access**: public\
**Fulfil**: `String[]` - local ip addresses\
**Reject**: `Error` Will reject if the device is offline

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getLocalIPAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(localIPAddresses) {
	localIPAddresses.forEach(function(localIP) {
		console.log(localIP);
	});
});
```

**Example**

```js
balena.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) {
	localIPAddresses.forEach(function(localIP) {
		console.log(localIP);
	});
});
```

***

**device.getLocalModeSupport(device) ⇒ `Object`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Returns whether local mode is supported along with a message describing the reason why local mode is not supported.\
**Returns**: `Object` - Local mode support info ({ supported: true/false, message: "..." })\
**Access**: public

| Param  | Type     | Description     |
| ------ | -------- | --------------- |
| device | `Object` | A device object |

**Example**

```js
balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) {
	balena.models.device.getLocalModeSupport(device);
})
```

***

**device.getMACAddresses(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the MAC addresses of a device\
**Access**: public\
**Fulfil**: `String[]` - mac addresses

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getMACAddresses('7cf02a69e4d34c9da573914963cf54fd').then(function(macAddresses) {
	macAddresses.forEach(function(mac) {
		console.log(mac);
	});
});
```

**Example**

```js
balena.models.device.getMACAddresses(123).then(function(macAddresses) {
	macAddresses.forEach(function(mac) {
		console.log(mac);
	});
});
```

***

**device.getMetrics(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the metrics related information for a device\
**Access**: public\
**Fulfil**: `Object` - device metrics

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getMetrics('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceMetrics) {
	console.log(deviceMetrics);
});
```

**Example**

```js
balena.models.device.getMetrics(123).then(function(deviceMetrics) {
	console.log(deviceMetrics);
});
```

***

**device.getName(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the name of a device\
**Access**: public\
**Fulfil**: `String` - device name

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getName('7cf02a69e4d34c9da573914963cf54fd').then(function(deviceName) {
	console.log(deviceName);
});
```

**Example**

```js
balena.models.device.getName(123).then(function(deviceName) {
	console.log(deviceName);
});
```

***

**device.getOsVersion(device) ⇒ `String`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the OS version (version number and variant combined) running on a device\
**Access**: public

| Param  | Type     | Description     |
| ------ | -------- | --------------- |
| device | `Object` | A device object |

**Example**

```js
balena.models.device.get('7cf02a69e4d34c9da573914963cf54fd').then(function(device) {
	console.log(device.os_version); // => 'balenaOS 2.26.0+rev1'
	console.log(device.os_variant); // => 'prod'
	balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod'
})
```

***

**device.getProgress(uuidOrId) ⇒ `Promise`**

Convenience method for getting the overall progress of a device. It's recommended to use `balena.models.device.get()` instead, in case that you need to retrieve more device fields than just the progress.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the progress of a device\
**Access**: public\
**Fulfil**: `Number|null` - device progress\
**See**: [get](#balena.models.device.get) for an example on selecting the `overall_progress` field.

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getProgress('7cf02a69e4d34c9da573914963cf54fd').then(function(progress) {
	console.log(progress);
});
```

**Example**

```js
balena.models.device.getProgress(123).then(function(progress) {
	console.log(progress);
});
```

***

**device.getStatus(uuidOrId) ⇒ `Promise`**

Convenience method for getting the overall status of a device. It's recommended to use `balena.models.device.get()` instead, in case that you need to retrieve more device fields than just the status.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the status of a device\
**Access**: public\
**Fulfil**: `String` - device status\
**See**: [get](#balena.models.device.get) for an example on selecting the `overall_status` field.

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getStatus('7cf02a69e4d34c9da573914963cf54fd').then(function(status) {
	console.log(status);
});
```

**Example**

```js
balena.models.device.getStatus(123).then(function(status) {
	console.log(status);
});
```

***

**device.getSupervisorState(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the supervisor state on a device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getSupervisorState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) {
	console.log(state);
});
```

**Example**

```js
balena.models.device.getSupervisorState(123).then(function(state) {
	console.log(state);
});
```

***

**device.getSupervisorTargetState(uuidOrId, version) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the target supervisor state on a device\
**Access**: public

| Param    | Type                 | Description                                            |
| -------- | -------------------- | ------------------------------------------------------ |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number)                    |
| version  | `Number`             | (optional) target state version (2 or 3), default to 2 |

**Example**

```js
balena.models.device.getSupervisorTargetState('7cf02a69e4d34c9da573914963cf54fd').then(function(state) {
	console.log(state);
});
```

**Example**

```js
balena.models.device.getSupervisorTargetState(123).then(function(state) {
	console.log(state);
});
```

**Example**

```js
balena.models.device.getSupervisorTargetState(123, 3).then(function(state) {
	console.log(state);
});
```

***

**device.getSupervisorTargetStateForApp(uuidOrId, release) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the target supervisor state on a "generic" device on a fleet\
**Access**: public

| Param    | Type                 | Description                               |
| -------- | -------------------- | ----------------------------------------- |
| uuidOrId | `String` \| `Number` | fleet uuid (string) or id (number)        |
| release  | `String`             | (optional) release uuid (default tracked) |

**Example**

```js
balena.models.device.getSupervisorTargetStateForApp('7cf02a69e4d34c9da573914963cf54fd').then(function(state) {
	console.log(state);
});
```

**Example**

```js
balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) {
	console.log(state);
});
```

**Example**

```js
balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a69e4d34c9da573914963cf54fd').then(function(state) {
	console.log(state);
});
```

***

**device.getTargetReleaseHash(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get the hash of the currently tracked release for a specific device\
**Access**: public\
**Fulfil**: `String` - The release hash of the currently tracked release

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd').then(function(release) {
	console.log(release);
});
```

**Example**

```js
balena.models.device.getTargetReleaseHash('7cf02a69e4d34c9da573914963cf54fd', function(release) {
	console.log(release);
});
```

***

**device.getWithServiceDetails(uuidOrId, \[options]) ⇒ `Promise`**

This method does not map exactly to the underlying model: it runs a larger prebuilt query, and reformats it into an easy to use and understand format. If you want more control, or to see the raw model directly, use `device.get(uuidOrId, options)` instead.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get a single device along with its associated services' details, including their associated commit\
**Access**: public\
**Fulfil**: `Object` - device with service details

| Param      | Type                 | Default | Description                         |
| ---------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId   | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options] | `Object`             | `{}`    | extra pine options to use           |

**Example**

```js
balena.models.device.getWithServiceDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(device) {
	console.log(device);
})
```

**Example**

```js
balena.models.device.getWithServiceDetails(123).then(function(device) {
	console.log(device);
})
```

***

**device.grantSupportAccess(uuidOrIdOrArray, expiryTimestamp) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Grant support access to a device until a specified time\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |
| expiryTimestamp | `Number`                                                     | a timestamp in ms for when the support access will expire         |

**Example**

```js
balena.models.device.grantSupportAccess('7cf02a69e4d34c9da573914963cf54fd', Date.now() + 3600 * 1000);
```

**Example**

```js
balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000);
```

***

**device.has(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Check if a device exists\
**Access**: public\
**Fulfil**: `Boolean` - has device

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.has('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDevice) {
	console.log(hasDevice);
});
```

**Example**

```js
balena.models.device.has(123).then(function(hasDevice) {
	console.log(hasDevice);
});
```

***

**device.hasDeviceUrl(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Check if a device is web accessible with device utls\
**Access**: public\
**Fulfil**: `Boolean` - has device url

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.hasDeviceUrl('7cf02a69e4d34c9da573914963cf54fd').then(function(hasDeviceUrl) {
	if (hasDeviceUrl) {
		console.log('The device has device URL enabled');
	}
});
```

**Example**

```js
balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) {
	if (hasDeviceUrl) {
		console.log('The device has device URL enabled');
	}
});
```

***

**device.hasLockOverride(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Check if a device has the lock override enabled\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.hasLockOverride('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.hasLockOverride(123);
```

***

**device.identify(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Identify device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.identify('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.identify(123);
```

***

**device.isInLocalMode(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Check if local mode is enabled on the device\
**Access**: public\
**Fulfil**: `Boolean` - has device url

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.isInLocalMode('7cf02a69e4d34c9da573914963cf54fd').then(function(isInLocalMode) {
	if (isInLocalMode) {
		console.log('The device has local mode enabled');
	}
});
```

**Example**

```js
balena.models.device.isInLocalMode(123).then(function(isInLocalMode) {
	if (isInLocalMode) {
		console.log('The device has local mode enabled');
	}
});
```

***

**device.isOnline(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Check if a device is online\
**Access**: public\
**Fulfil**: `Boolean` - is device online

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.isOnline('7cf02a69e4d34c9da573914963cf54fd').then(function(isOnline) {
	console.log('Is device online?', isOnline);
});
```

**Example**

```js
balena.models.device.isOnline(123).then(function(isOnline) {
	console.log('Is device online?', isOnline);
});
```

***

**device.isTrackingApplicationRelease(uuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Get whether the device is configured to track the current application release\
**Access**: public\
**Fulfil**: `Boolean` - is tracking the current application release

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.isTrackingApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(isEnabled) {
	console.log(isEnabled);
});
```

***

**device.move(uuidOrIdOrArray, applicationSlugOrUuidOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Move a device to another application\
**Access**: public

| Param                     | Type                                                         | Description                                                       |
| ------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray           | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |
| applicationSlugOrUuidOrId | `String` \| `Number`                                         | application slug (string), uuid (string) or id (number)           |

**Example**

```js
balena.models.device.move('7cf02a69e4d34c9da573914963cf54fd', 'myorganization/myapp');
```

**Example**

```js
balena.models.device.move(123, 'myorganization/myapp');
```

**Example**

```js
balena.models.device.move(123, 456);
```

***

**device.ping(uuidOrId) ⇒ `Promise`**

This is useful to signal that the supervisor is alive and responding.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Ping a device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.ping('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.ping(123);
```

***

**device.pinToOsRelease(uuidOrIdOrArray, osVersionOrId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Mark a specific device to be updated to a particular OS release\
**Access**: public\
**Experimental**:

| Param           | Type                                                         | Description                                                                                                                                                                                                                                                                                                                                               |
| --------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids                                                                                                                                                                                                                                                                                         |
| osVersionOrId   | `String`                                                     | the raw version of a OS release (string) or id (number) Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number, a "prod" variant and greater than or equal to the one running on the device. To resolve compatible update targets for a device use `balena.models.os.getSupportedOsUpdateVersions`. |

**Example**

```js
await balena.models.device.pinToOsRelease('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod');
```

***

**device.pinToRelease(uuidOrIdOrArray, fullReleaseHashOrId) ⇒ `Promise`**

Configures the device to run a particular release and not get updated when the current application release changes.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Set a specific device to run a particular release\
**Access**: public

| Param               | Type                                                         | Description                                                       |
| ------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray     | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |
| fullReleaseHashOrId | `String` \| `Number`                                         | the hash of a successful release (string) or id (number)          |

**Example**

```js
balena.models.device.pinToRelease('7cf02a69e4d34c9da573914963cf54fd', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() {
	...
});
```

**Example**

```js
balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() {
	...
});
```

***

**device.pinToSupervisorRelease(uuidOrIdOrArray, supervisorVersionOrId) ⇒ `Promise`**

Configures the device to run a particular supervisor release.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Set a specific device to run a particular supervisor release\
**Access**: public

| Param                 | Type                                                         | Description                                                       |
| --------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray       | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |
| supervisorVersionOrId | `String` \| `Number`                                         | the raw version of a supervisor release (string) or id (number)   |

**Example**

```js
balena.models.device.pinToSupervisorRelease('7cf02a69e4d34c9da573914963cf54fd', '10.8.0').then(function() {
	...
});
```

**Example**

```js
balena.models.device.pinToSupervisorRelease(123, '11.4.14').then(function() {
	...
});
```

***

**device.purge(uuidOrId) ⇒ `Promise`**

This function clears the user application's `/data` directory.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Purge device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.purge('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.purge(123);
```

***

**device.reboot(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Reboot device\
**Access**: public

| Param            | Type                 | Default | Description                         |
| ---------------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId         | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options]       | `Object`             |         | options                             |
| \[options.force] | `Boolean`            | `false` | override update lock                |

**Example**

```js
balena.models.device.reboot('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.reboot(123);
```

***

**device.register(applicationSlugOrUuidOrId, uuid, \[deviceTypeSlug]) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Register a new device with a Balena application.\
**Access**: public\
**Fulfil**: `Object` Device registration info ({ id: "...", uuid: "...", api\_key: "..." })

| Param                     | Type                 | Description                                             |
| ------------------------- | -------------------- | ------------------------------------------------------- |
| applicationSlugOrUuidOrId | `String` \| `Number` | application slug (string), uuid (string) or id (number) |
| uuid                      | `String`             | device uuid                                             |
| \[deviceTypeSlug]         | `String`             | device type slug (string) or alias (string)             |

**Example**

```js
var uuid = balena.models.device.generateUniqueKey();
balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) {
	console.log(registrationInfo);
});
```

**Example**

```js
var uuid = balena.models.device.generateUniqueKey();
balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) {
	console.log(registrationInfo);
});
```

**Example**

```js
var uuid = balena.models.device.generateUniqueKey();
balena.models.device.register(123, uuid).then(function(registrationInfo) {
	console.log(registrationInfo);
});
```

***

**device.remove(uuidOrIdOrArray) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Remove device\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |

**Example**

```js
balena.models.device.remove('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.remove(123);
```

***

**device.rename(uuidOrId, newName) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Rename device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| newName  | `String`             | the device new name                 |

**Example**

```js
balena.models.device.rename('7cf02a69e4d34c9da573914963cf54fd', 'NewName');
```

**Example**

```js
balena.models.device.rename(123, 'NewName');
```

***

**device.restartApplication(uuidOrId) ⇒ `Promise`**

This function restarts the Docker container running the application on the device, but doesn't reboot the device itself.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Restart application on device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |

**Example**

```js
balena.models.device.restartApplication('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.restartApplication(123);
```

***

**device.restartService(uuidOrId, imageId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Restart a service on a device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| imageId  | `Number`             | id of the image to restart          |

**Example**

```js
balena.models.device.restartService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() {
	...
});
```

**Example**

```js
balena.models.device.restartService(1, 123).then(function() {
	...
});
```

***

**device.revokeSupportAccess(uuidOrIdOrArray) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Revoke support access to a device\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |

**Example**

```js
balena.models.device.revokeSupportAccess('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.revokeSupportAccess(123);
```

***

**device.setCustomLocation(uuidOrIdOrArray, location) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Set a custom location for a device\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |
| location        | `Object`                                                     | the location ({ latitude: 123, longitude: 456 })                  |

**Example**

```js
balena.models.device.setCustomLocation('7cf02a69e4d34c9da573914963cf54fd', { latitude: 123, longitude: 456 });
```

**Example**

```js
balena.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 });
```

***

**device.setNote(uuidOrIdOrArray, note) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Note a device\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |
| note            | `String`                                                     | the note                                                          |

**Example**

```js
balena.models.device.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note');
```

**Example**

```js
balena.models.device.setNote(123, 'My useful note');
```

***

**device.shutdown(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Shutdown device\
**Access**: public

| Param            | Type                 | Default | Description                         |
| ---------------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId         | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options]       | `Object`             |         | options                             |
| \[options.force] | `Boolean`            | `false` | override update lock                |

**Example**

```js
balena.models.device.shutdown('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.shutdown(123);
```

***

**device.startOsUpdate(uuidOrUuids, targetOsVersion, \[options]) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Start an OS update on a device\
**Access**: public\
**Fulfil**: `Object` - action response

| Param                  | Type                         | Description                                                                                                                                                                                                                                                                                                          |
| ---------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| uuidOrUuids            | `String` \| `Array.<String>` | full device uuid or array of full uuids                                                                                                                                                                                                                                                                              |
| targetOsVersion        | `String`                     | semver-compatible version for the target device Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number, a "prod" variant and greater than the one running on the device. To resolve the semver-compatible range use `balena.model.os.getMaxSatisfyingVersion`. |
| \[options]             | `Object`                     | options                                                                                                                                                                                                                                                                                                              |
| \[options.runDetached] | `Boolean`                    | run the update in detached mode. True by default                                                                                                                                                                                                                                                                     |

**Example**

```js
balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) {
	console.log(result.status);
});
```

***

**device.startService(uuidOrId, imageId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Start a service on a device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| imageId  | `Number`             | id of the image to start            |

**Example**

```js
balena.models.device.startService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() {
	...
});
```

**Example**

```js
balena.models.device.startService(1, 123).then(function() {
	...
});
```

***

**device.stopService(uuidOrId, imageId) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Stop a service on a device\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| imageId  | `Number`             | id of the image to stop             |

**Example**

```js
balena.models.device.stopService('7cf02a69e4d34c9da573914963cf54fd', 123).then(function() {
	...
});
```

**Example**

```js
balena.models.device.stopService(1, 123).then(function() {
	...
});
```

***

**device.trackApplicationRelease(uuidOrIdOrArray) ⇒ `Promise`**

The device's current release will be updated with each new successfully built release.

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Configure a specific device to track the current application release\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |

**Example**

```js
balena.models.device.trackApplicationRelease('7cf02a69e4d34c9da573914963cf54fd').then(function() {
	...
});
```

***

**device.unsetCustomLocation(uuidOrIdOrArray) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Clear the custom location of a device\
**Access**: public

| Param           | Type                                                         | Description                                                       |
| --------------- | ------------------------------------------------------------ | ----------------------------------------------------------------- |
| uuidOrIdOrArray | `String` \| `Array.<String>` \| `Number` \| `Array.<Number>` | device uuid (string) or id (number) or array of full uuids or ids |

**Example**

```js
balena.models.device.unsetCustomLocation('7cf02a69e4d34c9da573914963cf54fd');
```

**Example**

```js
balena.models.device.unsetCustomLocation(123);
```

***

**device.update(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`device`](#balena.models.device)\
**Summary**: Trigger an update check on the supervisor\
**Access**: public

| Param            | Type                 | Default | Description                         |
| ---------------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId         | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options]       | `Object`             |         | options                             |
| \[options.force] | `Boolean`            | `false` | override update lock                |

**Example**

```js
balena.models.device.update('7cf02a69e4d34c9da573914963cf54fd', {
	force: true
});
```

**Example**

```js
balena.models.device.update(123, {
	force: true
});
```

***

**device.configVar : `object`**

**Kind**: static namespace of [`device`](#balena.models.device)

* [.configVar](#balena.models.device.configVar) : `object`
  * [.get(uuidOrId, key)](#balena.models.device.configVar.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.configVar.getAllByApplication) ⇒ `Promise`
  * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.configVar.getAllByDevice) ⇒ `Promise`
  * [.remove(uuidOrId, key)](#balena.models.device.configVar.remove) ⇒ `Promise`
  * [.set(uuidOrId, key, value)](#balena.models.device.configVar.set) ⇒ `Promise`

***

**configVar.get(uuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.device.configVar)\
**Summary**: Get the value of a specific config variable\
**Access**: public\
**Fulfil**: `String|undefined` - the config variable value (or undefined)

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| key      | `String`             | config variable name                |

**Example**

```js
balena.models.device.configVar.get('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function(value) {
	console.log(value);
});
```

**Example**

```js
balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) {
	console.log(value);
});
```

***

**configVar.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.device.configVar)\
**Summary**: Get all device config variables by application\
**Access**: public\
**Fulfil**: `Object[]` - device config variables

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.device.configVar.getAllByApplication(999999).then(function(vars) {
	console.log(vars);
});
```

***

**configVar.getAllByDevice(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.device.configVar)\
**Summary**: Get all config variables for a device\
**Access**: public\
**Fulfil**: `Object[]` - device config variables

| Param      | Type                 | Default | Description                         |
| ---------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId   | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options] | `Object`             | `{}`    | extra pine options to use           |

**Example**

```js
balena.models.device.configVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.device.configVar.getAllByDevice(999999).then(function(vars) {
	console.log(vars);
});
```

***

**configVar.remove(uuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.device.configVar)\
**Summary**: Clear the value of a specific config variable\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| key      | `String`             | config variable name                |

**Example**

```js
balena.models.device.configVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR').then(function() {
	...
});
```

**Example**

```js
balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() {
	...
});
```

***

**configVar.set(uuidOrId, key, value) ⇒ `Promise`**

**Kind**: static method of [`configVar`](#balena.models.device.configVar)\
**Summary**: Set the value of a specific config variable\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| key      | `String`             | config variable name                |
| value    | `String`             | config variable value               |

**Example**

```js
balena.models.device.configVar.set('7cf02a69e4d34c9da573914963cf54fd', 'BALENA_VAR', 'newvalue').then(function() {
	...
});
```

**Example**

```js
balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() {
	...
});
```

***

**device.envVar : `object`**

**Kind**: static namespace of [`device`](#balena.models.device)

* [.envVar](#balena.models.device.envVar) : `object`
  * [.get(uuidOrId, key)](#balena.models.device.envVar.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.envVar.getAllByApplication) ⇒ `Promise`
  * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.envVar.getAllByDevice) ⇒ `Promise`
  * [.remove(uuidOrId, key)](#balena.models.device.envVar.remove) ⇒ `Promise`
  * [.set(uuidOrId, key, value)](#balena.models.device.envVar.set) ⇒ `Promise`

***

**envVar.get(uuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.device.envVar)\
**Summary**: Get the value of a specific environment variable\
**Access**: public\
**Fulfil**: `String|undefined` - the environment variable value (or undefined)

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| key      | `String`             | environment variable name           |

**Example**

```js
balena.models.device.envVar.get('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function(value) {
	console.log(value);
});
```

**Example**

```js
balena.models.device.envVar.get(999999, 'VAR').then(function(value) {
	console.log(value);
});
```

***

**envVar.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.device.envVar)\
**Summary**: Get all device environment variables by application\
**Access**: public\
**Fulfil**: `Object[]` - device environment variables

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.device.envVar.getAllByApplication(999999).then(function(vars) {
	console.log(vars);
});
```

***

**envVar.getAllByDevice(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.device.envVar)\
**Summary**: Get all environment variables for a device\
**Access**: public\
**Fulfil**: `Object[]` - device environment variables

| Param      | Type                 | Default | Description                         |
| ---------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId   | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options] | `Object`             | `{}`    | extra pine options to use           |

**Example**

```js
balena.models.device.envVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.device.envVar.getAllByDevice(999999).then(function(vars) {
	console.log(vars);
});
```

***

**envVar.remove(uuidOrId, key) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.device.envVar)\
**Summary**: Clear the value of a specific environment variable\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| key      | `String`             | environment variable name           |

**Example**

```js
balena.models.device.envVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'VAR').then(function() {
	...
});
```

**Example**

```js
balena.models.device.envVar.remove(999999, 'VAR').then(function() {
	...
});
```

***

**envVar.set(uuidOrId, key, value) ⇒ `Promise`**

**Kind**: static method of [`envVar`](#balena.models.device.envVar)\
**Summary**: Set the value of a specific environment variable\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| key      | `String`             | environment variable name           |
| value    | `String`             | environment variable value          |

**Example**

```js
balena.models.device.envVar.set('7cf02a69e4d34c9da573914963cf54fd', 'VAR', 'newvalue').then(function() {
	...
});
```

**Example**

```js
balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() {
	...
});
```

***

**device.history : `object`**

**Kind**: static namespace of [`device`](#balena.models.device)

* [.history](#balena.models.device.history) : `object`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.history.getAllByApplication) ⇒ `Promise`
  * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.history.getAllByDevice) ⇒ `Promise`

***

**history.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`history`](#balena.models.device.history)\
**Summary**: Get all device history entries by application with time frame\
**Access**: public\
**Fulfil**: `Object[]` - device history

| Param                  | Type                 | Default                  | Description                                                          |
| ---------------------- | -------------------- | ------------------------ | -------------------------------------------------------------------- |
| slugOrUuidOrId         | `String` \| `Number` |                          | application slug (string), uuid (string) or id (number)              |
| \[dateFilter.fromDate] | `Date`               | `subDays(new Date(), 7)` | history entries older or equal to this date - default now() - 7 days |
| \[dateFilter.toDate]   | `Date`               |                          | history entries younger or equal to this date                        |
| \[options]             | `Object`             |                          | extra pine options to use                                            |

**Example**

```js
balena.models.device.history.getAllByApplication('myorganization/myapp').then(function(entries) {
	console.log(entries);
});
```

**Example**

```js
balena.models.device.history.getAllByApplication(999999).then(function(entries) {
	console.log(entries);
});

 
```

**Example**

```js
// get all device history entries between now - 20 days and now - 10 days
balena.models.device.history.getAllByApplication(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)})
```

**Example**

```js
// get all device history entries between now - 20 days and now - 10 days
balena.models.device.history.getAllByApplication(
  999999,
  { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10),
  { $top: 10, $orderby: { id: 'desc' }}
});
```

***

**history.getAllByDevice(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`history`](#balena.models.device.history)\
**Summary**: Get all history entries for a device\
**Access**: public\
**Fulfil**: `Object[]` - device history

| Param                  | Type                 | Default                  | Description                                                          |
| ---------------------- | -------------------- | ------------------------ | -------------------------------------------------------------------- |
| uuidOrId               | `String` \| `Number` |                          | device uuid (32 / 62 digits string) or id (number)                   |
| \[dateFilter.fromDate] | `Date`               | `subDays(new Date(), 7)` | history entries older or equal to this date - default now() - 7 days |
| \[dateFilter.toDate]   | `Date`               |                          | history entries younger or equal to this date                        |
| \[options]             | `Object`             |                          | extra pine options to use                                            |

**Example**

```js
balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) {
	console.log(entries);
});
```

**Example**

```js
balena.models.device.history.getAllByDevice(999999).then(function(entries) {
	console.log(entries);
});
```

**Example**

```js
// get all device history entries between now - 20 days and now - 10 days
balena.models.device.history.getAllByDevice(999999, { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)})
```

**Example**

```js
// get all device history entries between now - 20 days and now - 10 days
balena.models.device.history.getAllByDevice(
 999999,
 { fromDate: subDays(new Date(), 20), toDate: subDays(new Date(), 10)},
 { $top: 10, $orderby: { id: 'desc' }}
)
```

***

**device.serviceVar : `object`**

**Kind**: static namespace of [`device`](#balena.models.device)

* [.serviceVar](#balena.models.device.serviceVar) : `object`
  * [.get(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.serviceVar.getAllByApplication) ⇒ `Promise`
  * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.serviceVar.getAllByDevice) ⇒ `Promise`
  * [.remove(uuidOrId, serviceNameOrId, key)](#balena.models.device.serviceVar.remove) ⇒ `Promise`
  * [.set(uuidOrId, serviceNameOrId, key, value)](#balena.models.device.serviceVar.set) ⇒ `Promise`

***

**serviceVar.get(uuidOrId, serviceNameOrId, key) ⇒ `Promise`**

**Kind**: static method of [`serviceVar`](#balena.models.device.serviceVar)\
**Summary**: Get the overriden value of a service variable on a device\
**Access**: public\
**Fulfil**: `String|undefined` - the variable value (or undefined)

| Param           | Type                 | Description                          |
| --------------- | -------------------- | ------------------------------------ |
| uuidOrId        | `String` \| `Number` | device uuid (string) or id (number)  |
| serviceNameOrId | `String` \| `Number` | service name (string) or id (number) |
| key             | `String`             | variable name                        |

**Example**

```js
balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function(value) {
	console.log(value);
});
```

**Example**

```js
balena.models.device.serviceVar.get('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function(value) {
	console.log(value);
});
```

**Example**

```js
balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) {
	console.log(value);
});
```

***

**serviceVar.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`serviceVar`](#balena.models.device.serviceVar)\
**Summary**: Get all device service variable overrides by application\
**Access**: public\
**Fulfil**: `Object[]` - service variables

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) {
	console.log(vars);
});
```

***

**serviceVar.getAllByDevice(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`serviceVar`](#balena.models.device.serviceVar)\
**Summary**: Get all service variable overrides for a device\
**Access**: public\
**Fulfil**: `Object[]` - service variables

| Param      | Type                 | Default | Description                         |
| ---------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId   | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options] | `Object`             | `{}`    | extra pine options to use           |

**Example**

```js
balena.models.device.serviceVar.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) {
	console.log(vars);
});
```

***

**serviceVar.remove(uuidOrId, serviceNameOrId, key) ⇒ `Promise`**

**Kind**: static method of [`serviceVar`](#balena.models.device.serviceVar)\
**Summary**: Clear the overridden value of a service variable on a device\
**Access**: public

| Param           | Type                 | Description                          |
| --------------- | -------------------- | ------------------------------------ |
| uuidOrId        | `String` \| `Number` | device uuid (string) or id (number)  |
| serviceNameOrId | `String` \| `Number` | service name (string) or id (number) |
| key             | `String`             | variable name                        |

**Example**

```js
balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR').then(function() {
	...
});
```

**Example**

```js
balena.models.device.serviceVar.remove('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR').then(function() {
	...
});
```

**Example**

```js
balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() {
	...
});
```

***

**serviceVar.set(uuidOrId, serviceNameOrId, key, value) ⇒ `Promise`**

**Kind**: static method of [`serviceVar`](#balena.models.device.serviceVar)\
**Summary**: Set the overriden value of a service variable on a device\
**Access**: public

| Param           | Type                 | Description                          |
| --------------- | -------------------- | ------------------------------------ |
| uuidOrId        | `String` \| `Number` | device uuid (string) or id (number)  |
| serviceNameOrId | `String` \| `Number` | service name (string) or id (number) |
| key             | `String`             | variable name                        |
| value           | `String`             | variable value                       |

**Example**

```js
balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 123, 'VAR', 'override').then(function() {
	...
});
```

**Example**

```js
balena.models.device.serviceVar.set('7cf02a69e4d34c9da573914963cf54fd', 'myservice', 'VAR', 'override').then(function() {
	...
});
```

**Example**

```js
balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() {
	...
});
```

***

**device.tags : `object`**

**Kind**: static namespace of [`device`](#balena.models.device)

* [.tags](#balena.models.device.tags) : `object`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.device.tags.getAllByApplication) ⇒ `Promise`
  * [.getAllByDevice(uuidOrId, \[options\])](#balena.models.device.tags.getAllByDevice) ⇒ `Promise`
  * [.remove(uuidOrId, tagKey)](#balena.models.device.tags.remove) ⇒ `Promise`
  * [.set(uuidOrId, tagKey, value)](#balena.models.device.tags.set) ⇒ `Promise`

***

**tags.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.device.tags)\
**Summary**: Get all device tags for an application\
**Access**: public\
**Fulfil**: `Object[]` - device tags

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) {
	console.log(tags);
});
```

**Example**

```js
balena.models.device.tags.getAllByApplication(999999).then(function(tags) {
	console.log(tags);
});
```

***

**tags.getAllByDevice(uuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.device.tags)\
**Summary**: Get all device tags for a device\
**Access**: public\
**Fulfil**: `Object[]` - device tags

| Param      | Type                 | Default | Description                         |
| ---------- | -------------------- | ------- | ----------------------------------- |
| uuidOrId   | `String` \| `Number` |         | device uuid (string) or id (number) |
| \[options] | `Object`             | `{}`    | extra pine options to use           |

**Example**

```js
balena.models.device.tags.getAllByDevice('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) {
	console.log(tags);
});
```

**Example**

```js
balena.models.device.tags.getAllByDevice(123).then(function(tags) {
	console.log(tags);
});
```

***

**tags.remove(uuidOrId, tagKey) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.device.tags)\
**Summary**: Remove a device tag\
**Access**: public

| Param    | Type                 | Description                         |
| -------- | -------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number` | device uuid (string) or id (number) |
| tagKey   | `String`             | tag key                             |

**Example**

```js
balena.models.device.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR');
```

***

**tags.set(uuidOrId, tagKey, value) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.device.tags)\
**Summary**: Set a device tag\
**Access**: public

| Param    | Type                    | Description                         |
| -------- | ----------------------- | ----------------------------------- |
| uuidOrId | `String` \| `Number`    | device uuid (string) or id (number) |
| tagKey   | `String`                | tag key                             |
| value    | `String` \| `undefined` | tag value                           |

**Example**

```js
balena.models.device.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim');
```

**Example**

```js
balena.models.device.tags.set(123, 'EDITOR', 'vim');
```

***

#### models.deviceType : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.deviceType](#balena.models.deviceType) : `object`
  * [.get(idOrSlug, \[options\])](#balena.models.deviceType.get) ⇒ `Promise`
  * [.getAll(\[options\])](#balena.models.deviceType.getAll) ⇒ `Promise`
  * [.getAllSupported(\[options\])](#balena.models.deviceType.getAllSupported) ⇒ `Promise`
  * [.getBySlugOrName(slugOrName)](#balena.models.deviceType.getBySlugOrName) ⇒ `Promise`
  * [.getInstallMethod(deviceTypeSlug)](#balena.models.deviceType.getInstallMethod) ⇒ `Promise`
  * [.getInstructions(deviceTypeSlugOrContract)](#balena.models.deviceType.getInstructions) ⇒ `Promise`
  * [.getInterpolatedPartials(deviceTypeSlug)](#balena.models.deviceType.getInterpolatedPartials) ⇒ `Promise`
  * [.getName(deviceTypeSlug)](#balena.models.deviceType.getName) ⇒ `Promise`
  * [.getSlugByName(deviceTypeName)](#balena.models.deviceType.getSlugByName) ⇒ `Promise`

***

**deviceType.get(idOrSlug, \[options]) ⇒ `Promise`**

This method returns a single device type.

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get a single deviceType\
**Access**: public\
**Fulfil**: `Object[]` - device types

| Param      | Type                 | Default | Description                                       |
| ---------- | -------------------- | ------- | ------------------------------------------------- |
| idOrSlug   | `String` \| `Number` |         | device type slug (string) or alias (string) or id |
| \[options] | `Object`             | `{}`    | extra pine options to use                         |

**Example**

```js
balena.models.deviceType.get('raspberry-pi').then(function(deviceType) {
	console.log(deviceType);
});
```

**Example**

```js
balena.models.deviceType.get('raspberrypi').then(function(deviceType) {
	console.log('resolved alias:', deviceType);
});
```

***

**deviceType.getAll(\[options]) ⇒ `Promise`**

This method returns all device types.

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get all deviceTypes\
**Access**: public\
**Fulfil**: `Object[]` - device types

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.deviceType.getAll().then(function(deviceTypes) {
	console.log(deviceTypes);
});
```

**Example**

```js
balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) {
	console.log(deviceTypes);
})
```

***

**deviceType.getAllSupported(\[options]) ⇒ `Promise`**

This method returns all supported device types.

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get all supported deviceTypes\
**Access**: public\
**Fulfil**: `Object[]` - device types

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.deviceType.getAllSupported().then(function(deviceTypes) {
	console.log(deviceTypes);
});
```

**Example**

```js
balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) {
	console.log(deviceTypes);
})
```

***

**deviceType.getBySlugOrName(slugOrName) ⇒ `Promise`**

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get a deviceType by slug or name\
**Access**: public\
**Fulfil**: `Object` - device type

| Param      | Type     | Description     |
| ---------- | -------- | --------------- |
| slugOrName | `String` | deviceType slug |

**Example**

```js
balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) {
	console.log(deviceType);
});
```

***

**deviceType.getInstallMethod(deviceTypeSlug) ⇒ `Promise`**

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get installation method on a given device type\
**Access**: public\
**Fulfil**: `String` - the installation method supported for the given device type slug

| Param          | Type     | Description      |
| -------------- | -------- | ---------------- |
| deviceTypeSlug | `String` | device type slug |

**Example**

```js
balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) {
	console.log(method);
 // externalBoot
});
```

***

**deviceType.getInstructions(deviceTypeSlugOrContract) ⇒ `Promise`**

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get instructions for installing a host OS on a given device type\
**Access**: public\
**Fulfil**: `Object | String[]` - step by step instructions for installing the host OS to the device

| Param                    | Type                 | Description                  |
| ------------------------ | -------------------- | ---------------------------- |
| deviceTypeSlugOrContract | `String` \| `Object` | device type slug or contract |

**Example**

```js
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 <a href="https://etcher.balena.io/">Etcher</a>.
 // 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.
});
```

***

**deviceType.getInterpolatedPartials(deviceTypeSlug) ⇒ `Promise`**

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get a contract with resolved partial templates\
**Access**: public\
**Fulfil**: `Contract` - device type contract with resolved partials

| Param          | Type     | Description      |
| -------------- | -------- | ---------------- |
| deviceTypeSlug | `String` | device type slug |

**Example**

```js
balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) {
 for (const partial in contract.partials) {
 	console.log(`${partial}: ${contract.partials[partial]}`);
 }
	// bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"]
});
```

***

**deviceType.getName(deviceTypeSlug) ⇒ `Promise`**

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get display name for a device\
**Access**: public\
**Fulfil**: `String` - device display name

| Param          | Type     | Description      |
| -------------- | -------- | ---------------- |
| deviceTypeSlug | `String` | device type slug |

**Example**

```js
balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) {
	console.log(deviceTypeName);
	// Raspberry Pi
});
```

***

**deviceType.getSlugByName(deviceTypeName) ⇒ `Promise`**

**Kind**: static method of [`deviceType`](#balena.models.deviceType)\
**Summary**: Get device slug\
**Access**: public\
**Fulfil**: `String` - device slug name

| Param          | Type     | Description      |
| -------------- | -------- | ---------------- |
| deviceTypeName | `String` | device type name |

**Example**

```js
balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) {
	console.log(deviceTypeSlug);
	// raspberry-pi
});
```

***

#### models.image : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.image](#balena.models.image) : `object`
  * [.get(id, \[options\])](#balena.models.image.get) ⇒ `Promise`
  * [.getLogs(id)](#balena.models.image.getLogs) ⇒ `Promise`

***

**image.get(id, \[options]) ⇒ `Promise`**

**Kind**: static method of [`image`](#balena.models.image)\
**Summary**: Get a specific image\
**Access**: public\
**Fulfil**: `Object` - image

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| id         | `Number` |         | image id                  |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.image.get(123).then(function(image) {
	console.log(image);
});
```

***

**image.getLogs(id) ⇒ `Promise`**

**Kind**: static method of [`image`](#balena.models.image)\
**Summary**: Get the logs for an image\
**Access**: public\
**Fulfil**: `string | null` - logs

| Param | Type     | Description |
| ----- | -------- | ----------- |
| id    | `Number` | image id    |

**Example**

```js
balena.models.image.getLogs(123).then(function(logs) {
	console.log(logs);
});
```

***

#### models.key : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.key](#balena.models.key) : `object`
  * [.create(title, key)](#balena.models.key.create) ⇒ `Promise`
  * [.get(id)](#balena.models.key.get) ⇒ `Promise`
  * [.getAll(\[options\])](#balena.models.key.getAll) ⇒ `Promise`
  * [.remove(id)](#balena.models.key.remove) ⇒ `Promise`

***

**key.create(title, key) ⇒ `Promise`**

**Kind**: static method of [`key`](#balena.models.key)\
**Summary**: Create a ssh key\
**Access**: public\
**Fulfil**: `Object` - ssh key

| Param | Type     | Description        |
| ----- | -------- | ------------------ |
| title | `String` | key title          |
| key   | `String` | the public ssh key |

**Example**

```js
balena.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) {
	console.log(key);
});
```

***

**key.get(id) ⇒ `Promise`**

**Kind**: static method of [`key`](#balena.models.key)\
**Summary**: Get a single ssh key\
**Access**: public\
**Fulfil**: `Object` - ssh key

| Param | Type     | Description |
| ----- | -------- | ----------- |
| id    | `Number` | key id      |

**Example**

```js
balena.models.key.get(51).then(function(key) {
	console.log(key);
});
```

***

**key.getAll(\[options]) ⇒ `Promise`**

**Kind**: static method of [`key`](#balena.models.key)\
**Summary**: Get all ssh keys\
**Access**: public\
**Fulfil**: `Object[]` - ssh keys

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.key.getAll().then(function(keys) {
	console.log(keys);
});
```

***

**key.remove(id) ⇒ `Promise`**

**Kind**: static method of [`key`](#balena.models.key)\
**Summary**: Remove ssh key\
**Access**: public

| Param | Type     | Description |
| ----- | -------- | ----------- |
| id    | `Number` | key id      |

**Example**

```js
balena.models.key.remove(51);
```

***

#### models.organization : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.organization](#balena.models.organization) : `object`
  * [.create(options)](#balena.models.organization.create) ⇒ `Promise`
  * [.get(handleOrId, \[options\])](#balena.models.organization.get) ⇒ `Promise`
  * [.getAll(\[options\])](#balena.models.organization.getAll) ⇒ `Promise`
  * [.remove(handleOrId)](#balena.models.organization.remove) ⇒ `Promise`
  * [.invite](#balena.models.organization.invite) : `object`
    * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ `Promise`
    * [.create(handleOrId, options, \[message\])](#balena.models.organization.invite.create) ⇒ `Promise`
    * [.getAll(\[options\])](#balena.models.organization.invite.getAll) ⇒ `Promise`
    * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.organization.invite.getAllByOrganization) ⇒ `Promise`
    * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ `Promise`
  * [.membership](#balena.models.organization.membership) : `object`
    * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ `Promise`
    * [.get(membershipId, \[options\])](#balena.models.organization.membership.get) ⇒ `Promise`
    * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.organization.membership.getAllByOrganization) ⇒ `Promise`
    * [.getAllByUser(usernameOrId, \[options\])](#balena.models.organization.membership.getAllByUser) ⇒ `Promise`
    * [.remove(id)](#balena.models.organization.membership.remove) ⇒ `Promise`

***

**organization.create(options) ⇒ `Promise`**

This method creates a new organization with the current user as an administrator.

**Kind**: static method of [`organization`](#balena.models.organization)\
**Summary**: Creates a new organization\
**Access**: public\
**Fulfil**: `String` - Organization

| Param             | Type     | Description                                                  |
| ----------------- | -------- | ------------------------------------------------------------ |
| options           | `Object` | Organization parameters to use.                              |
| options.name      | `String` | Required: the name of the organization that will be created. |
| \[options.handle] | `String` | The handle of the organization that will be created.         |

**Example**

```js
balena.models.organization.create({ name:'MyOrganization' }).then(function(organization) {
	console.log(organization);
});
```

**Example**

```js
balena.models.organization.create({
  name:'MyOrganization',
  logo_image: new File(
    imageContent,
    'img.jpeg'
  );
})
.then(function(organization) {
  console.log(organization);
});
```

***

**organization.get(handleOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`organization`](#balena.models.organization)\
**Summary**: Get a single organization\
**Access**: public\
**Fulfil**: `Object` - organization

| Param      | Type                 | Default | Description                                  |
| ---------- | -------------------- | ------- | -------------------------------------------- |
| handleOrId | `String` \| `Number` |         | organization handle (string) or id (number). |
| \[options] | `Object`             | `{}`    | extra pine options to use                    |

**Example**

```js
balena.models.organization.get('myorganization').then(function(organization) {
	console.log(organization);
});
```

**Example**

```js
balena.models.organization.get(123).then(function(organization) {
	console.log(organization);
});
```

***

**organization.getAll(\[options]) ⇒ `Promise`**

**Kind**: static method of [`organization`](#balena.models.organization)\
**Summary**: Get all Organizations\
**Access**: public\
**Fulfil**: `Object[]` - organizations

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.organization.getAll().then(function(organizations) {
	console.log(organizations);
});
```

***

**organization.remove(handleOrId) ⇒ `Promise`**

**Kind**: static method of [`organization`](#balena.models.organization)\
**Summary**: Remove an Organization\
**Access**: public

| Param      | Type                 | Description                                  |
| ---------- | -------------------- | -------------------------------------------- |
| handleOrId | `String` \| `Number` | organization handle (string) or id (number). |

**Example**

```js
balena.models.organization.remove(123);
```

***

**organization.invite : `object`**

**Kind**: static namespace of [`organization`](#balena.models.organization)

* [.invite](#balena.models.organization.invite) : `object`
  * [.accept(invitationToken)](#balena.models.organization.invite.accept) ⇒ `Promise`
  * [.create(handleOrId, options, \[message\])](#balena.models.organization.invite.create) ⇒ `Promise`
  * [.getAll(\[options\])](#balena.models.organization.invite.getAll) ⇒ `Promise`
  * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.organization.invite.getAllByOrganization) ⇒ `Promise`
  * [.revoke(id)](#balena.models.organization.invite.revoke) ⇒ `Promise`

***

**invite.accept(invitationToken) ⇒ `Promise`**

This method adds the calling user to the organization.

**Kind**: static method of [`invite`](#balena.models.organization.invite)\
**Summary**: Accepts an invite\
**Access**: public

| Param           | Type     | Description  |
| --------------- | -------- | ------------ |
| invitationToken | `String` | invite token |

**Example**

```js
balena.models.organization.invite.accept("qwerty-invitation-token");
```

***

**invite.create(handleOrId, options, \[message]) ⇒ `Promise`**

This method invites a user by their email to an organization.

**Kind**: static method of [`invite`](#balena.models.organization.invite)\
**Summary**: Creates a new invite for an organization\
**Access**: public\
**Fulfil**: `String` - organization invite

| Param               | Type                 | Default       | Description                                  |
| ------------------- | -------------------- | ------------- | -------------------------------------------- |
| handleOrId          | `String` \| `Number` |               | organization handle (string), or id (number) |
| options             | `Object`             |               | invite creation parameters                   |
| options.invitee     | `String`             |               | the email of the invitee                     |
| \[options.roleName] | `String`             | `"developer"` | the role name to be granted to the invitee   |
| \[message]          | `String`             |               | the message to send along with the invite    |

**Example**

```js
balena.models.organization.invite.create('MyOrg', { invitee: "invitee@example.org", roleName: "developer", message: "join my org" }).then(function(invite) {
	console.log(invite);
});
```

***

**invite.getAll(\[options]) ⇒ `Promise`**

This method returns all invites.

**Kind**: static method of [`invite`](#balena.models.organization.invite)\
**Summary**: Get all invites\
**Access**: public\
**Fulfil**: `Object[]` - invites

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.organization.invite.getAll().then(function(invites) {
	console.log(invites);
});
```

***

**invite.getAllByOrganization(handleOrId, \[options]) ⇒ `Promise`**

This method returns all invites for a specific organization.

**Kind**: static method of [`invite`](#balena.models.organization.invite)\
**Summary**: Get all invites by organization\
**Access**: public\
**Fulfil**: `Object[]` - invites

| Param      | Type                 | Default | Description                                  |
| ---------- | -------------------- | ------- | -------------------------------------------- |
| handleOrId | `String` \| `Number` |         | organization handle (string), or id (number) |
| \[options] | `Object`             | `{}`    | extra pine options to use                    |

**Example**

```js
balena.models.organization.invite.getAllByOrganization('MyOrg').then(function(invites) {
	console.log(invites);
});
```

**Example**

```js
balena.models.organization.invite.getAllByOrganization(123).then(function(invites) {
	console.log(invites);
});
```

***

**invite.revoke(id) ⇒ `Promise`**

**Kind**: static method of [`invite`](#balena.models.organization.invite)\
**Summary**: Revoke an invite\
**Access**: public

| Param | Type     | Description            |
| ----- | -------- | ---------------------- |
| id    | `Number` | organization invite id |

**Example**

```js
balena.models.organization.invite.revoke(123);
```

***

**organization.membership : `object`**

**Kind**: static namespace of [`organization`](#balena.models.organization)

* [.membership](#balena.models.organization.membership) : `object`
  * [.changeRole(idOrUniqueKey, roleName)](#balena.models.organization.membership.changeRole) ⇒ `Promise`
  * [.get(membershipId, \[options\])](#balena.models.organization.membership.get) ⇒ `Promise`
  * [.getAllByOrganization(handleOrId, \[options\])](#balena.models.organization.membership.getAllByOrganization) ⇒ `Promise`
  * [.getAllByUser(usernameOrId, \[options\])](#balena.models.organization.membership.getAllByUser) ⇒ `Promise`
  * [.remove(id)](#balena.models.organization.membership.remove) ⇒ `Promise`

***

**membership.changeRole(idOrUniqueKey, roleName) ⇒ `Promise`**

This method changes the role of an organization member.

**Kind**: static method of [`membership`](#balena.models.organization.membership)\
**Summary**: Changes the role of an organization member\
**Access**: public

| Param         | Type                 | Description                                                                                                                   |
| ------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| idOrUniqueKey | `Number` \| `Object` | the id or an object with the unique `user` & `is_member_of__organization` numeric pair of the membership that will be changed |
| roleName      | `String`             | the role name to be granted to the membership                                                                                 |

**Example**

```js
balena.models.organization.membership.changeRole(123, "member").then(function() {
	console.log('OK');
});
```

**Example**

```js
balena.models.organization.membership.changeRole({
	user: 123,
	is_member_of__organization: 125,
}, "member").then(function() {
	console.log('OK');
});
```

***

**membership.get(membershipId, \[options]) ⇒ `Promise`**

This method returns a single organization membership.

**Kind**: static method of [`membership`](#balena.models.organization.membership)\
**Summary**: Get a single organization membership\
**Access**: public\
**Fulfil**: `Object` - organization membership

| Param        | Type                 | Default | Description                                                                                              |
| ------------ | -------------------- | ------- | -------------------------------------------------------------------------------------------------------- |
| membershipId | `number` \| `Object` |         | the id or an object with the unique `user` & `is_member_of__organization` numeric pair of the membership |
| \[options]   | `Object`             | `{}`    | extra pine options to use                                                                                |

**Example**

```js
balena.models.organization.membership.get(5).then(function(memberships) {
	console.log(memberships);
});
```

***

**membership.getAllByOrganization(handleOrId, \[options]) ⇒ `Promise`**

This method returns all organization memberships for a specific organization.

**Kind**: static method of [`membership`](#balena.models.organization.membership)\
**Summary**: Get all memberships by organization\
**Access**: public\
**Fulfil**: `Object[]` - organization memberships

| Param      | Type                 | Default | Description                                  |
| ---------- | -------------------- | ------- | -------------------------------------------- |
| handleOrId | `String` \| `Number` |         | organization handle (string) or id (number). |
| \[options] | `Object`             | `{}`    | extra pine options to use                    |

**Example**

```js
balena.models.organization.membership.getAllByOrganization('MyOrg').then(function(memberships) {
	console.log(memberships);
});
```

**Example**

```js
balena.models.organization.membership.getAllByOrganization(123).then(function(memberships) {
	console.log(memberships);
});
```

***

**membership.getAllByUser(usernameOrId, \[options]) ⇒ `Promise`**

This method returns all organization memberships for a specific user.

**Kind**: static method of [`membership`](#balena.models.organization.membership)\
**Summary**: Get all memberships by user\
**Access**: public\
**Fulfil**: `Object[]` - organization memberships

| Param        | Type                 | Default | Description                                 |
| ------------ | -------------------- | ------- | ------------------------------------------- |
| usernameOrId | `String` \| `Number` |         | the user's username (string) or id (number) |
| \[options]   | `Object`             | `{}`    | extra pine options to use                   |

**Example**

```js
balena.models.organization.membership.getAllByUser('balena_os').then(function(memberships) {
	console.log(memberships);
});
```

**Example**

```js
balena.models.organization.membership.getAllByUser(123).then(function(memberships) {
	console.log(memberships);
});
```

***

**membership.remove(id) ⇒ `Promise`**

**Kind**: static method of [`membership`](#balena.models.organization.membership)\
**Summary**: Remove a membership\
**Access**: public

| Param | Type     | Description                |
| ----- | -------- | -------------------------- |
| id    | `Number` | organization membership id |

**Example**

```js
balena.models.organization.membership.remove(123);
```

**Example**

```js
balena.models.organization.membership.remove({
	user: 123,
	is_member_of__application: 125,
});
```

***

#### models.os : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.os](#balena.models.os) : `object`
  * [.download(options)](#balena.models.os.download) ⇒ `Promise`
  * [.getAllOsVersions(deviceTypes, \[options\])](#balena.models.os.getAllOsVersions) ⇒ `Promise`
  * [.getAvailableOsVersions(deviceTypes, \[pineOptions\], \[extraOptions\])](#balena.models.os.getAvailableOsVersions) ⇒ `Promise`
  * [.getConfig(slugOrUuidOrId, options)](#balena.models.os.getConfig) ⇒ `Promise`
  * [.getDownloadSize(deviceType, \[version\])](#balena.models.os.getDownloadSize) ⇒ `Promise`
  * [.getMaxSatisfyingVersion(deviceType, versionOrRange, \[osType\])](#balena.models.os.getMaxSatisfyingVersion) ⇒ `Promise`
  * [.getOsUpdateType(deviceType, currentVersion, targetVersion)](#balena.models.os.getOsUpdateType) ⇒ `Promise`
  * [.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, \[options\])](#balena.models.os.getSupervisorReleasesForCpuArchitecture) ⇒ `Promise.<String>`
  * [.getSupportedOsUpdateVersions(deviceType, currentVersion, \[options\])](#balena.models.os.getSupportedOsUpdateVersions) ⇒ `Promise`
  * [.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture)](#balena.models.os.isArchitectureCompatibleWith) ⇒ `Boolean`
  * [.isSupportedOsUpdate(deviceType, currentVersion, targetVersion)](#balena.models.os.isSupportedOsUpdate) ⇒ `Promise`

***

**os.download(options) ⇒ `Promise`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Download an OS image\
**Access**: public\
**Fulfil**: `ReadableStream` - download stream

| Param                            | Type      | Default    | Description                                                                                                                                                               |
| -------------------------------- | --------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options                          | `Object`  |            | OS image options to use.                                                                                                                                                  |
| options.deviceType               | `String`  |            | device type slug                                                                                                                                                          |
| \[options.version]               | `String`  | `'latest'` | semver-compatible version or 'latest', defaults to 'latest' Unsupported (unpublished) version will result in rejection. The version **must** be the exact version number. |
| \[options.developmentMode]       | `Boolean` |            | controls development mode for unified balenaOS releases.                                                                                                                  |
| \[options.appId]                 | `Number`  |            | the application ID (number).                                                                                                                                              |
| \[options.fileType]              | `String`  |            | download file type. One of '.img' or '.zip' or '.gz'.                                                                                                                     |
| \[options.imageType]             | `String`  |            | download file type. One of 'raw' or 'flasher'                                                                                                                             |
| \[options.appUpdatePollInterval] | `Number`  |            | how often the OS checks for updates, in minutes.                                                                                                                          |
| \[options.network]               | `String`  |            | the network type that the device will use, one of 'ethernet' or 'wifi'.                                                                                                   |
| \[options.wifiKey]               | `String`  |            | the key for the wifi network the device will connect to if network is wifi.                                                                                               |
| \[options.wifiSsid]              | `String`  |            | the ssid for the wifi network the device will connect to if network is wifi.                                                                                              |

**Example**

```js
balena.models.os.download({deviceType: 'raspberry-pi'}).then(function(stream) {
	stream.pipe(fs.createWriteStream('foo/bar/image.img'));
});
```

***

**os.getAllOsVersions(deviceTypes, \[options]) ⇒ `Promise`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Get all OS versions for the provided device type(s), inlcuding invalidated ones\
**Access**: public\
**Fulfil**: `Object[]|Object` - An array of OsVersion objects when a single device type slug is provided, or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided.

| Param       | Type                         | Default | Description                        |
| ----------- | ---------------------------- | ------- | ---------------------------------- |
| deviceTypes | `String` \| `Array.<String>` |         | device type slug or array of slugs |
| \[options]  | `Object`                     | `{}`    | extra pine options to use          |

**Example**

```js
balena.models.os.getAllOsVersions('raspberrypi3');
```

**Example**

```js
balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3']);
```

**Example**

```js
balena.models.os.getAllOsVersions(['fincm3', 'raspberrypi3'], { $filter: { is_invalidated: false } });
```

***

**os.getAvailableOsVersions(deviceTypes, \[pineOptions], \[extraOptions]) ⇒ `Promise`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Get the supported OS versions for the provided device type(s)\
**Access**: public\
**Fulfil**: `Object[]|Object` - An array of OsVersion objects when a single device type slug is provided, or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided.

| Param                        | Type                         | Default | Description                                            |
| ---------------------------- | ---------------------------- | ------- | ------------------------------------------------------ |
| deviceTypes                  | `String` \| `Array.<String>` |         | device type slug or array of slugs                     |
| \[pineOptions]               | `Object`                     |         | Extra pine options to use                              |
| \[extraOptions]              | `Object`                     |         | Extra convenience options to use                       |
| \[extraOptions.includeDraft] | `Boolean`                    | `false` | Whether pre-releases should be included in the results |

**Example**

```js
balena.models.os.getAvailableOsVersions('raspberrypi3');
```

**Example**

```js
balena.models.os.getAvailableOsVersions(['fincm3', 'raspberrypi3']);
```

***

**os.getConfig(slugOrUuidOrId, options) ⇒ `Promise`**

Builds the config.json for a device in the given application, with the given options.

Note that an OS version is required. For versions < 2.7.8, config generation is only supported when using a session token, not an API key.

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Get an applications config.json\
**Access**: public\
**Fulfil**: `Object` - application configuration as a JSON object.

| Param                                | Type                 | Default      | Description                                                             |
| ------------------------------------ | -------------------- | ------------ | ----------------------------------------------------------------------- |
| slugOrUuidOrId                       | `String` \| `Number` |              | application slug (string), uuid (string) or id (number).                |
| options                              | `Object`             |              | OS configuration options to use.                                        |
| options.version                      | `String`             |              | Required: the OS version of the image.                                  |
| \[options.network]                   | `String`             | `'ethernet'` | The network type that the device will use, one of 'ethernet' or 'wifi'. |
| \[options.appUpdatePollInterval]     | `Number`             |              | How often the OS checks for updates, in minutes.                        |
| \[options.provisioningKeyName]       | `String`             |              | Name assigned to API key                                                |
| \[options.provisioningKeyExpiryDate] | `String`             |              | Expiry Date assigned to API key                                         |
| \[options.developmentMode]           | `Boolean`            |              | Controls development mode for unified balenaOS releases.                |
| \[options.wifiKey]                   | `String`             |              | The key for the wifi network the device will connect to.                |
| \[options.wifiSsid]                  | `String`             |              | The ssid for the wifi network the device will connect to.               |
| \[options.ip]                        | `String`             |              | static ip address.                                                      |
| \[options.gateway]                   | `String`             |              | static ip gateway.                                                      |
| \[options.netmask]                   | `String`             |              | static ip netmask.                                                      |

**Example**

```js
balena.models.os.getConfig('myorganization/myapp', { version: '2.12.7+rev1.prod' }).then(function(config) {
	fs.writeFile('foo/bar/config.json', JSON.stringify(config));
});

balena.models.os.getConfig(123, { version: '2.12.7+rev1.prod' }).then(function(config) {
	fs.writeFile('foo/bar/config.json', JSON.stringify(config));
});
```

***

**os.getDownloadSize(deviceType, \[version]) ⇒ `Promise`**

**Note!** Currently only the raw (uncompressed) size is reported.

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Get OS download size estimate\
**Access**: public\
**Fulfil**: `Number` - OS image download size, in bytes.

| Param      | Type     | Description                                                                                                    |
| ---------- | -------- | -------------------------------------------------------------------------------------------------------------- |
| deviceType | `String` | device type slug                                                                                               |
| \[version] | `String` | semver-compatible version or 'latest', defaults to 'latest'. The version **must** be the exact version number. |

**Example**

```js
balena.models.os.getDownloadSize('raspberry-pi').then(function(size) {
	console.log('The OS download size for raspberry-pi', size);
});
```

***

**os.getMaxSatisfyingVersion(deviceType, versionOrRange, \[osType]) ⇒ `Promise`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Get the max OS version satisfying the given range\
**Access**: public\
**Fulfil**: `String|null` - the version number, or `null` if no matching versions are found

| Param          | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| -------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| deviceType     | `String` | device type slug                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| versionOrRange | `String` | <p>can be one of</p><ul><li>the exact version number, in which case it is returned if the version is supported, or <code>null</code> is returned otherwise,</li><li>a <a href="https://www.npmjs.com/package/semver">semver</a>-compatible range specification, in which case the most recent satisfying version is returned if it exists, or <code>null</code> is returned,</li><li><code>'latest'</code> in which case the most recent version is returned, excluding pre-releases, Defaults to <code>'latest'</code>.</li></ul> |
| \[osType]      | `String` | can be one of 'default', 'esr' or null to include all types                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

**Example**

```js
balena.models.os.getMaxSatisfyingVersion('raspberry-pi', '^2.11.0').then(function(version) {
	console.log(version);
});
```

***

**os.getOsUpdateType(deviceType, currentVersion, targetVersion) ⇒ `Promise`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Returns the OS update type based on device type, current and target balenaOS versions\
**Access**: public\
**Fulfil**: `String` - Currently available types are:

* resinhup11
* resinhup12
* balenahup
  * takeover

Throws error in any of these cases:

* Current or target versions are invalid
* Current or target versions do not match in dev/prod type
* Current and target versions imply a downgrade operation
* Action is not supported by device type

| Param          | Type     | Description                                           |
| -------------- | -------- | ----------------------------------------------------- |
| deviceType     | `String` | device type slug                                      |
| currentVersion | `String` | semver-compatible version for the starting OS version |
| targetVersion  | `String` | semver-compatible version for the target OS version   |

**Example**

```js
balena.models.os.getOsUpdateType('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(osUpdateType) {
	console.log(osUpdateType);
});
```

***

**os.getSupervisorReleasesForCpuArchitecture(cpuArchitectureSlugOrId, \[options]) ⇒ `Promise.<String>`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Returns the Releases of the supervisor for the CPU Architecture\
**Returns**: `Promise.<String>` - - An array of Release objects that can be used to manage a device as supervisors.\
**Access**: public

| Param                   | Type                 | Default | Description                                               |
| ----------------------- | -------------------- | ------- | --------------------------------------------------------- |
| cpuArchitectureSlugOrId | `String` \| `Number` |         | The slug (string) or id (number) for the CPU Architecture |
| \[options]              | `Object`             | `{}`    | extra pine options to use                                 |

**Example**

```js
const results = balena.models.os.getSupervisorReleasesForCpuArchitecture('aarch64');

const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture(
	'aarch64',
	{ $filter: { raw_version: '12.11.0' } },
);

const [result] = balena.models.os.getSupervisorReleasesForCpuArchitecture(
	'aarch64',
	{
			$select: ['id', 'raw_version', 'known_issue_list', 'created_at', 'contract'],
			$expand: {
				release_image: {
					$select: 'id',
					$expand: {
						image: {
							$select: 'is_stored_at__image_location',
						},
					},
				},
			},
		$filter: { raw_version: '12.11.0' }
	},
);
```

***

**os.getSupportedOsUpdateVersions(deviceType, currentVersion, \[options]) ⇒ `Promise`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Returns the supported OS update targets for the provided device type\
**Access**: public\
**Fulfil**: `Object[]|Object` - An array of OsVersion objects when a single device type slug is provided, or a dictionary of OsVersion objects by device type slug when an array of device type slugs is provided.\
**Fulfil**: `Object` - the versions information, of the following structure:

* versions - an array of strings, containing exact version numbers that OS update is supported
* recommended - the recommended version, i.e. the most recent version that is *not* pre-release, can be `null`
* current - the provided current version after normalization

| Param                   | Type               | Default | Description                                                     |
| ----------------------- | ------------------ | ------- | --------------------------------------------------------------- |
| deviceType              | `String`           |         | device type slug                                                |
| currentVersion          | `String`           |         | semver-compatible version for the starting OS version           |
| \[options]              | `Object`           |         | Extra options to filter the OS releases by                      |
| \[options.includeDraft] | `Boolean`          | `false` | Whether pre-releases should be included in the results          |
| \[options.osType]       | `String` \| `null` |         | Can be one of 'default', 'esr' or null which includes all types |

**Example**

```js
balena.models.os.getSupportedOsUpdateVersions('raspberry-pi', '2.9.6+rev2.prod').then(function(isSupported) {
	console.log(isSupported);
});
```

***

**os.isArchitectureCompatibleWith(osArchitecture, applicationArchitecture) ⇒ `Boolean`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Returns whether the specified OS architecture is compatible with the target architecture\
**Returns**: `Boolean` - - Whether the specified OS architecture is capable of running applications build for the target architecture\
**Access**: public

| Param                   | Type     | Description                                                    |
| ----------------------- | -------- | -------------------------------------------------------------- |
| osArchitecture          | `String` | The OS's architecture as specified in its device type          |
| applicationArchitecture | `String` | The application's architecture as specified in its device type |

**Example**

```js
const result1 = balena.models.os.isArchitectureCompatibleWith('aarch64', 'armv7hf');
console.log(result1);

const result2 = balena.models.os.isArchitectureCompatibleWith('armv7hf', 'amd64');
console.log(result2);
```

***

**os.isSupportedOsUpdate(deviceType, currentVersion, targetVersion) ⇒ `Promise`**

**Kind**: static method of [`os`](#balena.models.os)\
**Summary**: Returns whether the provided device type supports OS updates between the provided balenaOS versions\
**Access**: public\
**Fulfil**: `Boolean` - whether upgrading the OS to the target version is supported

| Param          | Type     | Description                                           |
| -------------- | -------- | ----------------------------------------------------- |
| deviceType     | `String` | device type slug                                      |
| currentVersion | `String` | semver-compatible version for the starting OS version |
| targetVersion  | `String` | semver-compatible version for the target OS version   |

**Example**

```js
balena.models.os.isSupportedOsUpgrade('raspberry-pi', '2.9.6+rev2.prod', '2.29.2+rev1.prod').then(function(isSupported) {
	console.log(isSupported);
});
```

***

#### models.release : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.release](#balena.models.release) : `object`
  * [.createFromUrl(slugOrUuidOrId, urlDeployOptions)](#balena.models.release.createFromUrl) ⇒ `Promise`
  * [.finalize(commitOrIdOrRawVersion)](#balena.models.release.finalize) ⇒ `Promise`
  * [.get(commitOrIdOrRawVersion, \[options\])](#balena.models.release.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.getAllByApplication) ⇒ `Promise`
  * [.getLatestByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.getLatestByApplication) ⇒ `Promise`
  * [.getWithImageDetails(commitOrIdOrRawVersion, \[options\])](#balena.models.release.getWithImageDetails) ⇒ `Promise`
  * [.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated)](#balena.models.release.setIsInvalidated) ⇒ `Promise`
  * [.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull)](#balena.models.release.setKnownIssueList) ⇒ `Promise`
  * [.setNote(commitOrIdOrRawVersion, noteOrNull)](#balena.models.release.setNote) ⇒ `Promise`
  * [.asset](#balena.models.release.asset) : `object`
    * [.download(id)](#balena.models.release.asset.download) ⇒ `Promise`
    * [.get(id, \[options\])](#balena.models.release.asset.get) ⇒ `Promise`
    * [.getAllByRelease(commitOrIdOrRawVersion, \[options\])](#balena.models.release.asset.getAllByRelease) ⇒ `Promise`
    * [.remove(id)](#balena.models.release.asset.remove) ⇒ `Promise`
    * [.upload(uploadParams, \[options\])](#balena.models.release.asset.upload) ⇒ `Promise`
  * [.tags](#balena.models.release.tags) : `object`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.tags.getAllByApplication) ⇒ `Promise`
    * [.getAllByRelease(commitOrIdOrRawVersion, \[options\])](#balena.models.release.tags.getAllByRelease) ⇒ `Promise`
    * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ `Promise`
    * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ `Promise`

***

**release.createFromUrl(slugOrUuidOrId, urlDeployOptions) ⇒ `Promise`**

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Create a new release built from the source in the provided url\
**Access**: public\
**Fulfil**: `number` - release ID

| Param                             | Type                 | Default | Description                                                                        |
| --------------------------------- | -------------------- | ------- | ---------------------------------------------------------------------------------- |
| slugOrUuidOrId                    | `String` \| `Number` |         | application slug (string), uuid (string) or id (number)                            |
| urlDeployOptions                  | `Object`             |         | builder options                                                                    |
| urlDeployOptions.url              | `String`             |         | a url with a tarball of the project to build                                       |
| \[urlDeployOptions.shouldFlatten] | `Boolean`            | `true`  | Should be true when the tarball includes an extra root folder with all the content |

**Example**

```js
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);
});
```

**Example**

```js
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);
});
```

***

**release.finalize(commitOrIdOrRawVersion) ⇒ `Promise`**

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Finalizes a draft release\
**Access**: public\
**Fulfil**: `void`

| Param                  | Type                             | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |

**Example**

```js
balena.models.release.finalize(123).then(function() {
	console.log('finalized!');
});
```

**Example**

```js
balena.models.release.finalize('7cf02a69e4d34c9da573914963cf54fd').then(function() {
	console.log('finalized!');
});
```

**Example**

```js
balena.models.release.finalize({application: 456, raw_version: '0.0.0'}).then(function(release) {
	console.log('finalized!');
});
```

***

**release.get(commitOrIdOrRawVersion, \[options]) ⇒ `Promise`**

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Get a specific release\
**Access**: public\
**Fulfil**: `Object` - release

| Param                  | Type                             | Default | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` |         | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| \[options]             | `Object`                         | `{}`    | extra pine options to use                                                                                                                        |

**Example**

```js
balena.models.release.get(123).then(function(release) {
	console.log(release);
});
```

**Example**

```js
balena.models.release.get('7cf02a69e4d34c9da573914963cf54fd').then(function(release) {
	console.log(release);
});
```

**Example**

```js
balena.models.release.get({application: 456, raw_version: '0.0.0'}).then(function(release) {
	console.log(release);
});
```

***

**release.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Get all releases from an application\
**Access**: public\
**Fulfil**: `Object[]` - releases

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.release.getAllByApplication('myorganization/myapp').then(function(releases) {
	console.log(releases);
});
```

**Example**

```js
balena.models.release.getAllByApplication(123).then(function(releases) {
	console.log(releases);
});
```

***

**release.getLatestByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Get the latest successful release for an application\
**Access**: public\
**Fulfil**: `Object|undefined` - release

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.release.getLatestByApplication('myorganization/myapp').then(function(releases) {
	console.log(releases);
});
```

**Example**

```js
balena.models.release.getLatestByApplication(123).then(function(releases) {
	console.log(releases);
});
```

***

**release.getWithImageDetails(commitOrIdOrRawVersion, \[options]) ⇒ `Promise`**

This method does not map exactly to the underlying model: it runs a larger prebuilt query, and reformats it into an easy to use and understand format. If you want significantly more control, or to see the raw model directly, use `release.get(id, options)` instead.

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Get a specific release with the details of the images built\
**Access**: public\
**Fulfil**: `Object` - release with image details

| Param                  | Type                             | Default | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` |         | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| \[options]             | `Object`                         | `{}`    | a map of extra pine options                                                                                                                      |
| \[options.release]     | `Boolean`                        | `{}`    | extra pine options for releases                                                                                                                  |
| \[options.image]       | `Object`                         | `{}`    | extra pine options for images                                                                                                                    |

**Example**

```js
balena.models.release.getWithImageDetails(123).then(function(release) {
	console.log(release);
});
```

**Example**

```js
balena.models.release.getWithImageDetails('7cf02a69e4d34c9da573914963cf54fd').then(function(release) {
	console.log(release);
});
```

**Example**

```js
balena.models.release.getWithImageDetails({application: 456, raw_version: '0.0.0'}).then(function(release) {
	console.log(release);
});
```

**Example**

```js
balena.models.release.getWithImageDetails(123, { image: { $select: 'build_log' } })
.then(function(release) {
	console.log(release.images[0].build_log);
});
```

***

**release.setIsInvalidated(commitOrIdOrRawVersion, isInvalidated) ⇒ `Promise`**

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Set the is\_invalidated property of a release to true or false\
**Access**: public\
**Fulfil**: `void`

| Param                  | Type                             | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| isInvalidated          | `Boolean`                        | boolean value, true for invalidated, false for validated                                                                                         |

**Example**

```js
balena.models.release.setIsInvalidated(123, true).then(function() {
	console.log('invalidated!');
});
```

**Example**

```js
balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', true).then(function() {
	console.log('invalidated!');
});
```

**Example**

```js
balena.models.release.setIsInvalidated({application: 456, raw_version: '0.0.0'}).then(function(release) {
	console.log('invalidated!);
});
```

**Example**

```js
balena.models.release.setIsInvalidated(123, false).then(function() {
	console.log('validated!');
});
```

**Example**

```js
balena.models.release.setIsInvalidated('7cf02a69e4d34c9da573914963cf54fd', false).then(function() {
	console.log('validated!');
});
```

***

**release.setKnownIssueList(commitOrIdOrRawVersion, knownIssueListOrNull) ⇒ `Promise`**

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Add a known issue list to a release\
**Access**: public

| Param                  | Type                             | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| knownIssueListOrNull   | `String` \| `null`               | the known issue list                                                                                                                             |

**Example**

```js
balena.models.release.setKnownIssueList('7cf02a69e4d34c9da573914963cf54fd', 'This is an issue');
```

**Example**

```js
balena.models.release.setKnownIssueList(123, 'This is an issue');
```

**Example**

```js
balena.models.release.setKnownIssueList({application: 456, rawVersion: '0.0.0'}, 'This is an issue');
```

***

**release.setNote(commitOrIdOrRawVersion, noteOrNull) ⇒ `Promise`**

**Kind**: static method of [`release`](#balena.models.release)\
**Summary**: Add a note to a release\
**Access**: public

| Param                  | Type                             | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| noteOrNull             | `String` \| `null`               | the note                                                                                                                                         |

**Example**

```js
balena.models.release.setNote('7cf02a69e4d34c9da573914963cf54fd', 'My useful note');
```

**Example**

```js
balena.models.release.setNote(123, 'My useful note');
```

**Example**

```js
balena.models.release.setNote({ application: 456, rawVersion: '0.0.0' }, 'My useful note');
```

***

**release.asset : `object`**

**Kind**: static namespace of [`release`](#balena.models.release)

* [.asset](#balena.models.release.asset) : `object`
  * [.download(id)](#balena.models.release.asset.download) ⇒ `Promise`
  * [.get(id, \[options\])](#balena.models.release.asset.get) ⇒ `Promise`
  * [.getAllByRelease(commitOrIdOrRawVersion, \[options\])](#balena.models.release.asset.getAllByRelease) ⇒ `Promise`
  * [.remove(id)](#balena.models.release.asset.remove) ⇒ `Promise`
  * [.upload(uploadParams, \[options\])](#balena.models.release.asset.upload) ⇒ `Promise`

***

**asset.download(id) ⇒ `Promise`**

**Kind**: static method of [`asset`](#balena.models.release.asset)\
**Summary**: Download a release asset\
**Access**: public\
**Fulfil**: `NodeJS.ReadableStream` - download stream

| Param | Type                 | Description                                                                |
| ----- | -------------------- | -------------------------------------------------------------------------- |
| id    | `Number` \| `Object` | release asset ID or object specifying the unique release & asset\_key pair |

**Example**

```js
balena.models.release.asset.download(123).then(function(stream) {
	stream.pipe(fs.createWriteStream('logo.png'));
});
```

**Example**

```js
balena.models.release.asset.download({
	asset_key: 'logo.png',
	release: 123
}).then(function(stream) {
	stream.pipe(fs.createWriteStream('logo.png'));
});
```

***

**asset.get(id, \[options]) ⇒ `Promise`**

**Kind**: static method of [`asset`](#balena.models.release.asset)\
**Summary**: Get a specific release asset\
**Access**: public\
**Fulfil**: `Object` - release asset

| Param      | Type                 | Default | Description                                                                |
| ---------- | -------------------- | ------- | -------------------------------------------------------------------------- |
| id         | `Number` \| `Object` |         | release asset ID or object specifying the unique release & asset\_key pair |
| \[options] | `Object`             | `{}`    | extra pine options to use                                                  |

**Example**

```js
balena.models.release.asset.get(123).then(function(asset) {
	console.log(asset);
});
```

**Example**

```js
balena.models.release.asset.get({
	asset_key: 'logo.png',
	release: 123
}).then(function(asset) {
	console.log(asset);
});
```

***

**asset.getAllByRelease(commitOrIdOrRawVersion, \[options]) ⇒ `Promise`**

**Kind**: static method of [`asset`](#balena.models.release.asset)\
**Summary**: Get all release assets for a release\
**Access**: public\
**Fulfil**: `Object[]` - release assets

| Param                  | Type                             | Default | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` |         | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| \[options]             | `Object`                         | `{}`    | extra pine options to use                                                                                                                        |

**Example**

```js
balena.models.release.asset.getAllByRelease(123).then(function(assets) {
	console.log(assets);
});
```

**Example**

```js
balena.models.release.asset.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(assets) {
	console.log(assets);
});
```

**Example**

```js
balena.models.release.asset.getAllByRelease({ application: 456, raw_version: '1.2.3' }).then(function(assets) {
	console.log(assets);
});
```

***

**asset.remove(id) ⇒ `Promise`**

**Kind**: static method of [`asset`](#balena.models.release.asset)\
**Summary**: Remove a release asset\
**Access**: public

| Param | Type                 | Description                                                                |
| ----- | -------------------- | -------------------------------------------------------------------------- |
| id    | `Number` \| `Object` | release asset ID or object specifying the unique release & asset\_key pair |

**Example**

```js
balena.models.release.asset.remove(123);
```

**Example**

```js
balena.models.release.asset.remove({
	asset_key: 'logo.png',
	release: 123
});
```

***

**asset.upload(uploadParams, \[options]) ⇒ `Promise`**

**Kind**: static method of [`asset`](#balena.models.release.asset)\
**Summary**: Upload a release asset\
**Access**: public\
**Fulfil**: `Object` - uploaded release asset

| Param                       | Type               | Default   | Description                                                                                                                                       |
| --------------------------- | ------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| uploadParams                | `Object`           |           | upload parameters                                                                                                                                 |
| uploadParams.asset          | `String` \| `File` |           | asset file path (string, Node.js only) or File object (Node.js & browser). For File objects, use new File(\[content], filename, {type: mimeType}) |
| uploadParams.asset\_key     | `String`           |           | unique key for the asset within the release                                                                                                       |
| uploadParams.release        | `Number`           |           | release ID                                                                                                                                        |
| \[options]                  | `Object`           | `{}`      | upload options                                                                                                                                    |
| \[options.chunkSize]        | `Number`           | `5242880` | chunk size for multipart uploads (5MiB default)                                                                                                   |
| \[options.parallelUploads]  | `Number`           | `5`       | number of parallel uploads for multipart                                                                                                          |
| \[options.overwrite]        | `Boolean`          | `false`   | whether to overwrite existing asset                                                                                                               |
| \[options.onUploadProgress] | `function`         |           | callback for upload progress                                                                                                                      |

**Example**

```js
// Upload from file path (Node.js)
balena.models.release.asset.upload({
	asset: '/path/to/logo.png',
	asset_key: 'logo.png',
	release: 123
}).then(function(asset) {
	console.log('Asset uploaded:', asset);
});
```

**Example**

```js
// Upload with File API (Node.js and browser)
const content = Buffer.from('Hello, World!', 'utf-8');
const file = new File([content], 'readme.txt', { type: 'text/plain' });

balena.models.release.asset.upload({
	asset: file,
	asset_key: 'readme.txt',
	release: 123
}).then(function(asset) {
	console.log('Asset uploaded:', asset);
});
```

**Example**

```js
// Upload large file with File API and progress tracking
const largeContent = new Uint8Array(10 * 1024 * 1024); // 10MB
const largeFile = new File([largeContent], 'data.bin', { type: 'application/octet-stream' });

balena.models.release.asset.upload({
	asset: largeFile,
	asset_key: 'data.bin',
	release: 123
}, {
	chunkSize: 5 * 1024 * 1024, // 5MB chunks
	parallelUploads: 3,
	onUploadProgress: function(progress) {
		const percent = (progress.uploaded / progress.total * 100).toFixed(2);
		console.log(`Upload progress: ${percent}%`);
	}
}).then(function(asset) {
	console.log('Large file uploaded:', asset);
});
```

**Example**

```js
// Browser: Upload file from input element
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0]; // File object from input

balena.models.release.asset.upload({
	asset: file,
	asset_key: file.name,
	release: 123
}).then(function(asset) {
	console.log('File uploaded from browser:', asset);
});
```

**Example**

```js
// Upload with overwrite option
balena.models.release.asset.upload({
	asset: '/path/to/logo.png',
	asset_key: 'logo.png',
	release: 123
}, {
	overwrite: true
}).then(function(asset) {
	console.log('Asset uploaded/updated:', asset);
});
```

***

**release.tags : `object`**

**Kind**: static namespace of [`release`](#balena.models.release)

* [.tags](#balena.models.release.tags) : `object`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.release.tags.getAllByApplication) ⇒ `Promise`
  * [.getAllByRelease(commitOrIdOrRawVersion, \[options\])](#balena.models.release.tags.getAllByRelease) ⇒ `Promise`
  * [.remove(commitOrIdOrRawVersion, tagKey)](#balena.models.release.tags.remove) ⇒ `Promise`
  * [.set(commitOrIdOrRawVersion, tagKey, value)](#balena.models.release.tags.set) ⇒ `Promise`

***

**tags.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.release.tags)\
**Summary**: Get all release tags for an application\
**Access**: public\
**Fulfil**: `Object[]` - release tags

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.release.tags.getAllByApplication('myorganization/myapp').then(function(tags) {
	console.log(tags);
});
```

**Example**

```js
balena.models.release.tags.getAllByApplication(999999).then(function(tags) {
	console.log(tags);
});
```

***

**tags.getAllByRelease(commitOrIdOrRawVersion, \[options]) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.release.tags)\
**Summary**: Get all release tags for a release\
**Access**: public\
**Fulfil**: `Object[]` - release tags

| Param                  | Type                             | Default | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` |         | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| \[options]             | `Object`                         | `{}`    | extra pine options to use                                                                                                                        |

**Example**

```js
balena.models.release.tags.getAllByRelease(123).then(function(tags) {
	console.log(tags);
});
```

**Example**

```js
balena.models.release.tags.getAllByRelease('7cf02a69e4d34c9da573914963cf54fd').then(function(tags) {
	console.log(tags);
});
```

**Example**

```js
balena.models.release.tags.getAllByRelease({application: 456, rawVersion: '0.0.0'}).then(function(tags) {
	console.log(tags);
});
```

***

**tags.remove(commitOrIdOrRawVersion, tagKey) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.release.tags)\
**Summary**: Remove a release tag\
**Access**: public

| Param                  | Type                             | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| tagKey                 | `String`                         | tag key                                                                                                                                          |

**Example**

```js
balena.models.release.tags.remove(123, 'EDITOR');
```

**Example**

```js
balena.models.release.tags.remove('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR');
```

**Example**

```js
balena.models.release.tags.remove({application: 456, rawVersion: '0.0.0'}, 'EDITOR');
```

***

**tags.set(commitOrIdOrRawVersion, tagKey, value) ⇒ `Promise`**

**Kind**: static method of [`tags`](#balena.models.release.tags)\
**Summary**: Set a release tag\
**Access**: public

| Param                  | Type                             | Description                                                                                                                                      |
| ---------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| commitOrIdOrRawVersion | `String` \| `Number` \| `Object` | release commit (string) or id (number) or an object with the unique `application` (number or string) & `rawVersion` (string) pair of the release |
| tagKey                 | `String`                         | tag key                                                                                                                                          |
| value                  | `String` \| `undefined`          | tag value                                                                                                                                        |

**Example**

```js
balena.models.release.tags.set(123, 'EDITOR', 'vim');
```

**Example**

```js
balena.models.release.tags.set('7cf02a69e4d34c9da573914963cf54fd', 'EDITOR', 'vim');
```

**Example**

```js
balena.models.release.tags.set({application: 456, rawVersion: '0.0.0'}, 'EDITOR', 'vim');
```

***

#### models.service : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.service](#balena.models.service) : `object`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.service.getAllByApplication) ⇒ `Promise`
  * [.var](#balena.models.service.var) : `object`
    * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ `Promise`
    * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.service.var.getAllByApplication) ⇒ `Promise`
    * [.getAllByService(serviceIdOrNaturalKey, \[options\])](#balena.models.service.var.getAllByService) ⇒ `Promise`
    * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ `Promise`
    * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ `Promise`

***

**service.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`service`](#balena.models.service)\
**Summary**: Get all services from an application\
**Access**: public\
**Fulfil**: `Object[]` - services

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) {
	console.log(services);
});
```

**Example**

```js
balena.models.service.getAllByApplication(123).then(function(services) {
	console.log(services);
});
```

***

**service.var : `object`**

**Kind**: static namespace of [`service`](#balena.models.service)

* [.var](#balena.models.service.var) : `object`
  * [.get(serviceIdOrNaturalKey, key)](#balena.models.service.var.get) ⇒ `Promise`
  * [.getAllByApplication(slugOrUuidOrId, \[options\])](#balena.models.service.var.getAllByApplication) ⇒ `Promise`
  * [.getAllByService(serviceIdOrNaturalKey, \[options\])](#balena.models.service.var.getAllByService) ⇒ `Promise`
  * [.remove(serviceIdOrNaturalKey, key)](#balena.models.service.var.remove) ⇒ `Promise`
  * [.set(serviceIdOrNaturalKey, key, value)](#balena.models.service.var.set) ⇒ `Promise`

***

**var.get(serviceIdOrNaturalKey, key) ⇒ `Promise`**

**Kind**: static method of [`var`](#balena.models.service.var)\
**Summary**: Get the value of a specific service variable\
**Access**: public\
**Fulfil**: `String|undefined` - the variable value (or undefined)

| Param                 | Type                 | Description                                          |
| --------------------- | -------------------- | ---------------------------------------------------- |
| serviceIdOrNaturalKey | `Number` \| `Object` | service id (number) or appliation-service\_name pair |
| key                   | `String`             | variable name                                        |

**Example**

```js
balena.models.service.var.get(999999, 'VAR').then(function(value) {
	console.log(value);
});
```

**Example**

```js
balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) {
	console.log(value);
});
```

***

**var.getAllByApplication(slugOrUuidOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`var`](#balena.models.service.var)\
**Summary**: Get all service variables by application\
**Access**: public\
**Fulfil**: `Object[]` - service variables

| Param          | Type                 | Default | Description                                             |
| -------------- | -------------------- | ------- | ------------------------------------------------------- |
| slugOrUuidOrId | `String` \| `Number` |         | application slug (string), uuid (string) or id (number) |
| \[options]     | `Object`             | `{}`    | extra pine options to use                               |

**Example**

```js
balena.models.service.var.getAllByApplication('myorganization/myapp').then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.service.var.getAllByApplication(999999).then(function(vars) {
	console.log(vars);
});
```

***

**var.getAllByService(serviceIdOrNaturalKey, \[options]) ⇒ `Promise`**

**Kind**: static method of [`var`](#balena.models.service.var)\
**Summary**: Get all variables for a service\
**Access**: public\
**Fulfil**: `Object[]` - service variables

| Param                 | Type                 | Default | Description                                          |
| --------------------- | -------------------- | ------- | ---------------------------------------------------- |
| serviceIdOrNaturalKey | `Number` \| `Object` |         | service id (number) or appliation-service\_name pair |
| \[options]            | `Object`             | `{}`    | extra pine options to use                            |

**Example**

```js
balena.models.service.var.getAllByService(999999).then(function(vars) {
	console.log(vars);
});
```

**Example**

```js
balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) {
	console.log(vars);
});
```

***

**var.remove(serviceIdOrNaturalKey, key) ⇒ `Promise`**

**Kind**: static method of [`var`](#balena.models.service.var)\
**Summary**: Clear the value of a specific service variable\
**Access**: public

| Param                 | Type                 | Description                                          |
| --------------------- | -------------------- | ---------------------------------------------------- |
| serviceIdOrNaturalKey | `Number` \| `Object` | service id (number) or appliation-service\_name pair |
| key                   | `String`             | variable name                                        |

**Example**

```js
balena.models.service.var.remove(999999, 'VAR').then(function() {
	...
});
```

**Example**

```js
balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() {
	...
});
```

***

**var.set(serviceIdOrNaturalKey, key, value) ⇒ `Promise`**

**Kind**: static method of [`var`](#balena.models.service.var)\
**Summary**: Set the value of a specific service variable\
**Access**: public

| Param                 | Type                 | Description                                          |
| --------------------- | -------------------- | ---------------------------------------------------- |
| serviceIdOrNaturalKey | `Number` \| `Object` | service id (number) or appliation-service\_name pair |
| key                   | `String`             | variable name                                        |
| value                 | `String`             | variable value                                       |

**Example**

```js
balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() {
	...
});
```

**Example**

```js
balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() {
	...
});
```

***

#### models.team : `object`

**Kind**: static namespace of [`models`](#balena.models)

* [.team](#balena.models.team) : `object`
  * [.create(organizationSlugOrId, name)](#balena.models.team.create) ⇒ `Promise`
  * [.get(teamId, \[options\])](#balena.models.team.get) ⇒ `Promise`
  * [.getAllByOrganization(organizationSlugOrId, \[options\])](#balena.models.team.getAllByOrganization) ⇒ `Promise`
  * [.remove(teamId)](#balena.models.team.remove) ⇒ `Promise`
  * [.rename(teamId, newName)](#balena.models.team.rename) ⇒ `Promise`
  * [.applicationAccess](#balena.models.team.applicationAccess) : `object`
    * [.get(teamApplicationAccessId, \[options\])](#balena.models.team.applicationAccess.get) ⇒ `Promise`
    * [.getAllByTeam(teamId, \[options\])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ `Promise`
    * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ `Promise`
    * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ `Promise`

***

**team.create(organizationSlugOrId, name) ⇒ `Promise`**

This method creates a new team.

**Kind**: static method of [`team`](#balena.models.team)\
**Summary**: Creates a new Team\
**Access**: public\
**Fulfil**: `Object` - Team

| Param                | Type     | Description                                                     |
| -------------------- | -------- | --------------------------------------------------------------- |
| organizationSlugOrId | `Number` | Required: the organization slug or id the team will be part of. |
| name                 | `String` | Required: the name of the team that will be created.            |

**Example**

```js
balena.models.team.create(1239948, 'MyTeam').then(function(team) {
	console.log(team);
});
```

**Example**

```js
balena.models.team.create('myOrgHandle', 'MyTeam')
.then(function(team) {
  console.log(team);
});
```

***

**team.get(teamId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`team`](#balena.models.team)\
**Summary**: Get a single Team\
**Access**: public\
**Fulfil**: `Object` - Team

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| teamId     | `Number` |         | team id (number).         |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.team.get(123).then(function(team) {
	console.log(team);
});
```

***

**team.getAllByOrganization(organizationSlugOrId, \[options]) ⇒ `Promise`**

**Kind**: static method of [`team`](#balena.models.team)\
**Summary**: Get all Teams of a specific Organization\
**Access**: public\
**Fulfil**: `Object[]` - Teams

| Param                | Type     | Default | Description                                                |
| -------------------- | -------- | ------- | ---------------------------------------------------------- |
| organizationSlugOrId | `Number` |         | Required: the organization slug or id the team is part of. |
| \[options]           | `Object` | `{}`    | extra pine options to use                                  |

**Example**

```js
balena.models.team.getAllByOrganization(123).then(function(teams) {
	console.log(teams);
});
```

**Example**

```js
balena.models.team.getAllByOrganization('MyOrganizationHandle').then(function(teams) {
	console.log(teams);
});
```

***

**team.remove(teamId) ⇒ `Promise`**

**Kind**: static method of [`team`](#balena.models.team)\
**Summary**: Remove a Team\
**Access**: public

| Param  | Type     | Description       |
| ------ | -------- | ----------------- |
| teamId | `Number` | team id (number). |

**Example**

```js
balena.models.team.remove(123);
```

***

**team.rename(teamId, newName) ⇒ `Promise`**

**Kind**: static method of [`team`](#balena.models.team)\
**Summary**: Rename Team\
**Access**: public

| Param   | Type     | Description            |
| ------- | -------- | ---------------------- |
| teamId  | `Number` | team id (number)       |
| newName | `String` | new team name (string) |

**Example**

```js
balena.models.team.rename(123, 'MyNewTeamName');
```

***

**team.applicationAccess : `object`**

**Kind**: static namespace of [`team`](#balena.models.team)

* [.applicationAccess](#balena.models.team.applicationAccess) : `object`
  * [.get(teamApplicationAccessId, \[options\])](#balena.models.team.applicationAccess.get) ⇒ `Promise`
  * [.getAllByTeam(teamId, \[options\])](#balena.models.team.applicationAccess.getAllByTeam) ⇒ `Promise`
  * [.remove(teamApplicationAccessId)](#balena.models.team.applicationAccess.remove) ⇒ `Promise`
  * [.update(teamApplicationAccessId, roleName)](#balena.models.team.applicationAccess.update) ⇒ `Promise`

***

**applicationAccess.get(teamApplicationAccessId, \[options]) ⇒ `Promise`**

This method get specific team application access.

**Kind**: static method of [`applicationAccess`](#balena.models.team.applicationAccess)\
**Summary**: Get team applications access\
**Access**: public\
**Fulfil**: `Object` - TeamApplicationAccess

| Param                   | Type     | Default | Description                               |
| ----------------------- | -------- | ------- | ----------------------------------------- |
| teamApplicationAccessId | `Number` |         | Required: the team application access id. |
| \[options]              | `Object` | `{}`    | extra pine options to use                 |

**Example**

```js
balena.models.team.applicationAccess.get(1239948).then(function(teamApplicationAccess) {
	console.log(teamApplicationAccess);
});
```

***

**applicationAccess.getAllByTeam(teamId, \[options]) ⇒ `Promise`**

This method get all team application access.

**Kind**: static method of [`applicationAccess`](#balena.models.team.applicationAccess)\
**Summary**: Get all team applications access\
**Access**: public\
**Fulfil**: `Object[]` - team application access

| Param      | Type     | Default | Description               |
| ---------- | -------- | ------- | ------------------------- |
| teamId     | `Number` |         | Required: the team id.    |
| \[options] | `Object` | `{}`    | extra pine options to use |

**Example**

```js
balena.models.team.applicationAccess.getAllByTeam(1239948).then(function(teamApplicationAccesses) {
	console.log(teamApplicationAccesses);
});
```

***

**applicationAccess.remove(teamApplicationAccessId) ⇒ `Promise`**

This remove a team application access.

**Kind**: static method of [`applicationAccess`](#balena.models.team.applicationAccess)\
**Summary**: Remove team application access\
**Access**: public\
**Fulfil**: `void`

| Param                   | Type     | Description                               |
| ----------------------- | -------- | ----------------------------------------- |
| teamApplicationAccessId | `Number` | Required: the team application access id. |

**Example**

```js
balena.models.team.remove(123).then(function(teams) {
	console.log(teams);
});
```

***

**applicationAccess.update(teamApplicationAccessId, roleName) ⇒ `Promise`**

This method update a team application access role.

**Kind**: static method of [`applicationAccess`](#balena.models.team.applicationAccess)\
**Summary**: Update team application access\
**Access**: public\
**Fulfil**: `Object` - TeamApplicationAccess

| Param                   | Type     | Description                                                    |
| ----------------------- | -------- | -------------------------------------------------------------- |
| teamApplicationAccessId | `Number` | Required: the team application access id.                      |
| roleName                | `String` | Required: The new role to assing (ApplicationMembershipRoles). |

**Example**

```js
balena.models.team.update(123, 'developer').then(function(teamApplicationAccess) {
	console.log(teamApplicationAccess);
});
```

***

### balena.settings : `object`

**Kind**: static namespace of [`balena`](#balena)

* [.settings](#balena.settings) : `object`
  * [.get(\[key\])](#balena.settings.get) ⇒ `Promise`
  * [.getAll()](#balena.settings.getAll) ⇒ `Promise`

***

#### settings.get(\[key]) ⇒ `Promise`

**Kind**: static method of [`settings`](#balena.settings)\
**Summary**: Get a single setting. **Only implemented in Node.js**\
**Access**: public\
**Fulfil**: `*` - setting value

| Param  | Type     | Description |
| ------ | -------- | ----------- |
| \[key] | `String` | setting key |

**Example**

```js
balena.settings.get('apiUrl').then(function(apiUrl) {
	console.log(apiUrl);
});
```

***

#### settings.getAll() ⇒ `Promise`

**Kind**: static method of [`settings`](#balena.settings)\
**Summary**: Get all settings **Only implemented in Node.js**\
**Access**: public\
**Fulfil**: `Object` - settings\
**Example**

```js
balena.settings.getAll().then(function(settings) {
	console.log(settings);
});
```

***

### balena.utils : `object`

**Kind**: static namespace of [`balena`](#balena)

***
