Naijacloud
Docs

Functions

Every /v1 route for functions. This page is generated from the API's OpenAPI contract, so it always matches what the API accepts and returns.

Authentication, pagination, errors and idempotency work the same on every route. They are described once, in the API overview.

Reserve an upload for a function's code (a .zip, up to 20 MB)

POST /v1/function-uploads

Key scopes: WRITE and PLATFORM_API.

Body

FieldTypeRequiredNotes
projectIdstring (uuid)yes
environmentIdstring (uuid)noDefaults to the project's production environment.
namestringyese.g. hello
sizeBytesnumberyesSize of the zip in bytes.

Returns

bash
curl -X POST "https://api.naijacloud.com/v1/function-uploads" \ -H "Authorization: Bearer $NC_API_KEY" \ -H "Content-Type: application/json" \ -d '{"projectId":"…","name":"hello","sizeBytes":1}'

Deploy an uploaded zip as the next version of a function

POST /v1/functions

Creates the function on its first deploy. The previous version keeps serving until the new one is live, and stays if the deploy fails.

Key scopes: WRITE and PLATFORM_API.

Headers

NameTypeRequiredNotes
Idempotency-KeystringnoAny unique string (1–255 printable characters). A retry with the same key and body returns the first response instead of acting twice, for 24 hours.

Body

FieldTypeRequiredNotes
projectIdstring (uuid)yes
environmentIdstring (uuid)noDefaults to the project's production environment.
namestringyese.g. hello
uploadIdstring (uuid)yes
entrypointstringnoe.g. index.ts
commandstringnoThe command that deployed it, shown on the live version.
tierFREE, PRO, PRO_PLUS, STANDARD, STARTERnoOnly used when this deploy creates the environment's functions runtime. Without it the runtime is Free while the workspace has its free runtime open.

Returns

bash
curl -X POST "https://api.naijacloud.com/v1/functions" \ -H "Authorization: Bearer $NC_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{"projectId":"…","name":"hello","uploadId":"…"}'

Get a function, with its live and newest versions

GET /v1/functions/{functionId}

Key scopes: READ and PLATFORM_API.

Path parameters

NameTypeRequiredNotes
functionIdstringyesThe function's id.

Returns

bash
curl "https://api.naijacloud.com/v1/functions/$FUNCTION_ID" \ -H "Authorization: Bearer $NC_API_KEY"

Delete a function

DELETE /v1/functions/{functionId}

Its URL stops answering and its logs go with it.

Key scopes: WRITE and PLATFORM_API.

Path parameters

NameTypeRequiredNotes
functionIdstringyesThe function's id.

Returns

  • 204 with no body.
bash
curl -X DELETE "https://api.naijacloud.com/v1/functions/$FUNCTION_ID" \ -H "Authorization: Bearer $NC_API_KEY"

List a project environment's functions by name

GET /v1/projects/{projectId}/functions

Key scopes: READ and PLATFORM_API.

Path parameters

NameTypeRequiredNotes
projectIdstringyesThe project's id.

Query parameters

NameTypeRequiredNotes
limitintegernoRows per page. Ignored when a cursor is given.
cursorstringnoThe nextCursor of the previous page, unchanged.
searchstringnoOnly rows whose name contains this. Send the same value with every page of one walk.
environmentIdstring (uuid)noDefaults to the project's production environment.

Returns

  • 200 with a page: { data: V1Function[], nextCursor }, where each item is V1Function.
bash
curl "https://api.naijacloud.com/v1/projects/$PROJECT_ID/functions" \ -H "Authorization: Bearer $NC_API_KEY"

Types

V1Deploy

FieldTypeNotes
idstring (uuid)
serviceIdstring (uuid)
statusQUEUED, BUILDING, TESTING, DEPLOYING, RUNNING, FAILED, CANCELLED, REPLACED, SUPERSEDED
triggerPUSH, MANUAL, ROLLBACK, FIRST_DEPLOY, SYSTEM, or nullWhat started it: a push, a person, a rollback, …
branchstring, or null
commitShastring, or null
commitMessagestring, or null
authorNamestring, or null
buildCommandstring, or null
startCommandstring, or null
errorstring, or nullWhy it failed, written for you.
errorCodeMISSING_SCRIPT, COMMAND_NOT_FOUND, MODULE_NOT_FOUND, BUILD_FAILED, CRASH, OOM, PORT_NOT_LISTENING, HEALTH_TIMEOUT, IMAGE_REJECTED, BUILD_OOM, NODE_BUSY, NODE_LOW_DISK, DATA_SERVICE_ON_OTHER_NODE, FREE_BUILD_LIMIT, UNKNOWN, or null
durationMsnumber, or nullFrom the start of work (not queueing) to the end, in ms.
createdAtstring (date-time)
startedAtstring (date-time), or null
finishedAtstring (date-time), or null

V1DeployFunctionResult

FieldTypeNotes
functionV1Function
versionV1FunctionVersion
deployV1Deploy

V1Function

FieldTypeNotes
idstring (uuid)
namestringe.g. send-receipt
urlstringe.g. https://shop-fn.naijacloud.app/functions/v1/send-receipt
statusDEPLOYING, LIVE, SLEEPING, FAILED, ERRORING, STOPPED
statusDetailstring, or null
regionstring, or nulle.g. eu-west
tierFREE, PRO, PRO_PLUS, STANDARD, STARTER
runtimeServiceIdstring (uuid), or nullThe hidden web service every function in the environment runs in.
environmentIdstring (uuid)
liveVersionV1FunctionVersion, or null
latestVersionV1FunctionVersion, or null
calls24hnumber, or null
errors24hnumber, or null
limitsV1FunctionLimits
createdAtstring (date-time)
updatedAtstring (date-time)

V1FunctionLimits

FieldTypeNotes
memoryMbnumber
maxDurationSecondsnumberLongest one call may run before a 504.
maxCodeBytesnumberLargest upload per deploy, in bytes.

V1FunctionVersion

FieldTypeNotes
idstring (uuid)
numbernumberFrom 1, per function.
statusDEPLOYING, LIVE, REPLACED, FAILED
sizeBytesnumber
entrypointstringe.g. index.ts
commandstring, or null
deployedByNamestring, or null
deployIdstring (uuid), or nullThe runtime deploy carrying it; its logs are the build log.
errorMessagestring, or null
createdAtstring (date-time)

V1StaticUpload

FieldTypeNotes
uploadIdstring (uuid)
urlstringA presigned URL; it expires.
methodstringe.g. PUT
headersarray of V1UploadHeader
maxBytesnumber
expiresInSecondsnumber

V1UploadHeader

FieldTypeNotes
namestring
valuestring