Function calls

Call a Function

Request Examples

This endpoint supports both multipart/form-data and application/json content types. Using multipart/form-data is recommended as it allows you to send files directly without base64 encoding.

Send a file directly using multipart/form-data. This is the simplest approach and avoids the overhead of base64 encoding.

Single file:

curl -X POST https://api.bem.ai/v2/functions/invoice-extractor/call \
  -H "x-api-key: YOUR_API_KEY" \
  -F "referenceID=ref-001" \
  -F "file=@/path/to/invoice.pdf"

Multiple files (for join functions):

curl -X POST https://api.bem.ai/v2/functions/my-join-function/call \
  -H "x-api-key: YOUR_API_KEY" \
  -F "referenceID=ref-001" \
  -F "files=@/path/to/file1.pdf" \
  -F "files=@/path/to/file2.pdf"

Send file contents as base64-encoded strings in a JSON body.

curl -X POST https://api.bem.ai/v2/functions/invoice-extractor/call \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "arguments": [
      {
        "referenceID": "ref-001",
        "inputType": "pdf",
        "inputContent": "JVBERi0xLjQKJeLjz9..."
      }
    ]
  }'
POST
/v2/functions/{functionName}/call
x-api-key<token>

Authenticate using API Key in request header

In: header

Path Parameters

functionName*string

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://api.bem.ai/v2/functions/string/call" \  -H "Content-Type: application/json" \  -d '{    "arguments": [      {        "referenceID": "string",        "inputType": "csv",        "inputContent": "string"      }    ]  }'
{
  "functionCalls": [
    {
      "functionCallID": "string",
      "functionID": "string",
      "functionName": "string",
      "type": "transform",
      "referenceID": "string",
      "status": "pending",
      "functionVersionNum": 0,
      "activity": [
        {
          "displayName": "string",
          "status": "pending"
        }
      ],
      "startedAt": "2019-08-24T14:15:22Z",
      "finishedAt": "2019-08-24T14:15:22Z",
      "sourceFunctionCallID": "string",
      "sourceEventID": "string",
      "workflowCallID": "string",
      "inputType": "string",
      "s3URL": "string",
      "inputs": [
        {
          "inputType": "string",
          "itemReferenceID": "string",
          "s3URL": "string"
        }
      ]
    }
  ]
}