Skip to content

Create a Function

POST
/api/v1/faas/functions/
curl --request POST \
--url 'https://api.e2enetworks.com/myaccount/api/v1/faas/functions/?project_id=<PROJECT_ID>&location=<LOCATION>&apikey=<API_KEY>' \
--header 'Authorization: Bearer <API_TOKEN>'

Creates a new function with provided configurations and uploads the code file.

project_id
required
integer
location
required
string
Allowed values: Delhi Chennai

Deployment region for the resource. Accepted values: Delhi, Chennai.

Mumbai region has been discontinued. Delhi and Chennai are the only supported regions.

Media typemultipart/form-data
object
function_name
required

Unique name for the function

string

Example

e2e-function-55619
runtime
required

Runtime environment

string
Allowed values: python-3.11-fastapi python-3.11-flask node-20-express node-18-express python-3.11-http node-20-http dotnet-7.0-http php-8.2-http go-1.21-http python-3.9-http gpu-pytorch-fastapi gpu-pytorch-flask gpu-tensorflow-fastapi gpu-tensorflow-flask custom-container-cpu

Example

python-3.11-fastapi
memory
required

Memory allocated to the function (in MB)

string
Allowed values: 128 256 512 1024

Example

128
timeout
required

Timeout for the function (in seconds)

string

Example

15
environment_variables
required

JSON string of environment variables

string

Example

{
"env_name": "env_value"
}
code_file
required

Zipped function source code (.zip file)

string format: binary

Function created successfully

Media typeapplication/json
object
code
integer
data
object
files
Array<object>
object
file_path
string
content
string
id
integer
errors
object
message
string

Example

{
"code": 200,
"data": {
"files": [
{
"file_path": "e2e-function-91786/func.py",
"content": "from fastapi import FastAPI, Request\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom pydantic import BaseModel\n\napp = FastAPI()\napp.add_middleware(CORSMiddleware, allow_origins=[\"*\"], allow_methods=[\"*\"], allow_headers=[\"*\"])\n\nclass Payload(BaseModel):\n name: str = \"World\"\n\n@app.get(\"/\")\nasync def get_handler():\n return {\"message\": \"Hello from FastAPI GET\"}\n\n@app.post(\"/\")\nasync def post_handler(payload: Payload):\n return {\"message\": f\"Hello, {payload.name}!\"}\n"
}
],
"id": 185
},
"errors": {},
"message": "Success"
}