Skip to main content

/functions/rest/v1/namespaces/{id}/functions REST Method

Creates a new Function.

Updated on
Jul 9, 2024

/functions/rest/v1/namespaces/{id}/functions REST Method

Path Parameters

id
string
REQUIRED
The ID of the namespace associated with this function.

Body Parameters

name
string
REQUIRED
A name for your function. The value you provide for 'name' will be converted to kebab case (all lowercase with words separated by hyphens).
description
string
A description of your function. Accepts markdown.
kind
string
REQUIRED
The runtime for your function. ENUM: "nodejs-qn:20", "python-qn:3.11"
code
string
REQUIRED
The code for your function encoded in base64. This field accepts base64 encoded string containing your function code or a base64 encoded zip archive of your function and its dependencies.
binary
boolean
REQUIRED
Indicates whether the code field contains a zip archive.
limits
object
REQUIRED
An object containing the limits for your function.
timeout
integer
REQUIRED
The maximum time in milliseconds that your function can run. Must be between 5000 and 60000
memory
integer
REQUIRED
The maximum memory in MB that your function can use. Must be one of 128, 256, 512

Returns

name
string
The name of the function.
description
string
The description of your function.
namespace
string
The ID of the namespace associated with this function.
created_at
string
The timestamp when the function was created.
updated_at
string
The timestamp when the function was updated.
qn_account_id
string
The ID of the QuickNode account that created the function.
exec
object
The code attributes of the function.
kind
string
The runtime for your function. ENUM: "nodejs-qn:20", "python-qn:3.11"
code
string
The code for your function encoded in base64.
binary
boolean
Whether the code field contains a zip archive.
limits
object
The limits for the function.
timeout
integer
The maximum time in milliseconds that your function can run.
memory
integer
The maximum memory in MB that your function can use.
concurrency
integer
The maximum number of concurrent executions of your function.
Request
1
curl -X POST \
2
"https://api.quicknode.com/functions/rest/v1/namespaces/{id}/functions" \
3
-H "accept: application/json" \
4
-H "Content-Type: application/json" \
5
-H "x-api-key: YOUR_API_KEY" \
6
-d $'{
7
"name": "MyFunction",
8
"description": "MyFunction Description",
9
"kind": "nodejs-qn:20",
10
"code": "ZnVuY3Rpb24gbWFpbihwYXJhbXMpIHsKICAgIC8vIEV4dHJhY3QgZGF0YXNldCBhbmQgbmV0d29yayBmcm9tIG1ldGFkYXRhIGluIHBhcmFtcwogICAgY29uc3QgZGF0YXNldCA9IHBhcmFtcy5tZXRhZGF0YS5kYXRhc2V0OwogICAgY29uc3QgbmV0d29yayA9IHBhcmFtcy5tZXRhZGF0YS5uZXR3b3JrOwoKICAgIGNvbnNvbGUubG9nKGBUaGlzIGlzIGEgbG9nIGZyb20gdGhlICR7ZGF0YXNldH0gZGF0YXNldCBvbiB0aGUgJHtuZXR3b3JrfSBuZXR3b3JrLmApOwoKICAgIHJldHVybiB7IAogICAgICAgIG1lc3NhZ2U6IGBUaGlzIGlzIHRoZSByZXR1cm4gZnJvbSB0aGUgJHtkYXRhc2V0fSBkYXRhc2V0IG9uIHRoZSAke25ldHdvcmt9IG5ldHdvcmsuYCwKICAgICAgICBwYXJhbXMKICAgIH07Cn0=",
11
"binary": false,
12
"limits": {
13
"timeout": 5000,
14
"memory": 128
15
}
16
}'
17
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free