Create a Function
Create a new function to process and transform data.
Functions are the core building blocks for data transformation. The type field in the request body determines
which kind of function to create, and each type has its own required configuration.
Function Types
Each function type has detailed documentation with examples and best practices:
| Type | Purpose | Guide |
|---|---|---|
transform | Extract structured JSON from documents | Transform Functions Guide |
analyze | Visual analysis of images and documents | Analyze Functions Guide |
route | Classify and route data to different paths | Route Functions Guide |
split | Split multi-page documents into pieces | Split Functions Guide |
join | Combine multiple inputs into one output | Join Functions Guide |
payload_shaping | Transform data with JMESPath expressions | Payload Shaping Functions Guide |
enrich | Semantic search against collections | Enrich Functions Guide |
See the Function Types Overview for help choosing the right type.
Quick Reference
Transform Functions
Extract structured data from documents. Requires outputSchema and outputSchemaName.
Full documentation
Analyze Functions
Visual analysis optimized for images and scanned documents. Requires outputSchema and outputSchemaName.
Full documentation
Route Functions
Classify and direct data to different processing paths. Requires description and routes array.
Full documentation
Split Functions
Break multi-page documents into smaller pieces. Requires splitType (print_page or semantic_page).
Full documentation
Join Functions
Combine multiple inputs into a single output. Requires joinType, outputSchema, and outputSchemaName.
Full documentation
Payload Shaping Functions
Transform data using JMESPath expressions. Requires shapingSchema.
Full documentation
Enrich Functions
Add context via semantic search against collections. Requires config with collectionName.
Full documentation
Versioning
Each create operation creates version 1 of the function. Updates create new versions automatically.
Use GET /v2/functions/{functionName}/versions to list all versions.
Authorization
API Key Authenticate using API Key in request header
In: header
Request Body
application/json
Name of function. Must be UNIQUE on a per-environment basis.
Display name of function. Human-readable name to help you identify the function.
Array of tags to categorize and organize functions.
Name of output schema object.
Desired output structure defined in standard JSON Schema convention.
Whether tabular chunking is enabled on the pipeline. This processes tables in CSV/Excel in row batches, rather than all rows at once.
"transform"Response Body
application/json
curl -X POST "https://api.bem.ai/v2/functions" \ -H "Content-Type: application/json" \ -d '{ "type": "payload_shaping", "functionName": "extract-freight-tender-summary", "displayName": "Extract Freight Tender Summary", "shapingSchema": " { \"load_reference\": tenders[0].loadReference, \"total_weight_tons\": tenders[].weightTons | sum(@), \"origins\": tenders[].origin | unique(@), \"submitters\": tenders[].submitter.name | unique(@) }" }'{
"functionID": "string",
"functionName": "string",
"versionNum": 0,
"usedInWorkflows": [
{
"workflowID": "string",
"workflowName": "string",
"currentVersionNum": 0,
"usedInWorkflowVersionNums": [
0
]
}
],
"displayName": "string",
"tags": [
"string"
],
"audit": {
"functionCreatedBy": {
"userActionID": "string",
"userID": "string",
"userEmail": "string",
"apiKeyName": "string",
"emailAddress": "string",
"createdAt": "2019-08-24T14:15:22Z"
},
"functionLastUpdatedBy": {
"userActionID": "string",
"userID": "string",
"userEmail": "string",
"apiKeyName": "string",
"emailAddress": "string",
"createdAt": "2019-08-24T14:15:22Z"
},
"versionCreatedBy": {
"userActionID": "string",
"userID": "string",
"userEmail": "string",
"apiKeyName": "string",
"emailAddress": "string",
"createdAt": "2019-08-24T14:15:22Z"
}
},
"type": "transform",
"outputSchemaName": "string",
"outputSchema": {},
"emailAddress": "string",
"tabularChunkingEnabled": true
}