Lark Modules
Lark modules let you define reusable Starlark functions that can be imported and called inside your Custom API definitions. Modules are scoped to a space and stored server-side — create them once, use them across multiple definitions.
https://<your-domain>/minimal/code/v1/lark
Create or Update a Module
Create a new module or update an existing one. Both operations use the same POST endpoint —
if a module with the given module name already exists in the space, it is overwritten.
POST /minimal/code/v1/lark/
Request Body
The body is YAML-formatted text. The first block contains the space identifiers; the second block defines the module.
| Field | Type | Required | Description |
|---|---|---|---|
org_id | string | ✅ Yes | Organisation identifier |
project_id | string | ✅ Yes | Project identifier |
space_id | string | ✅ Yes | Space the module is scoped to |
user_id | string | ✅ Yes | Authenticated user's identifier |
module | string | ✅ Yes | Module name — used to import and reference this module |
code | string (YAML block scalar) | ✅ Yes | Starlark function definitions using ` |
Example — strings module:
org_id: <your-org-id>
project_id: <your-project-id>
space_id: <your-space-id>
user_id: <your-user-id>
module: strings
code: |
def slugify(s):
result = ""
s = s.lower()
for i in range(len(s)):
c = s[i]
if c.isalnum():
result += c
elif c == " " and not result.endswith("-"):
result += "-"
return result.strip("-")
Example — math module:
org_id: <your-org-id>
project_id: <your-project-id>
space_id: <your-space-id>
user_id: <your-user-id>
module: math
code: |
def clamp(val, lo, hi):
if val < lo: return lo
if val > hi: return hi
return val
def lerp(a, b, t):
return a + (b - a) * t
def map_range(val, in_lo, in_hi, out_lo, out_hi):
return (val - in_lo) * (out_hi - out_lo) / (in_hi - in_lo) + out_lo
Response
201 Created — module saved successfully:
{
"code": 201,
"status": "Created",
"message": "lark module saved successfully"
}
List Modules
Returns all Lark modules registered under the space.
GET /minimal/code/v1/lark/list
Query Parameters
| Param | Type | Required | Description |
|---|---|---|---|
format | string | ❌ No | Response format — json (default) or xml |
Get a Module
Returns the code for a specific Lark module by name.
GET /minimal/code/v1/lark?module={module_name}
Query Parameters
| Param | Type | Required | Description |
|---|---|---|---|
module | string | ✅ Yes | Name of the module to retrieve |
Delete a Module
Permanently deletes a Lark module from the space.
DELETE /minimal/code/v1/lark?module={module_name}
Deleting a module will break any Custom API definitions that import it. Remove all references before deleting.
Query Parameters
| Param | Type | Required | Description |
|---|---|---|---|
module | string | ✅ Yes | Name of the module to delete |
Response
200 OK:
{
"code": 200,
"status": "OK",
"message": "lark module deleted successfully"
}
Required Headers
All Lark module endpoints require these headers.
| Header | Description |
|---|---|
X-Org-Id | Organisation identifier |
X-Project-Id | Project identifier |
X-Space-Id | Space the module is scoped to |
X-User-Id | Authenticated user's identifier |
X-User-Roles | Comma-separated roles (e.g., users,admin) |
Common Errors
| Code | Cause |
|---|---|
400 | Malformed YAML body or missing module / code field |
401 | Missing X-User-Id header |
404 | Module not found — check the module query param |
422 | Starlark syntax error in the code block |