Skip to main content

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.

Base URL
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.

FieldTypeRequiredDescription
org_idstring✅ YesOrganisation identifier
project_idstring✅ YesProject identifier
space_idstring✅ YesSpace the module is scoped to
user_idstring✅ YesAuthenticated user's identifier
modulestring✅ YesModule name — used to import and reference this module
codestring (YAML block scalar)✅ YesStarlark 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

ParamTypeRequiredDescription
formatstring❌ NoResponse 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

ParamTypeRequiredDescription
modulestring✅ YesName of the module to retrieve

Delete a Module

Permanently deletes a Lark module from the space.

DELETE /minimal/code/v1/lark?module={module_name}
danger

Deleting a module will break any Custom API definitions that import it. Remove all references before deleting.

Query Parameters

ParamTypeRequiredDescription
modulestring✅ YesName 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.

HeaderDescription
X-Org-IdOrganisation identifier
X-Project-IdProject identifier
X-Space-IdSpace the module is scoped to
X-User-IdAuthenticated user's identifier
X-User-RolesComma-separated roles (e.g., users,admin)

Common Errors

CodeCause
400Malformed YAML body or missing module / code field
401Missing X-User-Id header
404Module not found — check the module query param
422Starlark syntax error in the code block