Skip to main content
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": 25,
    "min_instances": 25
  },
  "code_text": "<string>",
  "flavor": "<string>",
  "main_method": "<string>",
  "name": "<string>",
  "runtime": "<string>",
  "timeout": 90,
  "dependencies": "",
  "description": "",
  "enable_api_key": true,
  "envs": {}
}
'
{
  "tasks": [
    "<string>"
  ]
}

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

region_id
integer
required

Region ID

namespace_name
string
required

Namespace name

Body

application/json
autoscaling
FaasAutoscalingSerializer · 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
flavor
string
required

The name of the flavor associated with the function.

main_method
string
required

The main startup method name.

Required string length: 1 - 100
name
string
required

Function name.

runtime
string
required

Function runtime.

timeout
integer
required

Function timeout in seconds.

Required range: 0 <= x <= 180
dependencies
string
default:""

Dependencies for the function to install.

Maximum string length: 100000
description
string
default:""

Description of the function.

Maximum string length: 255
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.

Example:

true

envs
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.

Response

200 - application/json

OK

tasks
string[]
required

List of task IDs representing asynchronous operations. Use these IDs to monitor operation progress:

  • GET /v1/tasks/{task_id} - Check individual task status and details Poll task status until completion (FINISHED/ERROR) before proceeding with dependent operations.