Artisan IMG > LeafLink (leaflink)

LeafLink

The largest online marketplace for wholesale cannabis.

Overview
Copied!

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

Authentication
Copied!

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 Tray.io 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 Tray.io 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:
Copied!

  • Webhook

Webhook Setup
Copied!

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 Tray.io 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 Tray.io 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
Copied!

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')
Copied!

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
Copied!

TRAY POTENTIAL: Tray.io 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 Tray.io 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
Copied!

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
Copied!

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 Tray.io, 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
Copied!

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:

All Operations

Latest version:

5.0

List licenses DDL

Get staff member

Retrieve an individual staff member by ID.

Get strain

Retrieve a strain.

Upload product image

Upload a product image.

Get contact

Retrieve an individual contact by ID.

Get payment

Retrieve a payment.

Archive customer

Archive a customer by customer ID.

Archive product

Mark the specified product as archived.

Create product line

Create a product line.

Create activity entry

Create a new company activity entry object for a company you have CRM management access for.

Create contact

Create a new contact.

Create customer

Create a new company customer.

Create payment

Create a new payment.

Create product

Create a new product.

Create strain

Create a strain.

Delete activity entry

Set the delete flag to true on a company activity entry by ID.

Delete contact

Set the delete flag to true on a contact by ID.

Delete line item

Delete a line item by ID.

Delete order

Delete an order. This operation is supported only for draft orders.

Delete product image

Delete a product image.

Get activity entry

Retrieve a company activity entry by ID.

Get brand

Retrieve a brand by ID.

Get company

Retrieve details about the company that the current user is authorized to access.

Get customer

Retrieve a customer by customer ID.

Get customer tier

Retrieve a "CompanyCustomerTier" by ID.

Get license

Retrieve a license by ID.

Get license type

Retrieve an individual license type by ID.

Get line item

Retrieve an individual line item by ID.

Get order

Retrieve an individual order by number.

Get product

Retrieve an individual product by ID.

Get product category

Retrieve a product category.

Get product image

Retrieve a product image.

Get product line

Retrieve a product line.

Get product subcategory

Retrieve a product subcategory.

List activity entries

List all company activity entry objects of companies the requester has CRM management access for.

List batches DDL

List brands

List all brands for all active companies the user is a member of.

List brands DDL

List buyer orders

List orders sent.

Update product line

Update a product line.

List buyers DDL

List companies

List all active companies the Requesting User is staff member of.

List companies DDL

List company staff

List all company staff.

List company staff DDL

List licenses

List all licenses for a user's companies.

List contacts

List all contacts for all active companies where the user has the "MANAGE_CRM" permission.

List contacts DDL

List customer tiers

List all customer tiers in LeafLink.

List customer tiers DDL

List customers

List all customers of active companies the Requesting User is also a staff member of.

List customers DDL

List delivery providers DDL

List license classifications DDL

List license numbers DDL

List license types

List all licenses types available on LeafLink.

List license types DDL

List line items

List all line items for all active companies where the user can manage received orders.

List listing states DDL

List order statuses

List all order statuses.

List order statuses DDL

List orders

List all received orders for all active companies where the user can manage received orders.

List orders DDL

List payments

Retrieve a list to payments.

List product categories

List all Product Categories in LeafLink.

List product categories DDL

List product images

Retrieve a list of product images.

List product lines

List all product lines for all active companies where the user has permission to do so.

List product lines DDL

List product subcategories

List all Product Subcategories in LeafLink.

List product subcategories DDL

List products

List all products for all active companies.

List products DDL

List strain classifications DDL

List strains

List all strains for all active companies the requesting user belongs to and has permission to manage the inventory.

List strains DDL

Raw HTTP request (advanced)

Perform a raw HTTP request with some pre-configuration and processing by the connector, such as authentication.

Transition order

Perform an order transition action. Valid actions are: [submit, accept, fulfill, cancel, reject, ship, complete].

Update activity entry

Update a company activity entry object for a company you have CRM management access for.

Update contact

Update an existing contact by ID.

Update customer

Update an existing company customer.

Update line item

Update an existing line item.

Update order

Update an Order.

Update product

Update an existing product.