Introduction to Lark Form subscription in n8n
Integrating Lark Forms with n8n opens up many possibilities for automating your workflow. When a new form is submitted or an approval is created, n8n can automatically receive notifications and process data according to the workflow you have set up. However, to establish this connection, you need to correctly follow the procedure for subscribing a form with the Lark API.
In this article, I will guide you through 3 detailed basic steps to subscribe a new Lark Form. Once completed, you will be able to reuse this process for any future forms without having to figure it out from scratch.
1. Get the Approval Code (Form Identifier)
The Approval Code is the unique ID of each form template in the Lark system. This is the most important information so that Lark knows which form n8n wants to “listen” for events from. Each form will have a unique code, and you need to get this exact code to ensure the webhook works correctly.
How to get the Approval Code
Step 1: Log in to Lark and access your Approval or Forms management section.
Step 2: Open the form you want to integrate with n8n. You can open the form in Design mode or in the Approval Management section.
Step 3: Look at the browser's URL address bar. The Approval Code is usually located right in the URL, possibly appearing after the parameter definitionCode= or located between forward slashes.
Specific example
Suppose the URL of the form you are opening is:
https://example.larksuite.com/approval/definitionCode=8C49EDF7-8116-448C-8131-83D2071B632E
Then your Approval Code is: 8C49EDF7-8116-448C-8131-83D2071B632E
Copy this code and save it in a safe place; you will need to use it in step 3.
2. Get the Tenant Access Token (Authentication Key)
The Tenant Access Token is an authentication string that helps the Lark API confirm that your application (in this case, the Approval-N8N app) has the right to perform operations with the form. This is the information that many people often overlook or do not know how to obtain when setting up for the first time.
Why is a Tenant Access Token needed?
Lark uses the OAuth 2.0 mechanism to secure the API. Every request sent to the Lark API needs a valid token in the header for authentication. If the token is missing or invalid, the API will return a 401 Unauthorized error.
Fastest way to get the Tenant Access Token
Method 1: Use Lark API Explorer (Recommended for beginners)
- Access Lark API Explorer (usually located at
https://open.larksuite.com/api-explorer). - In the top left corner, select the correct App you created (e.g., Approval-N8N).
- Lark will automatically display a token string starting with
t-in the side pane. This is your Tenant Access Token. - Copy this entire token string (including the
t-).
Method 2: Call the API to get the Token (For experienced users)
You can also directly call the endpoint /auth/v3/tenant_access_token/internal with the App ID and App Secret to get the token. However, this method is more complex and requires you to manage App credentials.
Important note about Token expiration
This token is only valid for 2 hours. After 2 hours, the token will expire and you need to get a new one. This is why in the “Quick Tip” section at the end of the post, I will guide you on how to automate this token retrieval so you don't have to do it manually every time.
If you are setting up for the first time and just want to test, manually getting the token from API Explorer is enough. But if you need to register multiple forms or want the system to run long-term, refer to the automation section at the end of the post.
3. Configure the HTTP Request Node in n8n
Once you have both pieces of important information (Approval Code and Tenant Access Token), you will use them to configure an HTTP Request node in n8n. This node will send a subscribe command to the Lark API, requesting Lark to send webhooks to n8n whenever an event occurs with the form.
Detailed configuration steps
Step 1: Create a new HTTP Request node in n8n
In your workflow, add a new node and select the type HTTP Request.
Step 2: Set the Method
Select the method as POST. This is the standard method for sending a subscribe command to the Lark API.
Step 3: Set the URL
The URL will look like this:
https://open.larksuite.com/open-apis/approval/v4/approvals/{{Approval_Code}}/subscribe
Where you need to replace {{Approval_Code}} with the Approval Code you obtained in step 1.
Example: If your Approval Code is 8C49EDF7-8116-448C-8131-83D2071B632E, then the full URL will be:
https://open.larksuite.com/open-apis/approval/v4/approvals/8C49EDF7-8116-448C-8131-83D2071B632E/subscribe
Step 4: Set the Headers
The Headers section is very important because it contains the authentication information. You need to add a new header with the following information:
- Name:
Authorization - Value:
Bearer [Tenant_Access_Token]
Extremely important note: There must be the word Bearer (capitalized B) and a space before the token string. Many people make the mistake of forgetting the space or misspelling Bearer, leading to the API returning an authentication error.
Example: If your token is t-g1044ghHGHJKL..., then the value in the header will be:
Bearer t-g1044ghHGHJKL...
Step 5: Test and Execute
After completing the configuration, press Execute to test. If everything is correct, you will receive a success response from the Lark API, confirming that the form has been successfully subscribed.
💡 Quick Tip: Automate Token retrieval for next time
As mentioned, the Tenant Access Token is only valid for 2 hours. If you need to register many forms or want the system to automatically renew the token, you should create a separate workflow to automate this process.
Automatic workflow consists of 2 nodes
Node 1: Get Tenant Access Token automatically
Create an HTTP Request node with the following configuration:
- Method: POST
- URL:
https://open.larksuite.com/open-apis/auth/v3/tenant_access_token/internal - Body (JSON):
{
"app_id": "YOUR_APP_ID",
"app_secret": "YOUR_APP_SECRET"
}This node will return a new token every time it is executed. You can save this token into a variable to use for the next node.
Node 2: Use Token to Subscribe Form
Use the token from Node 1 to send the subscribe command as instructed in step 3. You can use the expression {{$node["Node1"].json["tenant_access_token"]}} to get the token from the output of Node 1.
Benefits of automation
With this workflow, every time you need to register a new form, you only need to:
- Get the Approval Code from the URL (30 seconds)
- Paste the Approval Code into Node 2 (10 seconds)
- Execute workflow (5 seconds)
No need to go to API Explorer to get the token manually anymore!
Conclusion
Subscribing to a Lark Form in n8n is not complicated if you master 3 basic steps: Get the Approval Code, get the Tenant Access Token, and configure the HTTP Request node. Once set up, you can leverage the power of n8n to automate all processes related to your forms.
If you encounter difficulties during the setup process or want me to send the automatic token retrieval workflow template, please leave a comment below!
