Disconnect
Disconnects from the Lemlist API and releases the client connection, cleaning up the stored authentication credentials from memory.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Client Id - The client identifier returned from the Connect node. This ID references the authenticated session to be terminated.
How It Works
The Disconnect node is the final step when using the Connect/Disconnect pattern for Lemlist automation. When executed, the node:
- Validates that a Client ID has been provided
- Removes the stored authentication credentials from memory
- Releases the resources associated with the client connection
- Completes without returning any output
This ensures that sensitive authentication data is properly cleaned up after your automation completes.
Requirements
- A valid Client ID from a previously executed Connect node
- The Client ID must still be valid (not already disconnected)
Error Handling
The node will return specific errors in the following cases:
- ErrInvalidArg: Empty or missing Client ID
- ErrInternal: Failed to retrieve or process the Client ID
Usage Example
Basic Disconnect Flow
Connect/Disconnect Pattern:
1. Connect Node
└─> Output: client_id = "xyz123abc456..."
2. Perform Lemlist Operations
└─> List Campaigns (using client_id)
└─> Get Team (using client_id)
└─> Unsubscribe Lead (using client_id)
3. Disconnect Node
└─> Input: client_id = "xyz123abc456..."
└─> Cleans up the connection
Practical Automation Scenario
Daily Campaign Cleanup Workflow:
1. Connect to Lemlist
└─> client_id: "abc123"
2. List all active campaigns
└─> campaigns: [...]
3. For each campaign:
└─> Check bounce rates
└─> Unsubscribe bounced leads
└─> Remove invalid email addresses
4. Disconnect from Lemlist
└─> Clean up: "abc123"
└─> Workflow complete
Conditional Lead Management:
1. Connect to Lemlist
└─> client_id: "def456"
2. Read CSV of opted-out contacts
└─> email_list: ["user1@example.com", ...]
3. List all campaigns
└─> Get campaign IDs
4. For each email in list:
└─> Unsubscribe from all campaigns
5. Disconnect from Lemlist
└─> Clean up: "def456"
Usage Notes
- The Disconnect node should be executed after all Lemlist operations are complete
- Once disconnected, the Client ID becomes invalid and cannot be reused
- If you need to perform additional operations after disconnecting, you must create a new connection with a Connect node
- The stored credentials are also automatically cleaned up when the flow stops, but using Disconnect is a best practice
- This node does not require network communication with Lemlist - it only cleans up local resources
Best Practices
- Always pair Connect with Disconnect nodes to properly manage resources
- Place the Disconnect node in a Finally block or at the end of your flow to ensure it executes even if errors occur
- Use a single Disconnect node for each Connect node (one-to-one relationship)
- Don't attempt to use the same Client ID after disconnecting
- For error handling, consider wrapping Lemlist operations in a Try-Catch-Finally structure:
- Try: Lemlist operations
- Catch: Error handling
- Finally: Disconnect node
Error Recovery
Handling Disconnect Errors:
If the Disconnect node fails, it typically means:
- The Client ID was already disconnected or invalid
- This is usually not critical since the connection will be cleaned up when the flow ends
Best Practice Error Handling:
Try Block:
└─> Connect Node
└─> Lemlist Operations (List Campaigns, etc.)
Catch Block:
└─> Log error
└─> Handle specific error cases
Finally Block:
└─> Disconnect Node (always executes)
Resource Management
The Disconnect node is important for:
- Memory Management: Releases stored credentials from memory
- Security: Ensures sensitive API keys are not kept longer than necessary
- Clean Code: Makes automation flows explicit about connection lifecycle
- Debugging: Clear connection boundaries help troubleshoot issues
When to Skip Disconnect
You can skip using Disconnect (and Connect) when:
- Making only a single API call
- Using direct credential authentication in each node
- Building quick prototypes or tests
- The flow execution time is very short
In these cases, use the Credentials option directly in Lemlist nodes instead of the Connect/Disconnect pattern.
Common Errors and Solutions
Error: "Client ID cannot be empty"
- Cause: No Client ID was provided to the Disconnect node
- Solution: Ensure you're passing the Client ID output from the Connect node
No Error but Operations Fail After Disconnect
- Cause: Attempting to use Lemlist nodes after disconnecting
- Solution: Ensure Disconnect is the last Lemlist operation in your flow, or create a new connection if more operations are needed
Security Considerations
- Use Disconnect to ensure credentials are removed from memory as soon as they're no longer needed
- Even if Disconnect fails, credentials are automatically cleaned up when the flow stops
- For long-running flows, disconnect and reconnect periodically to minimize credential exposure time
- Monitor your Lemlist API usage to detect any unauthorized access or connection leaks