# API

{% hint style="info" %}
This feature requires an OffShoot Pro license. Upgrade via the [License Manager](https://account.hedge.video), or via OffShoot > Settings > License. Check out all Pro features [here](https://hedge.video/offshoot/pro-features).
{% endhint %}

You can tell OffShoot to do something by calling this URL – `offshoot://`. You can call this from any app or script that can open an URL.

{% hint style="success" %}
Using Hedge? Then use `hedge://` instead of  `offshoot://`
{% endhint %}

#### Using a browser

Copy/paste the URL below in a web browser, press `Enter`, and OffShoot will open.

```
offshoot://open
```

#### Using a shell

Copy/paste the command below in a shell, press `Enter`, and OffShoot will open.

{% tabs %}
{% tab title="Mac" %}
Using Terminal

```
open 'offshoot://open'
```

{% endtab %}

{% tab title="Windows" %}
Using PowerShell

```
start 'offshoot://open'
```

{% endtab %}
{% endtabs %}

#### Using a script

{% tabs %}
{% tab title="Mac" %}
AppleScript:

```
do shell script ("open 'offshoot://open'")
```

\
Python:

```
import os
os.system("open 'offshoot://open'")
```

{% endtab %}

{% tab title="Windows" %}
Python

```
import os
os.system("start 'offshoot://open'")
```

{% endtab %}
{% endtabs %}

The result of an API call is logged in a text file.

{% tabs %}
{% tab title="Mac" %}
Location: `~/Library/Logs/Hedge/urlSchemeResponseLog.txt`

This log will contain a single line with either a `success` or `fail` state. It's empty when OffShoot starts, then emptied after each call.
{% endtab %}

{% tab title="Windows" %}
Location: `C:\Users\$username\AppData\Roaming\Hedge\HedgeCallback.log`&#x20;

This is a multi-line log. It's emptied on app start and after each call.

`$time | $id | $arguments_passed`&#x20;

`$time | $id | $call_result`
{% endtab %}
{% endtabs %}

## OffShoot API calls

Control OffShoot's application state.&#x20;

### Open <a href="#open" id="open"></a>

```
offshoot://open
```

### Quit <a href="#quit" id="quit"></a>

```
offshoot://quit
```

### Restart <a href="#restart" id="restart"></a>

```
offshoot://restart
```

### Check for updates <a href="#update" id="update"></a>

```
offshoot://update
```

### Activate <a href="#activate" id="activate"></a>

```
offshoot://activate?key=xxxx-xxxx-xxxx-xxxx
```

| URL Parameter | Type   | Description |
| ------------- | ------ | ----------- |
| key           | String | Required    |

### Deactivate

```
offshoot://deactivate
```

### Chain Actions

The `actions` call allows you to pass multiple API calls in a single request:

{% code overflow="wrap" %}

```
offshoot://actions?json=[{"<action>":{"<property>": "<value>"}},{"<action>":{"<property>": "<value>"}}]
```

{% endcode %}

**Example**

{% code overflow="wrap" %}

```
offshoot://actions?json=[{"deactivate":{}},{"activate":{"key":"xxxx-xxxx-xxxx-xxxx"}}]
```

{% endcode %}

| URL Parameter | Type                            | Description               |
| ------------- | ------------------------------- | ------------------------- |
| json          | Array containing JSON object(s) | Required                  |
| \<action>     | String                          | An API action             |
| \<property>   | String                          | An action property        |
| \<value>      | Various                         | The value of the property |

{% hint style="info" %}
API call not working? URL-encode the JSON string.
{% endhint %}

{% hint style="info" %}
Actions without properties are passed as `{}`.
{% endhint %}

{% hint style="info" %}
Chained Actions can create timing issues. Keep this in mind when debugging. If you run into timing issues, cut up your chained action into multiple calls and proceed based on timers/OffShoot Events or logging output.
{% endhint %}

### Reset Disks

Removes disks from Sources and/or Destinations dropzones. Existing transfers are not affected. If `type` is not defined, both Sources and Destinations are reset.

```
offshoot://reset?type=sources
```

| URL Parameter | Type  | Description                             |
| ------------- | ----- | --------------------------------------- |
| type          | Sting | Optional (`sources` or `destinations)`. |

### Set Source

Sets a single Source or a collection of paths and applies a Label when defined.

```
offshoot://setSource?paths=["/Volumes/UNTITLED"]&label=Clips
```

| URL Parameter | Type   | Description |
| ------------- | ------ | ----------- |
| paths         | Array  | Required    |
| label         | String | Optional    |

{% tabs %}
{% tab title="Mac" %}
Terminal examples:<br>

```
open 'offshoot://actions?json=[{"setSource":{"paths":["/Volumes/Untitled/The Clips"],"label":"test"}}]'
```

\
Call with URL encoded json= value

```
open 'offshoot://actions?json=%5B%7B%22setSource%22%3A%7B%22paths%22%3A%5B%22%2FVolumes%2FUntitled%2FThe%20Clips%22%5D%2C%22label%22%3A%22test%22%7D%7D%5D
```

{% endtab %}

{% tab title="Windows" %}
PowerShell examples:

Call with escaped quotes

{% code overflow="wrap" %}

```
start 'offshoot://actions?json=[{\"setSource\":{\"paths\":[\"G:\The Clips\"],\"label\":\"test\"}}]'
```

{% endcode %}

Call with URL encoded json= value (don't escape quotes)

{% code overflow="wrap" %}

```
start 'offshoot://actions?json=[{"setSource":{"paths":["G:\The Clips"],"label":"test"}}]'
```

{% endcode %}

{% code overflow="wrap" %}

```
start 'offshoot://actions?json=%5B%7B%22setSource%22%3A%7B%22paths%22%3A%5B%22G%3A%5CThe%20Clips%22%5D%2C%22label%22%3A%22test%22%7D%7D%5D'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Set Destination

Sets a single Destination

```
offshoot://setDestination?path=/Volumes/BACKUP
```

| URL Parameter | Type  | Description            |
| ------------- | ----- | ---------------------- |
| path          | Array | Required / URL encoded |

{% tabs %}
{% tab title="Mac" %}
Terminal examples:<br>

{% code overflow="wrap" %}

```
open 'offshoot://actions?json=[{"setDestination":{"path":"/Volumes/Untitled/The Project"}}]'
```

{% endcode %}

\
Call with URL encoded json= value

{% code overflow="wrap" %}

```
open 'offshoot://actions?json=%5B%7B%22setDestination%22%3A%7B%22path%22%3A%22%2FVolumes%2FUntitled%2FThe%20Project%22%7D%7D%5D'
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
PowerShell examples:

```
start "offshoot://setDestination?path=SSD"
```

```
start "offshoot://setDestination?path=H:\"
```

Call with escaped quotes

```
start 'offshoot://actions?json=[{\"setDestination\":{\"path\":\"G:\The Clips\"}}]'
```

Call with URL encoded json= value (don't escape quotes)

```
start 'offshoot://actions?json=[{"setSource":{"paths":["G:\The Clips"],"label":"test"}}]'
```

{% code overflow="wrap" %}

```
start 'offshoot://actions?json=%5B%7B%22setSource%22%3A%7B%22paths%22%3A%5B%22G%3A%5CThe%20Clips%22%5D%2C%22label%22%3A%22test%22%7D%7D%5D'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Reload Presets

Reloads all presets. Call this after making changes to preset files.

```
offshoot://reloadPresets
```

### Add transfers

Creates transfers for all new combinations of Sources and Destinations. Identical to pressing the `Add Transfers` button in OffShoot.

```
offshoot://addTransfers
```

### Set Preferences

Sets a specific preference to a specific value. A complete list of all key names is available here: `/Applications/OffShoot.app/Contents/Resources/SFIDefaults.plist`

{% hint style="info" %}
Not sure which key name to use? Try changing the setting in OffShoot, then verifying the modified values in: `~/Library/Preferences/nl.syncfactory.Hedge.Mac.plist`
{% endhint %}

```
offshoot://setPreferences?preferences={"SFIDefaultsAutoSources":"0"}
```

| URL Parameter | Type        | Description |
| ------------- | ----------- | ----------- |
| preferences   | JSON Object | Required    |

{% hint style="info" %}
`The SetPreferences` action is for macOS only.&#x20;

On Windows, you can set the corresponding keys and values in the Windows Registry under `<current-user>\Software\Hedge`.
{% endhint %}
