Artisan IMG > LeafLink (leaflink)
Artisan IMG > LeafLink (leaflink)


The largest online marketplace for wholesale cannabis.


LeafLink provides a suite of products, including streamlined ordering, CRM, reporting tools, and fulfillment and shipment queues.


Within the workflow builder, highlight the LeafLink connector.

In the LeafLink connector properties panel to the right of the builder, click on the Authenticate tab and the 'New authentication' button. This will result in a authentication pop-up modal.

Name the authentication something that will easily identify it in a larger list. For example using the name of the service account, whether it is a Sandbox or Production OAuth, etc.

When choosing between the type of authentication you wish to create ('Personal' or 'Organisational'), consider who and how many people will need access to it.

The second page asks you for your 'API token', 'Environment', and 'Webhook Key' properties.

In order to get these fields, head to the LeafLink dashboard and navigate to 'Settings' > 'Developer Options'. On the 'Developer Options' page you'll see existing API tokens and Webhook Keys if available. You can always generate new ones if required.

Once you have added these fields to your authentication pop-up window, click the 'Create authentication' button.

Go back to your settings authentication field (within the workflow builder properties panel), and select the recently added authentication from the drop-down options now available.

Your connector authentication setup should now be complete.

If you wish your workflow to be kicked off by a particular action in LeafLink, you can use the LeafLink Trigger.

The LeafLink trigger allows you to receive notifications and trigger workflows when given events occur associated with the selected trigger operation.

Trigger Operations available:

  • Webhook

Webhook Setup

Select the LeafLink trigger. This can be done either at the create new workflow stage or updated within the workflow builder itself.

Highlight the LeafLink trigger. In the LeafLink trigger properties panel to the right of the builder, click on the Authenticate tab and the 'Add new authentication' button.

Follow the instructions from the Authentication section above to authenticate your trigger. Select 'Webhook' as the event you wish your trigger to listen to in order to set off the workflow itself.

To configure the webhook, you need the Workflow Public URL. Click on the horizontal hamburger icon available on the top left in the builder and navigate to 'Workflow settings' > 'General settings'.

From the general settings pop-up, copy the 'Workflow public URL' to the clipboard.

Next, visit the developer options page in LeafLink and click the 'Add Webhook' button.

Give the new webhook a name, paste the recently copied Tray's Workflow Public URL into the url field, and select the type(s) of events that should trigger the webhook. Make sure it is enabled and click 'Add Webhook'. This will create a LeafLink webhook that will trigger the execution of your workflow.

WEBHOOKS: As this uses a webhook as its operation type, you will also need to integrate it with your leaflink account, in order to complete the authentication process.

Available Operations

The examples below show one or two of the available connector operations in use.

Please see the Full Operations Reference at the end of this page for details on all available operations for this connector.

Using the Raw HTTP Request ('Universal Operation')

As of version 1.1, you can effectively create your own operations.

This is a very powerful feature which you can put to use when there is an endpoint in LeafLink which is not used by any of our operations.

To use this you will first of all need to research the endpoint in the LeafLink API documentation, to find the exact format that LeafLink will be expecting the endpoint to be passed in.

Note that you will only need to add the suffix to the endpoint, as the base URL will be automatically set (the base URL is picked up from the value for 'Environment', set when you created your authentication).

For example, say that the 'List product categories' operation did not exist in our LeafLink connector, and you wanted to use this endpoint. You would use the LeafLink API docs to find the relevant endpoint - which in this case is a GET request called: /product-categories/.

More details about this endpoint can be found here.

As you can see there is also the option to include two query parameters, 'limit' and 'offset', should you wish to do so. So if you know what your method, endpoint and details of your query parameters are, you can get a list of the product categories with the following settings:

Method: GET

Endpoint: /product-categories/

Query Parameters: Key: limit Value: 10

Body Type : None

Final outcome being: <base_url>/product-categories/?limit=10

Example Usage

TRAY POTENTIAL: is extremely flexible. By design there is no fixed way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors. This demo which follows shows only one possible way of working with and the leaflink connector. Once you've finished working through this example please see our Introduction to working with data and jsonpaths page and Data Guide for more details.

Below is an example of a way in which you could potentially use the LeafLink connector, to loop through a list of all payments, and then retrieve details of each payment.

The steps will be as follows:

  1. Setup using a manual trigger and retrieve a list of all payments.

  2. Loop through the list of payments received from the previous step.

  3. Get details of each payment.

Your completed workflow should look similar to this:

1 - Setup Trigger & list all payments

With your trigger in place (be it Manual, Scheduled, Callable etc) add a LeafLink connector. Set the operation to 'List payments'. As you can see, there are two required params, 'Limit' and 'Offset'. Enter your desired values for each, or use the default values.

Feel free to re-name your steps as you go along to make things clearer for yourself and other users. The operation names themselves often suffice.

This step will retrieve a list of all payments.

2 - Loop through the payments

Next, search for the Loop connector within your connector panel, and drag it into your workflow as your next step. Set your operation to 'Loop List'.

The Loop connector allows you to iterate through a list of results. In this example, we will use it to iterate through the list of payments received from the List payments step.

In order to specify the list, you want to loop through, start by using the list mapping icon (found next to the list input field, within the properties panel) to generate the connector-snake.

Grab the connector snake from the 'List' field in the 'Loop' step. With the tail end of the connector-snake, hover over the 'List payments' step, and select results from the list of output properties displayed. This will auto-populate a jsonpath within your list input field, and update the type selector to jsonpath.

For more clarification on the pathways you have available, open the Debug panel to view your step's Input and Output.

This step will loop through the list of payments retrieved from the LeafLink connector in step 1.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with, please see our Intro page and Data Guide for more details.

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

3 - Get details of each payment

The final step is to add another LeafLink connector inside the loop you added in step 2. Set this connector operation to 'Get payment'. You will notice that there is one required param, 'ID'.

Using the tail end of the connector-snake, hover over the 'Loop' step, and select id from the list of output properties displayed. This will auto-populate a jsonpath within your list input field, and update the type selector to jsonpath.

This step will retrieve details of each payment.

INTERPOLATION: When you wish to include JSON generated data within another input/output result, use our Interpolation method as described here.

BEST PRACTICES: Whenever you do decide to create your own workflow, be sure to check out some of our key articles such as: