POST
/
cloud
/
v1
/
faas
/
namespaces
/
{project_id}
/
{region_id}
/
{namespace_name}
/
functions
Create function
curl --request POST \
  --url https://api.gcore.com/cloud/v1/faas/namespaces/{project_id}/{region_id}/{namespace_name}/functions \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "autoscaling": {
    "max_instances": 2,
    "min_instances": 1
  },
  "code_text": "def main():\n    return '\''Hello World'\''",
  "dependencies": "numpy==1.21.0\npandas==1.3.0",
  "description": "This is a sample function.",
  "enable_api_key": true,
  "envs": {
    "ENV_VAR": "value"
  },
  "flavor": "64m-64MB",
  "main_method": "handler",
  "name": "function-name",
  "runtime": "python3.7.12",
  "timeout": 5
}'
{
  "tasks": [
    "d478ae29-dedc-4869-82f0-96104425f565"
  ]
}

Authorizations

Authorization
string
header
required

API key for authentication. Make sure to include the word apikey, followed by a single space and then your token. Example: apikey 1234$abcdef

Path Parameters

project_id
integer
required

Project ID

Examples:

1

region_id
integer
required

Region ID

Examples:

1

namespace_name
string
required

Namespace name

Examples:

"namespace-name"

Body

application/json
autoscaling
object
required

Autoscaling configuration for the function. Keys must be 'min_instances' or 'max_instances', and values must be integers between 0 and 50.

code_text
string
required

Function code text.

Required string length: 1 - 100000
Examples:

"def main():\n return 'Hello World'"

flavor
string
required

The name of the flavor associated with the function.

Examples:

"64m-64MB"

main_method
string
required

The main startup method name.

Required string length: 1 - 100
Examples:

"handler"

name
string
required

Function name.

Examples:

"function-name"

runtime
string
required

Function runtime.

Examples:

"python3.7.12"

timeout
integer
required

Function timeout in seconds.

Required range: 0 <= x <= 180
Examples:

5

dependencies
string
default:""

Dependencies for the function to install.

Maximum length: 100000
Examples:

"numpy==1.21.0\npandas==1.3.0"

description
string
default:""

Description of the function.

Maximum length: 255
Examples:

"This is a sample function."

enable_api_key
boolean | null

Enable or disable API key authentication. Enable api key is temporarily disabled. As a result, using Functions with authorization is currently not supported.

Examples:

true

envs
object

Environment variables for the function. Keys must match a specific regex pattern and be 1-255 characters long, and values must be 0-255 characters long.

Examples:
{ "ENV_VAR": "value" }

Response

200 - application/json

OK

tasks
string[]
required

List of task IDs

Examples:
["d478ae29-dedc-4869-82f0-96104425f565"]