Path parameters
-
An Atlas Project/Group ID.
-
The ObjectID of your application. The App Services API Project and Application IDs section demonstrates how to find this value.
Body
Required
The function to create
-
A JSON expression that evaluates to
trueif the Function is allowed to run in response to an incoming request. -
A unique name for the Function.
-
If
true, the function is hidden from client applications. You can still call a private function from JSON expressions and other functions, including incoming webhooks and triggers. -
The stringified source code for the function. The code must be valid ES6.
-
If
true, the function executes with full privileges, bypassing rules on all services. -
An application user's account ID. If defined, endpoints will always run as the specified user. Cannot be used with
run_as_user_id_script_source. -
The stringified source code for a function that returns an application user's account ID. If defined, endpoints execute the function on every request and run as the user with the ID returned from the function. Cannot be used with
run_as_user_id.
curl \
--request POST 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/functions' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"can_evaluate":{},"name":"string","private":true,"source":"string","run_as_system":true,"run_as_user_id":"string","run_as_user_id_script_source":"string"}'
{
"can_evaluate": {},
"name": "string",
"private": true,
"source": "string",
"run_as_system": true,
"run_as_user_id": "string",
"run_as_user_id_script_source": "string"
}
{
"_id": "string",
"name": "string"
}