Cloud Functions API

The Cloud Function API provides an interface for developers to deploy, manage, and execute decentralized cloud functions on the Apillon platform. These endpoints allow you to create cloud functions, manage jobs, and configure runtime environments.

Create Cloud Function

Create a new cloud function to be executed on decentralized processors.

POST /cloud-functions

Body Fields

FieldTypeDescriptionRequired
namestringName of the cloud functionYes
descriptionstringDescription of the cloud functionNo

Possible Errors

CodeDescription
42200212Missing required fields
42200205Name not valid
42200206Description not valid
50000001Internal server error

curl --location --request POST "https://api.apillon.io/cloud-functions" \
--header "Authorization: Basic :credentials" \
--header "Content-Type: application/json" \
--data-raw "{
    \"name\": \"My Cloud Function\",
    \"description\": \"Handles automated tasks\"
}"
{
  "status": 201,
  "data": {
    "createTime": "2024-09-12T13:32:26.706Z",
    "updateTime": null,
    "functionUuid": "90c37572-571e-4d8c-a906-7275e8e3cd8e",
    "projectUuid": "d0c34b5e-1fd6-473e-81f8-e89ee479f7aa",
    "bucketUuid": "1a100c47-56cc-4550-a969-6631bfb1c37b",
    "name": "My Cloud Function",
    "description": "Handles automated tasks",
    "activeJobId": null
  }
}

List Cloud Functions

Retrieve a list of cloud functions associated with a project.

GET /cloud-functions

Query Parameters

All query parameters from listing request

Response Fields

FieldTypeDescription
functionUuuidstringUnique identifier of the cloud function
projectUuidstringUUID of the project the cloud function belongs to
bucketUuidstringUUID of the bucket which script files are uploaded into
namestringName of the cloud function
descriptionstringDescription of the cloud function
activeJobIdnumberThe ID of the currently active job on the cloud function
project_uuidstringUnique identifier of the project
createTimeDateTimeCreation timestamp
updateTimeDateTimeLast updated timestamp

curl --location --request GET "https://api.apillon.io/cloud-functions?project_uuid=abc123-project" \
--header "Authorization: Basic :credentials"
{
  "status": 200,
  "data": {
    "items": [
      {
        "createTime": "2024-09-09T11:15:26.000Z",
        "updateTime": "2024-09-10T13:18:31.000Z",
        "functionUuid": "cfd85992-8f79-4486-97cf-2406bd722d90",
        "projectUuid": "d0c34b5e-1fd6-473e-81f8-e89ee479f7aa",
        "bucketUuid": "e85fa5ce-8c37-42fc-bf54-a578b0fd2d1f",
        "name": "My Cloud Function",
        "description": "Handles automated tasks",
        "activeJobId": 77
      }
    ],
    "total": 1,
    "page": 1,
    "limit": 20
  }
}

Get Cloud Function

Get the details of a specific cloud function by its UUID.

GET /cloud-functions/:function_uuid

URL Parameters

FieldTypeDescriptionRequired
function_uuidstringUnique identifier of the cloud functionYes

Response Fields

FieldTypeDescription
functionUuuidstringUnique identifier of the cloud function
projectUuidstringUUID of the project the cloud function belongs to
bucketUuidstringUUID of the bucket which script files are uploaded into
namestringName of the cloud function
descriptionstringDescription of the cloud function
activeJobIdnumberThe ID of the currently active job on the cloud function
project_uuidstringUnique identifier of the project
gatewayUrlstringAPI gateway endpoint URL of the cloud function
createTimeDateTimeCreation timestamp
updateTimeDateTimeLast updated timestamp
job.scriptCIdstringIPFS CID of the script file the job is running
job.slotsstringNumber of processors running the job
job.jobStatusstringThe current status of the job. Possible values: 1 (deploying), 2 (deployed), 3 (matched), 4 (inactive), 9 (deleted)

Possible Errors

CodeDescription
40300000Forbidden
40418005Cloud function not found

curl --location --request GET "https://api.apillon.io/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6" \
--header "Authorization: Basic :credentials"
{
    "id": "60020364-7edc-495a-a0a2-df695bb1cc3f",
    "status": 200,
    "data": {
      "createTime": "2024-09-09T11:15:26.000Z",
      "updateTime": "2024-09-10T13:18:31.000Z",
      "functionUuid": "cfd85992-8f79-4486-97cf-2406bd722d90",
      "projectUuid": "d0c34b5e-1fd6-473e-81f8-e89ee479f7aa",
      "bucketUuid": "e85fa5ce-8c37-42fc-bf54-a578b0fd2d1f",
      "name": "Env CF",
      "description": null,
      "activeJobId": 77,
      "gatewayUrl": "https://cfd85992-8f79-4486-97cf-2406bd722d90.gw.web3approved.com",
      "jobs": [
        {
          "id": 77,
          "createTime": "2024-09-10T12:55:44.000Z",
          "updateTime": "2024-09-12T13:57:26.000Z",
          "jobUuid": "2ead7ed9-125f-436d-9a09-5e8e95206791",
          "projectUuid": "d0c34b5e-1fd6-473e-81f8-e89ee479f7aa",
          "functionUuid": "cfd85992-8f79-4486-97cf-2406bd722d90",
          "scriptCid": "QmUq4iFLKZUpEsHCAqfsBermXHRnPuE5CNcyPv1xaNkyGp",
          "slots": 1,
          "jobStatus": 3
        }
      ]
    }
}

Create Cloud Function Job (Deployment)

Create a job/deployment for a specific cloud function.

POST /cloud-functions/:function_uuid/jobs

WARNING

The deployed code should be made on top of this Node.js template: https://github.com/Apillon/cloud-function-templateopen in new window If it does not contain the boilerplate code, the deployment will not be accessible via the provided API gateway URL.

URL Parameters

FieldTypeDescriptionRequired
function_uuidstringUnique identifier of the cloud functionYes

Body Fields

FieldTypeDescriptionRequired
namestringName of the jobYes
scriptCidstringIPFS CID of the script to deployYes
slotsnumberNumber of processors to deploy to (default 1)No

Possible Errors

CodeDescription
40300000Forbidden
42200212Missing required field
42200213Invalid field data
40418005Cloud function not found
50018013Error creating job

curl --location --request POST "https://api.apillon.io/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6/jobs" \
--header "Authorization: Basic :credentials" \
--header "Content-Type: application/json" \
--data-raw "{
    \"name\": \"Price fetcher\",
    \"scriptCid\": \"QmYwAPJzv5CZsnAzt8JCRdjD7...",
    \"slots\": 3
}"
{
    "id": "c7059955-688a-406d-8a61-9be3e931250c",
    "status": 201,
    "data": {
      "id": 79,
      "createTime": "2024-09-13T08:58:24.740Z",
      "updateTime": null,
      "jobUuid": "21a54e84-4daf-4c0e-98ed-fdcc859d1a1a",
      "projectUuid": "d0c34b5e-1fd6-473e-81f8-e89ee479f7aa",
      "functionUuid": "cfd85992-8f79-4486-97cf-2406bd722d90",
      "scriptCid": "QmYwAPJzv5CZsnAzt8JCRdjD7...",
      "slots": 3,
      "jobStatus": 1
    }
}

Set Cloud Function Environment Variables

Set the environment variables for a specific cloud function.

POST /cloud-functions/:function_uuid/environment

URL Parameters

FieldTypeDescriptionRequired
function_uuidstringUnique identifier of the cloud functionYes

Body Fields

FieldTypeDescriptionRequired
variablesarrayArray of key-value pairs for environment variablesYes

Possible Errors

CodeDescription
42218016Missing or invalid variables field
40418005Cloud function not found

curl --location --request POST "https://api.apillon.io/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6/environment" \
--header "Authorization: Basic :credentials" \
--header "Content-Type: application/json" \
--data-raw "{
    \"variables\": [{ \"key\": \"API_KEY\", \"value\": \"12345\" }]
}"
{
  "status": 200,
  "data": {
    "function_uuid": "d1e8b9f2-4d18-4ef7-9f59-87348590d5a6",
    "variables": [
      { "key": "API_KEY", "value": "12345" }
    ]
  }
}

Delete Job

Delete a specific job using its unique identifier.

DELETE /cloud-functions/jobs/:job_uuid

URL Parameters

FieldTypeDescriptionRequired
job_uuidstringUnique identifier of the jobYes

Possible Errors

CodeDescription
40418004Job not found
50018014Job not yet deployed
50018016Error deleting job

curl --location --request DELETE "https://api.apillon.io/cloud-functions/jobs/e3c86bb2-4190-4bda-9c8a-3852b6d04971" \
--header "Authorization: Basic :credentials"
{
  "status": 200,
  "message": "Job successfully deleted"
}