Functions API

Overview of functions API methods

post
Execute Function

https://api.codemash.io/:version/serverless/functions/:id/execute
Executes a function during a request.
Request
Response
Request
Path Parameters
version
required
string
The version of the API endpoint. Current latest v1.
id
required
string
The ID of function to be executed.
Headers
Authorization
required
string
Your project's secret key.
x-cm-projectid
required
string
Your project's ID. Can be passed as a query parameter.
Body Parameters
Template
optional
string
Parameter of JSON format to pass into the function.
Qualifier
optional
string
Version or alias of a function to execute.
Response
200: OK
Returns a response received from a function as string.
{
Result: ""
}
401: Unauthorized
Returns if the user does not have a valid permission to call this method.
500: Internal Server Error
.NET
Node
PHP
.NET
var client = new CodeMashClient(apiKey, projectId);
var codeService = new CodeMashCodeService(client);
var response = await codeService.ExecuteFunctionAsync(new ExecuteFunctionRequest
{
Id = Guid.Parse("{FUNCTION_ID}"),
});
Node
PHP
use Codemash\CodemashClient;
use Codemash\CodemashCode;
class CodemashService
{
protected CodemashCode $codemashCode;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$this->codemashCode = new CodemashAuth($client);
}
public function executeFunction()
{
$responseData = $this->codemashCode->executeFunction([
'id' => '{YOUR_FUNCTION_ID}',
]);
}
}

In order to execute the function method, you can use GET method instead of POST.