# Working with variables

## Adding/managing variables

A **variable** is a value that can change, depending on conditions or information supplied by the user. Using the Patchworks connector builder, variables can be defined at different levels:

| Level                                                                                                                                                                                                                                    | Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Connector instance (connector variables)](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/3-authentication-methods/authentication-method-options/connector-variables) | **Connector instance variables** defined here can be used when you [configure authentication methods](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/3-authentication-methods/authentication-method-options). If you're defining multiple authentication methods which share common variables, define them once here and then choose to 'use' them in subsequent authentication methods. |
| [Authentication method (auth variables)](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/3-authentication-methods/authentication-method-options/auth-variables)        | **Auth variables** (whether added directly or picked up and 'used' from predefined **connector instance variables**) are displayed as fields for your users to complete whenever the associated authentication method is used to [add a connector instance](https://doc.wearepatchworks.com/product-documentation/connectors-and-instances/working-with-instances/adding-an-instance).                                                                      |
| [Endpoint variables](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/endpoint-variables)                                                  | **Endpoint variables** are displayed as fields for your users to complete whenever they configure a process flow connection shape to use an associated endpoint.                                                                                                                                                                                                                                                                                            |

When a [process flow](https://doc.wearepatchworks.com/product-documentation/process-flows/about-process-flows) runs, any associated API requests are injected with user-provided variable values wherever a corresponding `{{variable}}` is found. &#x20;

{% hint style="info" %}
All variables added to connector builder API requests should be placed within double-curly brackets - for example: `{{product_type}}`.
{% endhint %}

The sections below explain the use of variables in general terms - for specific guidance in a particular context, please use the links provided [above](#about-parameters).

## Adding a variable

When you choose to add or edit a variable, the **add variable** or **manage variable** page is displayed:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F1LwYHYn9QH7kWlDOc546%2Fadd%20auth%20variable%202.png?alt=media&#x26;token=37570d97-e4cc-47e6-8886-e671336b8dcc" alt="" width="563"><figcaption></figcaption></figure></div>

Options on this page are the same, irrespective of whether you're adding/managing [connector variables](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/3-authentication-methods/authentication-method-options/connector-variables), [auth variables](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/3-authentication-methods/authentication-method-options/auth-variables) or [endpoint variables](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/endpoint-variables). Use the table below as a guide for completing this page:

| Field         | Summary                                                                                                                      |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Key           | The name to be used by Patchworks internally, when referencing this variable.                                                |
| Display name  | The field label that users will see if they are asked to enter a value for this variable.                                    |
| Alias         | The name used by the actual system when referencing this variable.                                                           |
| Default value | Enter a default value to be shown when this field is displayed to users. The maximum number of characters permitted is 1024. |

The remaining fields on this page determine if/how your users will interact with this variable when [adding an instance](https://doc.wearepatchworks.com/product-documentation/connectors-and-instances/working-with-instances/adding-an-instance) of this connector:

| Field                            | Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Is this required?                | <p>Toggle this option <strong>on</strong> to make this a mandatory field when a user either:</p><ul><li><a href="../../../../connectors-and-instances/working-with-instances/adding-an-instance">is asked to provide credentials for a new instance</a> (in the case of <a href="../3-authentication-methods/authentication-method-options/connector-variables">connector</a> and <a href="../3-authentication-methods/authentication-method-options/auth-variables">auth variables</a>) </li><li>configures a <a href="../../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape">connection shape</a> with a given endpoint (in the case of <a href="../4-endpoints/endpoint-options/endpoint-variables">endpoint variables</a>).  </li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Is this configurable             | <p>Toggle this option <strong>on</strong> to make this an optional field when a user either:</p><ul><li><a href="../../../../connectors-and-instances/working-with-instances/adding-an-instance">is asked to provide credentials for a new instance</a> (in the case of <a href="../3-authentication-methods/authentication-method-options/connector-variables">connector</a> and <a href="../3-authentication-methods/authentication-method-options/auth-variables">auth variables</a>) </li><li>configures a <a href="../../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape">connection shape</a> with a given endpoint (in the case of <a href="../4-endpoints/endpoint-options/endpoint-variables">endpoint variables</a>).  </li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Is this for advanced users only? | <p>Advanced variables are those which 'regular' users would not typically need to see or change, but which advanced users might want to change in exceptional cases. </p><p></p><p>With this option toggled <strong>on</strong>, the field for this variable is hidden in an <strong>advanced</strong> section </p><p>when a user either:</p><ul><li><a href="../../../../connectors-and-instances/working-with-instances/adding-an-instance">is asked to provide credentials for a new instance</a> (in the case of <a href="../3-authentication-methods/authentication-method-options/connector-variables">connector</a> and <a href="../3-authentication-methods/authentication-method-options/auth-variables">auth variables</a>) </li><li>configures a <a href="../../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape">connection shape</a> with a given endpoint (in the case of <a href="../4-endpoints/endpoint-options/endpoint-variables">endpoint variables</a>).  </li></ul><p>Only select this option if this is a variable that 'regular' users would NOT typically need to see or change - but which advanced users might want to change in exceptional cases. </p><p></p><p>For example, the <code>content-type</code> variable might typically be set too <code>application/json</code> but you need to allow for edge cases in NetSuite, where an advanced user might want to change it to <code>application/xml</code>. </p> |
| Is this variable a secret?       | Toggle this option **on** if values entered for this field are sensitive. Secret variables are encrypted and displayed as asterisks within the dashboard UI.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

## Editing a variable

To edit a variable, simply click the variable name to open the standard variable settings page - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F5undsMhANaZnoISBJck7%2Fedit%20variable.png?alt=media&#x26;token=dc5d8a52-515a-4324-a49b-894a51b02be4" alt="" width="563"><figcaption></figcaption></figure></div>

From here, you can make your required changes and click the **save** button.

{% hint style="info" %}
In some cases, a variable may be locked - these are variables which are required by Patchworks to perform a particular function (for example, default variables associated with [authentication methods](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/3-authentication-methods/authentication-method-options)). In this case, you can't change settings or remove the variable, but you can [change the display name](#renaming-a-locked-variable).
{% endhint %}

## Renaming a locked variable

In the case of a locked variable, you can change the name that users see for the associated field when they are asked to provide a value.

As such, we need to rename the To do this, click the field name and update the **display name** as appropriate - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FufPMVvDsZYVIzTgCrfxS%2Fchange%20field%20name.png?alt=media&#x26;token=26c2dbe8-8cc9-466c-a155-55e6736787c1" alt=""><figcaption></figcaption></figure></div>

<details>

<summary><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpLMO12yvTCxi9PorCt53%2Ficons8-film.svg?alt=media&#x26;token=e59864bc-2d97-4f98-966c-a083c18e60db" alt="" data-size="line"> Show me</summary>

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FEEapvwcvMd1ClwlZMgdF%2Fbasic%20auth%203.gif?alt=media\&token=90054817-ecfb-49a8-8e24-efb50f694b79)

</details>
