Using bem
Calling a Workflow or Function
Learn how to call a bem Function with your data. This guide covers how to send a batch of items for asynchronous processing using the function call endpoint.
Updated 12/11/2025
Once you have defined your logic, you can execute it by making a "Call". You can call a specific Workflow or an individual Function.
You make a POST request to the /v2/calls endpoint.
Calling a Workflow
This is the recommended way to process data. By calling a workflow, you trigger the entire sequence of functions defined in that workflow.
1curl -X POST https://api.bem.ai/v2/functions/enterprise-invoice-processor/call/v2/calls \
2 -H "x-api-key: <YOUR_BEM_API_KEY>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "calls": [
6 {
7 "workflowID": "wf_12345",
8 "callReferenceID": "your_internal_id_1",
9 "input": {
10 "singleFile": {
11 "inputType": "pdf",
12 "inputContent": "data:application/pdf;base64,..."
13 }
14 }
15 }
16 ]
17 }'Calling a Function Directly
You can also call a specific function directly if you need to run a single isolated task.
1curl -X POST https://api.bem.ai/v2/functions/enterprise-invoice-processor/call/v2/calls \
2 -H "x-api-key: <YOUR_BEM_API_KEY>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "calls": [
6 {
7 "functionID": "fn_67890",
8 "callReferenceID": "your_internal_id_2",
9 "input": {
10 "singleFile": {
11 "inputType": "pdf",
12 "inputContent": "data:application/pdf;base64,..."
13 }
14 }
15 }
16 ]
17 }'Understanding the Response
bem will return a list of created calls with their callID and status.
1{
2 "functionCalls": [
3 {
4 "functionCallID": "fnc_a1b2c3d4e5",
5 "referenceID": "inv_abc_123",
6 "status": "pending",
7 ...
8 },
9 {
10 "functionCallID": "fnc_f6g7h8i9j0",
11 "referenceID": "inv_def_456",
12 "status": "pending",
13 ...
14 }
15 ]
16}1{
2 "calls": [
3 {
4 "callID": "call_abc123",
5 "status": "pending",
6 "workflowID": "wf_12345",
7 "createdAt": "2025-12-11T12:00:00Z"
8 }
9 ]
10}