> For the complete documentation index, see [llms.txt](https://docs.balena.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.balena.io/reference/sdk/node-sdk/latest/models/service.md).

# Service

`balena.models.service` : `object`

**Kind**: static namespace

***

## getAllByApplication

`balena.models.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);
});
```

***

## var

`balena.models.service.var` : `object`

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

***

### get

`balena.models.service.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);
});
```

***

### getAllByApplication

`balena.models.service.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);
});
```

***

### getAllByService

`balena.models.service.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);
});
```

***

### remove

`balena.models.service.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() {
	...
});
```

***

### set

`balena.models.service.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() {
	...
});
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.balena.io/reference/sdk/node-sdk/latest/models/service.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
