---
title: "Code Connector | Lansweeper Platform"
slug: "code-connector"
description: "Use the Code connector in Lansweeper Flow Builder to author and run your own custom code as a step in your automated workflows."
status: "update"
updated: 2026-07-17T15:53:10Z
published: 2026-07-17T15:53:10Z
canonical: "docs.lansweeper.com/code-connector"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lansweeper.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Code Connector

Note on third‑party tools

              

We aim to provide accurate and helpful details about third‑party tools, but we can’t guarantee that this information is always complete or up to date. If you notice any discrepancies, feel free to share them in the feedback section below. For the most reliable information, please always refer to the third‑party tool’s official documentation.

Author and run your own code

## Connections

### API Key

API Key connection

| Input | Comments | Default |
| --- | --- | --- |
| API Key | API Key |  |

### API Key Secret

API Key Secret connection

| Input | Comments | Default |
| --- | --- | --- |
| API Key | API Key |  |
| API Secret | API Secret |  |

### Basic Username/Password

Basic Username and Password connection

| Input | Comments | Default |
| --- | --- | --- |
| Username | Username |  |
| Password | Password |  |

### OAuth 2.0 Authorization Code

OAuth 2.0 Authorization Code flow

This connection uses OAuth 2.0, a common authentication mechanism for integrations. Read about how OAuth 2.0 works [here](/docs/oauth-20-connections).

| Input | Comments | Default |
| --- | --- | --- |
| Authorize URL | The OAuth 2.0 Authorization URL for the API |  |
| Token URL | The OAuth 2.0 Token URL for the API |  |
| Scopes | Space separated OAuth 2.0 permission scopes for the API |  |
| Client ID | Client Identifier of your app for the API |  |
| Client Secret | Client Secret of your app for the API |  |
| Headers | Additional header to supply to authorization requests |  |

### OAuth 2.0 Client Credentials

OAuth 2.0 Client Credentials flow

This connection uses OAuth 2.0, a common authentication mechanism for integrations. Read about how OAuth 2.0 works [here](/docs/oauth-20-connections).

| Input | Comments | Default |
| --- | --- | --- |
| Token URL | The OAuth 2.0 Token URL for the API |  |
| Scopes | Space separated OAuth 2.0 permission scopes for the API |  |
| Client ID | Client Identifier of your app for the API |  |
| Client Secret | Client Secret of your app for the API |  |
| Headers | Additional header to supply to token requests |  |

### Private Key

Private key connection

| Input | Comments | Default |
| --- | --- | --- |
| Username | Username |  |
| Private Key | Private Key |  |

## Triggers

### Code Block Trigger

Author and run your own code as a trigger

| Input | Comments | Default |
| --- | --- | --- |
| Code | The code to be executed | /* Access config variables by name through the configVars object. e.g. const apiEndpoint = `&#x24;{configVars[&quot;App Base URL&quot;]}/api`; Access the trigger payload using the payload argument. This includes headers, the body of the request, and more information about the request. You can return string, number or complex object data. e.g. return { payload: { foo: "Hello", bar: 123.45, baz: true } }; You are also able to return an optional response to the webhook caller. For example, you can respond with a CSV response like the following: return { payload: { foo: "Hello", bar: 123.45, baz: true }, response: { statusCode: 200, contentType: "text/csv", body: "hello,world" }, } */ module.exports = async ({ logger, configVars }, payload) => { const response = { statusCode: 200, contentType: "text/plain", body: "hello", }; return { payload, response }; }; |

## Actions

### Code Block

Author and run your own code

| Input | Comments | Default |
| --- | --- | --- |
| Code | The code to be executed | /* Access config variables by name through the configVars object. e.g. const apiEndpoint = `&#x24;{configVars[&quot;App Base URL&quot;]}/api`; Access previous steps' results through the stepResults object. Trigger and step names are camelCased. If the step "Get Data from API" returned {"foo": "bar", "baz": 123}, you could destructure that data with: const { foo, baz } = stepResults.getDataFromApi.results; You can return string, number or complex object data. e.g. return { data: { foo: "Hello", bar: 123.45, baz: true } }; */ module.exports = async ({ logger, configVars }, stepResults) => { return { data: null }; }; |
