Skip to content

Automation

Automate document generation using Lark Base Automations. Generate documents automatically when records are created, updated, or when specific conditions are met.

  1. Go to the Template tab.
  2. Open the Automation section and expand HTTP Trigger.
  3. Copy the webhook URL provided.
  1. Open your Base → Automations.
  2. Create a new automation.
  3. Add a trigger (e.g. “When record is created”).
  4. Add the action Send HTTP Request.
  5. Configure: Method = POST, URL = the webhook URL + ?recordId={{record_id}}.
  6. Add header: X-Webhook-API-Key: <your API key>.

Webhook URL format:

https://api.automadoc.cc/api/webhook/templates/{templateId}/generate?recordId={recordId}

The key can be the template’s own or a company API key, which an app admin creates in the Company Portal under Company → API keys and which works for every template. The response lists the generationIds of the documents it started; GET /api/v1/documents/{generationId} reports each one.

To send each generated document out for signature, give the Send HTTP Request step a JSON body (Content-Type: application/json):

{ "sign": {} }

The signers come from the record, as set under Signing by automation on the Template tab; links and generated passwords for anyone outside are written back to the record for your automation to email. To name a signer in the request instead, give signers by role, as the document API takes them. See E-signature.

Every recipe ends with the same step: Send HTTP Request with method POST, the webhook URL followed by ?recordId= and the record ID of the record the trigger found, and the header X-Webhook-API-Key. Only the trigger changes. Trigger names vary slightly between Lark versions.

When a record is added: a document for every new record, e.g. a quote as soon as a request is entered. Choose the trigger for new records, and the table.

When a record is edited: a fresh document when a record changes. Pick the trigger for modified records and the fields to watch (for example only Amount and Customer), so an unrelated edit does not make a new document.

When a record meets conditions: a document at the moment a record reaches a state, e.g. Status becomes Approved. This is the most common recipe: it runs once, when the condition starts to hold.

When a date is reached: a document on a date in the record, e.g. a reminder letter on Due date, or seven days before it. Choose the date field and the offset.

On a schedule: documents at a set time, e.g. every Monday at 9:00. A schedule has no record of its own, so add a Find records step (for example “Status is Open”), then send the HTTP request for the records it found, using their record ID. Check in a test run that the request is sent once per record.

AnyCross and other integration tools can call AutomaDoc with a plain HTTP request node. To generate from a Base record, use the HTTP trigger above. To generate from data that is not in a Base (a form, an ERP), use the document API, which takes the data as JSON:

Setting Value
Method POST
URL https://api.automadoc.cc/api/v1/templates/{templateId}/documents?wait=20
Header X-Webhook-API-Key: your template or company API key
Header Content-Type: application/json
Body {"data": { … the fields of your document … }}

With ?wait=20 the response arrives once the document is ready, and its downloadUrl can be passed to the next node, to attach the file to a message or save it to Drive.

When a refusal is about your plan, the HTTP trigger answers 403 with a code in the JSON body:

code Why What to do
AUTOMATION_NOT_INCLUDED Your company has no Pro plan, no active trial and no Business seat. Buy a Business seat or Pro on the Billing page of the Company Portal.
QUOTA_EXCEEDED The automated documents included with your Business seats and the free monthly allowance are used up, and no document pack has documents left. Buy a document pack on the Billing page, or wait for the next period.
TEMPLATE_DISABLED The template is locked: your company has more templates than its plan allows. Raise the template allowance on the Billing page (a plan, seats or Extra Templates), or delete a template. A locked template comes back within 24 hours.

A missing X-Webhook-API-Key is refused with 401 (API_KEY_MISSING), and a wrong one, or one that does not open this template, with 403 (API_KEY_INVALID).

The HTTP trigger accepts 300 requests a minute per template, a budget of its own: a Lark automation sends each record once and does not retry, so it is not held to the document API’s 60. Its documents count toward the company’s 600 a minute, shared with the document API. Over either limit it answers 429 (RATE_LIMITED) and makes no document for that request, so spread a very large import over a few minutes. Every other refusal has a code too, for example RECORD_ID_REQUIRED (400, no recordId) and WORKER_UNAVAILABLE (502, try again shortly).

Receive notifications when documents are generated. Perfect for triggering follow-up automations.

  1. On the Template tab, open the Automation section and turn on Webhook Callback.
  2. Enter your webhook URL.
  3. Optionally, add a Bearer token for authentication.

AutomaDoc sends a POST with this JSON body:

{
"url": "https://api.automadoc.cc/...?expires=...&signature=...",
"filename": "Invoice-INV-2024-001.pdf",
"fields": { "Customer_Name": "Acme Corp", "Total_Amount": "1,500.00" }
}
  • url: signed download link, valid for 2 hours.
  • filename: the generated filename, after the filename pattern is applied.
  • fields: the record’s plain values used for the generation: text, numbers, dates and the like, as the document prints them. Linked records, lists and attachments are left out.
  • warnings: only when the generation warned about something, such as a picture that could not be fetched (named by its field and the URL’s host).

If the Bearer token is set, it is sent as the Authorization header.

  • Triggering follow-up Lark automations
  • Sending Lark Messenger notifications via bots
  • Integrating with Lark Approval workflows: to generate a document when a request is approved, see Approval documents, which needs no automation
  • Archiving documents to Lark Docs or Drive