Actions7
Overview
The Manage Session operation of the "Instagram Private API" n8n node allows users to handle Instagram session data. This is particularly useful for workflows that require persistent authentication with Instagram, avoiding repeated logins and reducing the risk of triggering security checks or rate limits. Typical scenarios include:
- Retrieving the current Instagram session data for backup or migration.
- Logging in to Instagram and capturing fresh session data for use in future node executions.
Practical examples:
- Automating the process of updating Instagram credentials in n8n by exporting/importing session data.
- Maintaining a stable session across multiple workflow runs without re-authenticating each time.
Properties
| Display Name | Type | Meaning |
|---|---|---|
| Session Action | options | Determines what session-related action to perform: - Get Current Session: Retrieve the current session data. - Login and Get Session: Log in to Instagram and obtain new session data. |
Output
The output is a JSON object (or array) with the following possible fields, depending on the selected Session Action:
For "Get Current Session":
{
"success": true,
"message": "Session data retrieved successfully",
"sessionData": { /* Instagram session data object */ },
"instructions": "Copy this session data and update your Instagram credentials with it to maintain your session between runs."
}
If no session data is found:
{
"success": false,
"message": "No session data found in credentials",
"instructions": "Use the \"Login and Get Session\" action to create a new session."
}
For "Login and Get Session":
{
"success": true,
"message": "Successfully logged in and captured session data",
"sessionData": { /* Instagram session data object */ },
"instructions": "Copy this session data and update your Instagram credentials with it to maintain your session between runs."
}
If login succeeds but session data cannot be captured:
{
"success": false,
"message": "Login successful but failed to capture session data",
"instructions": "Try again or check the logs for more information."
}
Note:
- The
sessionDatafield contains the raw session object required for maintaining authentication. - The
instructionsfield provides guidance on how to use the session data within n8n.
Dependencies
- External Service: Instagram account (username & password).
- API Key/Credentials: Requires n8n credentials of type
instagramPrivateApi, which should include username, password, and optionally existing session data. - Node.js Modules: Uses
instagram-private-api,fs,path, andos. - n8n Configuration: No special environment variables are required, but the node stores session files under the user's home directory at
.n8n/instagram-sessions.
Troubleshooting
Common Issues:
- Invalid Credentials: If the provided Instagram username or password is incorrect, authentication will fail.
- Session Expiry: If the session data is outdated or invalid, you may need to use "Login and Get Session" to refresh it.
- File System Permissions: The node writes session files to the local filesystem; ensure n8n has write access to the
.n8n/instagram-sessionsdirectory. - Instagram Security Checks: Frequent logins or suspicious activity may trigger Instagram's checkpoint or verification requirements.
Error Messages and Resolutions:
"Failed to authenticate with Instagram. Please check your credentials."
Resolution: Double-check your Instagram username and password in the n8n credentials."No session data found in credentials"
Resolution: Use the "Login and Get Session" action to generate new session data."Login successful but failed to capture session data"
Resolution: Try running the operation again or check the n8n logs for more details."Checkpoint required. Please verify your account."
Resolution: Log in to Instagram manually and complete any required verification steps.