fbpx
POSThttps://api.spotinst.io/functions/function?accountId={ACCOUNT_ID}

Create a new function.

Parameter Type Description
ACCOUNT_ID String

The account ID.

Request

Headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer ${TOKEN}"
}
Body
Copied!
Downloaded!
{
	"function": {
		"name": "my_first_function",
		"stage": "stage_name",
		"environmentId": "env-123456",
		"code": {
			"handler": "hello.HelloJava",
			"source": "{{base64}}"
		},
		"runtime": "java8",
		"limits": {
			"timeout": 60,
			"memory": 128
		},
		"access": "public",
		"activeVersions": [{
			"version": "$LATEST",
			"percentage": 100.0
		}],
		"cors": {
			"enabled": true,
			"origin": "http://foo.example",
			"headers": "Content-Type,Authorize",
			"methods": "PUT,POST"
		},
		"environmentVariables": {
			"envTest": "abcdefg"
		},
		"cron": {
			"active": true,
			"value": "* * * * *"
		},
        "iamRoleConfig": {
          	"roleId": "sfr-5da1aba5"
 		}
	}
}

Body Attributes


  • function.name * String
    The name of the Function. Must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen.
  • function.environmentId * String
    The ID of the environment.
  • function.code.handler * String
    A pointer to the function main handler, should be in the format: ‘fileName.handlerName’. In Java - The class name including your main function, should be in the format: ‘className’.
  • function.code.source * String
    Base64 representation of the archived user code. More info.
  • function.runtime * String
    The type of requested runtime.
  • function.limits * Object
    The Memory and Timeout settings.
  • function.limits.timeout * Integer
    The timeout of the function invocation in seconds (max: 300)
  • function.limits.memory * Integer
    The memory of the function in units of 64Mb (max: 2496)
  • function.access String
    Possible values: “public”, “private” - Where public indicates this function is configured to be executed without the token. default value: “private”
  • functions.environmentVariables String
    map Environment variables as key-value to be set on function context
  • functions.activeVersions Object
    Contains any number of valid active versions
  • functions.activeVersions.version String
    A version ID (number or $LATEST) you would like to deploy to production.
    Example: "2"
    Default: '$LATEST'
  • functions.activeVersions.percentage Double
    The ratio of deployed instances of that version. Must sum to 100.
    Example: 75.0
  • functions.cors Object
    Contains attributes for CORS.
  • functions.cors.enabled Boolean
    Toggle CORS support
    Default: false
  • functions.cors.origin String
    The URL you are permitting to access your function.
    Example: "http://foo.example"
    Default: "*"
  • functions.cors.headers String
    The headers, how the body is encoded.
    Default: 'Content-Type,Authorization'
  • functions.cors.methods String
    Comma-separated list of HTTP methods that are allowed to access the resource.
    Example: "POST"
    Default: 'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'
  • iamRoleConfig.roleId String
    IAM role ID created by Spotinst
Response - 200

Headers
{
  "Content-Type: application/json"
}
Body
Copied!
Downloaded!
{
  "status": {
    "code": 200,
    "message": "OK"
  },
  "count": "1",
  "items": [{
    "id": "fx-12345",
    "name": "my_first_function",
    "environmentId": "env-123456",
    "code": {
      "handler": "hello.HelloJava",
      "source": "INLINE"
    },
    "runtime": "java8",
    "limits": {
        "timeout": 60,
        "memory":128
    },
    "environmentVariables":{
        "envTest": "abcdefg"
    },
    "url": "http://app-8f9x02-testing.execute-function.multai.io/fx-12345"
  }]
}