Functions

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:

TypePurposeGuide
transformExtract structured JSON from documentsTransform Functions Guide
analyzeVisual analysis of images and documentsAnalyze Functions Guide
routeClassify and route data to different pathsRoute Functions Guide
splitSplit multi-page documents into piecesSplit Functions Guide
joinCombine multiple inputs into one outputJoin Functions Guide
payload_shapingTransform data with JMESPath expressionsPayload Shaping Functions Guide
enrichSemantic search against collectionsEnrich 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.

POST
/v2/functions
x-api-key<token>

Authenticate using API Key in request header

In: header

Request Body

application/json

functionName*string

Name of function. Must be UNIQUE on a per-environment basis.

displayName?string

Display name of function. Human-readable name to help you identify the function.

tags?array<>

Array of tags to categorize and organize functions.

outputSchemaName?string

Name of output schema object.

outputSchema?object

Desired output structure defined in standard JSON Schema convention.

tabularChunkingEnabled?boolean

Whether tabular chunking is enabled on the pipeline. This processes tables in CSV/Excel in row batches, rather than all rows at once.

type*string
Value in"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
}