> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/scopeview/automation-api-and-scripting/use-python-scopeview-api/python-api-reference/template.md).

# Template

## Function: addExpression

| **Section**    | **Description**                                                                                                                                                                                                           |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | Add ScopeView expression                                                                                                                                                                                                  |
| **Parameters** | **expression** (*str*) – The expression to be added                                                                                                                                                                       |
| **Returns**    | <p>The result of the <code>AddExpression</code> function call, <code>False</code> if error handling is disabled,<br>or raises an exception if a <code>FAILED\_PRECONDITION</code> error occurs. (int or bool or None)</p> |
| **Raises**     | <p><strong>ScopeViewApiException</strong> – If a <code>grpc.StatusCode.FAILED\_PRECONDITION</code> error occurs.<br><strong>Exception</strong> – If any other unexpected error occurs during the process.</p>             |

## Function: addTemplateFunction

| **Section**    | **Description**                                                                                                                                                                                                                                      |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | Add function to the current template                                                                                                                                                                                                                 |
| **Parameters** | <p><strong>function</strong> (<em>str</em>) – function string<br><strong>signals</strong> (<em>list\[str]</em>) – list of signals<br><strong>page</strong> (<em>int</em>) – page number<br><strong>visible</strong> (<em>bool</em>) – visibility</p> |
| **Returns**    | <p>The result of the <code>AddTemplateFunction</code> function call, <code>False</code> if error handling is disabled,<br>or raises an exception if a <code>FAILED\_PRECONDITION</code> error occurs. (int or bool or None)</p>                      |
| **Raises**     | <p><strong>ScopeViewApiException</strong> – If a <code>grpc.StatusCode.FAILED\_PRECONDITION</code> error occurs.<br><strong>Exception</strong> – If any other unexpected error occurs during the process.</p>                                        |

## Function: addTemplateSignals

| **Section**    | **Description**                                                                                                                                                                                                                                                                                            |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | Add expressions to the current template.                                                                                                                                                                                                                                                                   |
| **Parameters** | <p><strong>signals</strong> (<em>list\[str]</em>) – List of signals to be added to the template.<br><strong>page</strong> (<em>int</em>) – Page number where the signals will be added.<br><strong>visible</strong> (<em>bool</em>) – Indicates whether the signals should be visible on the template.</p> |
| **Returns**    | <p>The result of the <code>AddTemplateSignals</code> function call, <code>False</code> if error handling is disabled,<br>or raises an exception if a <code>FAILED\_PRECONDITION</code> error occurs. (int or bool or None)</p>                                                                             |
| **Raises**     | <p><strong>ScopeViewApiException</strong> – If a <code>grpc.StatusCode.FAILED\_PRECONDITION</code> error occurs.<br><strong>Exception</strong> – If any other unexpected error occurs during the process.</p>                                                                                              |

## Function: executeTemplate

| **Section**    | **Description**                                    |
| -------------- | -------------------------------------------------- |
| **Action**     | Execute ScopeView template                         |
| **Parameters** | **file\_name** (*str*) – path to template location |
| **Returns**    | Error value (int)                                  |
| **Raises**     | **AssertionError** – Raises exception on error     |

## Function: getSignal

| **Section**    | **Description**                                                                                                                              |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | Get a ScopeView signal name                                                                                                                  |
| **Parameters** | <p><strong>signal\_name</strong> (<em>str</em>) – signal name<br><strong>data\_source\_label</strong> (<em>str</em>) – data source label</p> |
| **Returns**    | Signal (Signal{signal\_name, data\_source\_label})                                                                                           |
| **Raises**     | **AssertionError** – Raises exception on error                                                                                               |

## Function: getTemplateDataSources

| **Section**    | **Description**                                        |
| -------------- | ------------------------------------------------------ |
| **Action**     | Get all ScopeView data sources of the current template |
| **Parameters** | None                                                   |
| **Returns**    | A list of data sources (list\[str])                    |
| **Raises**     | None                                                   |

## Function: importTemplate

| **Section**    | **Description**                                                                                                                                               |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | Import template to ScopeView                                                                                                                                  |
| **Parameters** | <p><strong>file\_name</strong> (<em>str</em>) – path to template location<br><strong>appendNewPage</strong> (<em>bool</em>) – append template to new page</p> |
| **Returns**    | Error value (int)                                                                                                                                             |
| **Raises**     | **AssertionError** – Raises exception on error                                                                                                                |

## Function: loadTemplate

| **Section**    | **Description**                                    |
| -------------- | -------------------------------------------------- |
| **Action**     | Load template to ScopeView                         |
| **Parameters** | **file\_name** (*str*) – path to template location |
| **Returns**    | Error value (int)                                  |
| **Raises**     | **AssertionError** – Raises exception on error     |

## Function: newTemplate

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Create new ScopeView template                  |
| **Parameters** | None                                           |
| **Returns**    | Error value (int)                              |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: removeAllPages

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Removes all pages from ScopeView template      |
| **Parameters** | None                                           |
| **Returns**    | Error value (int)                              |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: removeTemplateFunction

| **Section**    | **Description**                                                                                                                                                                                                                    |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | Remove function from the current template                                                                                                                                                                                          |
| **Parameters** | <p><strong>function</strong> (<em>str</em>) – function string<br><strong>page</strong> (<em>int</em>) – page number<br><strong>visible</strong> (<em>bool</em>) – visibility</p>                                                   |
| **Returns**    | <p>The result of the <code>RemoveTemplateFunction</code> function call, <code>False</code> if error handling is disabled,<br>or raises an exception if a <code>FAILED\_PRECONDITION</code> error occurs. (int or bool or None)</p> |
| **Raises**     | <p><strong>ScopeViewApiException</strong> – If a <code>grpc.StatusCode.FAILED\_PRECONDITION</code> error occurs.<br><strong>Exception</strong> – If any other unexpected error occurs during the process.</p>                      |

## Function: removeTemplateSignals

| **Section**    | **Description**                                                                                                                                                                        |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | Remove signals from the current template                                                                                                                                               |
| **Parameters** | <p><strong>signals</strong> (<em>list\[str]</em>) – list of signals<br><strong>page</strong> (<em>int</em>) – page number<br><strong>visible</strong> (<em>bool</em>) – visibility</p> |
| **Returns**    | Error value (int)                                                                                                                                                                      |
| **Raises**     | **AssertionError** – Raises exception on error                                                                                                                                         |

## Function: saveTemplate

| **Section**    | **Description**                                    |
| -------------- | -------------------------------------------------- |
| **Action**     | Save ScopeView template                            |
| **Parameters** | **file\_name** (*str*) – path to template location |
| **Returns**    | Error value (int)                                  |
| **Raises**     | **AssertionError** – Raises exception on error     |


---

# 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://www.opal-rt.com/docs/scopeview/automation-api-and-scripting/use-python-scopeview-api/python-api-reference/template.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.
