Hosting API

Hosting API provides endpoints for listing and deployment of websites. API can be used to implement CI/CDopen in new window. To deploy page through Apillon API, follow below steps:

  1. Upload website files to Apillon cloud server.
  • Request URLs for files upload
  • Upload files to cloud server
  • Trigger transfer into website
  1. Execute deployment to staging or production environment.

Note: You should first create a website on the Apillon dashboardopen in new window.

In all cURL examples, parameters with a colon as a prefix should be replaced with real values.

List websites

API to list all websites in project. Items are paginated and can be filtered and ordered through query parameters as described here .

GET /hosting/websites

Response fields (website)

Each item is an instance of website class, with below properties:

FieldTypeDescription
websiteUuidstringWebsite unique identifier
namestringWebsite name
descriptionstringWebsite description
domainstringWebsite domain. This property needs to be specified, so that Apillon is able to create SSL Certificates for IPFS gateway
bucketUuidstringUuid of bucket for file upload
ipnsStagingstringStaging IPNS. Set if deployment to staging environment exists
ipnsProductionstringProduction IPNS.
createTimeDateTimeItem create time
updateTimeDateTimeItem last update time

curl --location --request GET "https://api.apillon.io/hosting/websites" \
--header "Authorization: Basic :credentials"
curl --location --request GET "https://api.apillon.io/storage/buckets?search=My website" \
--header "Authorization: Basic :credentials"
{
    "id": "75095bf9-e976-45c8-8a9d-e013ca3b203a",
    "status": 200,
    "data": {
        "items": [
            ...
            {
                "createTime": "2023-10-11T10:51:13.000Z",
                "updateTime": "2023-10-11T10:51:13.000Z",
                "websiteUuid": "5fc7df41-f311-410d-8cb3-998198999a48",
                "name": "My website",
                "description": null,
                "domain": null,
                "bucketUuid": "1938a45c-3a54-43ee-af08-3abe90265f46",
                "ipnsStaging": null,
                "ipnsProduction": null
            }
            ...
        ],
        "total": 10
    }
}

Get website

Endpoint to get website. Endpoint returns basic website data, along with IPNS links.

GET /hosting/websites/:websiteUuid

URL parameters

NameDescriptionRequired
websiteUuidWebsite UUID, visible in developer console website overviewtrue

Possible errors

CodeDescription
40406010Website does not exists

Response fields

Response is an instance of website class, described above and additional properties described below. Those properties will receive value after deploy.

FieldTypeDescription
w3StagingLinkstringLink to staging version of the website
w3ProductionLinkstringLink to production version of the website
lastDeploymentUuidstringWebsite last deployment (to any environment) unique identifier
lastDeploymentStatusstringStatus of last deployment

curl --location --request GET "https://api.apillon.io/hosting/websites/:websiteUuid" \
--header "Authorization: Basic :credentials"
{
  "id": "a299ed8f-b682-4411-9fd9-eb3a3da31887",
  "status": 200,
  "data": {
    "createTime": "2023-10-13T07:41:30.000Z",
    "updateTime": "2023-10-13T07:41:30.000Z",
    "websiteUuid": "1a15d258-bbc9-459f-b83f-97710da6b983",
    "name": "My awesome website",
    "description": "My unstoppable website",
    "domain": "example-domain.io",
    "bucketUuid": "cd299839-dae6-47d0-8fdc-40143163e156",
    "ipnsStaging": null,
    "ipnsProduction": null,
    "w3StagingLink": null,
    "w3ProductionLink": null,
    "lastDeploymentUuid": null,
    "lastDeploymentStatus": null
  }
}

Get URLs for files upload

API that creates file upload requests and returns URLs for files upload.

POST /hosting/websites/:websiteUuid/upload

URL parameters

NameDescriptionRequired
websiteUuidUnique key of website bucket. Key is displayed on developer dashboard.true

Body fields

NameTypeDescriptionRequired
filesarrayArray of files metadata.true
sessionUuidstringSession unique key. If not specified, API generates new one. It is possible to use same sessionUuid in multiple requests.false

Each file metadata object in files array, contain below properties.

NameTypeDescriptionRequired
fileNamestringFull name (name and extension) of file to be uploadedtrue
contentTypestringFile MIME typeopen in new windowfalse
pathstringFile path inside website. Empty for root. Must not contain fileName.false

Possible errors

CodeDescription
40406010Website does not exists
42200040Request body is missing a files field.
42200008Request body file object is missing a fileName field.
50006003Internal error - Apillon was unable to generate upload URL.

Response

NameTypeDescription
sessionUuidstringSession unique key, which is later used to end upload and transfer files to website.
filesarrayArray of files metadata.

Files in request body are returned in response data.files property. Each file is equipped with url and fileUuid. All properties are displayed below.

FieldTypeDescription
urlstringURL for file upload. Signed URL is unique for each file and is valid only for a limited time (1 min), so you should start with file upload as soon as possible.

Request should use PUT method and binary body.

Binary data should be sent in body as-is, but with the appropriate Content-Type header (e.g., text/plain).
fileUuidstringFile unique identifier used to query file status, etc.
fileNamestringFull name (name and extension) of file to be uploaded
contentTypestringFile MIME typeopen in new window
pathstringFile path on the hosting bucket.

curl --location --request POST "https://api.apillon.io/hosting/websites/:websiteUuid/upload" \
--header "Authorization: Basic :credentials" \
--header "Content-Type: application/json" \
--data-raw "{
    \"files\": [
        {
            \"fileName\": \"index.html\",
            \"contentType\": \"text/html\"
        },
        {
            \"fileName\": \"styles.css\",
            \"contentType\": \"text/css\",
            \"path\": \"assets/\"
        }

    ]

}"
{
  "id": "7dd011ec-20e2-4c28-b585-da6c6f7fce8d",
  "status": 201,
  "data": {
    "sessionUuid": "29ef6ca2-b171-440c-b934-db8aa88c3424",
    "files": [
      {
        "path": null,
        "fileName": "index.html",
        "contentType": "text/html",
        "url": "https://sync-to-ipfs-queue.s3.eu-west-1.amazonaws.com/HOSTING_sessions/70/29ef6ca2-b171-440c-b934-db8aa88c3424/index.html?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQIMRRA6GJRL57L7G%2F20230215%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20230215T105030Z&X-Amz-Expires=900&X-Amz-Signature=187035d2307bc089101eff3abbdd7baa3e8691b4d5d3bafa5aebb87e589e8c0c&X-Amz-SignedHeaders=host&x-id=PutObject",
        "fileUuid": "e17436a1-5292-4380-ad91-eaac02a862b1"
      },
      {
        "path": "assets/",
        "fileName": "styles.css",
        "contentType": "text/css",
        "url": "https://sync-to-ipfs-queue.s3.eu-west-1.amazonaws.com/HOSTING_sessions/70/29ef6ca2-b171-440c-b934-db8aa88c3424/assets/styles.css?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQIMRRA6GJRL57L7G%2F20230215%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20230215T105030Z&X-Amz-Expires=900&X-Amz-Signature=f91b03a951fe3f99291802306be3e79812ca64e39effbb7dea1c19bb7cd1e42b&X-Amz-SignedHeaders=host&x-id=PutObject",
        "fileUuid": "358c2942-4ced-421e-9a6f-edbf94c55dff"
      }
    ]
  }
}

Example for uploading to signed URL:

curl --location --request PUT "https://sync-to-ipfs-queue.s3.eu-west-1.amazonaws.com/HOSTING_sessions/70/29ef6ca2-b171-440c-b934-db8aa88c3424/index.html?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQIMRRA6GJRL57L7G%2F20230215%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20230215T105030Z&X-Amz-Expires=900&X-Amz-Signature=187035d2307bc089101eff3abbdd7baa3e8691b4d5d3bafa5aebb87e589e8c0c&X-Amz-SignedHeaders=host&x-id=PutObject" \
--header "Content-Type: text/plain" \
--data-raw "<h1>
Welcome to my awesome website
</h1>"
curl --location --request PUT "https://sync-to-ipfs-queue.s3.eu-west-1.amazonaws.com/HOSTING_sessions/70/29ef6ca2-b171-440c-b934-db8aa88c3424/index.html?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQIMRRA6GJRL57L7G%2F20230215%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20230215T105030Z&X-Amz-Expires=900&X-Amz-Signature=187035d2307bc089101eff3abbdd7baa3e8691b4d5d3bafa5aebb87e589e8c0c&X-Amz-SignedHeaders=host&x-id=PutObject" \
--header "Content-Type: text/plain" \
--data-binary ":full path to file"

End upload session

Transfer files to website bucket, which is used as source for deploy to staging(preview) environment.

POST /hosting/websites/:websiteUuid/upload/:sessionUuid/end

URL parameters

NameDescriptionRequired
websiteUuidUnique key of website.true
sessionUuidSession uuid, passed or recieved in get URL for upload requesttrue

Possible errors

CodeDescription
40406004Session does not exists
40006001Files in this session were already transferred

Response

Api respond with status 200 OK , if operation is successfully executed.


curl --location --request POST "https://api.apillon.io/hosting/websites/:websiteUuid/upload/:sessionUuid/end" \
--header "Authorization: Basic :credentials" \
--header "Content-Type: application/json" \
{
  "id": "b64b1c07-1a8a-4b05-9e3b-3c6a519d6ff7",
  "status": 200,
  "data": true
}

Deploy website

Endpoint to trigger website deployment into specific environment.

POST /hosting/websites/:websiteUuid/deploy

URL parameters

NameDescriptionRequired
websiteUuidWebsite UUID, visible in developer console website overviewtrue

Body fields

NameTypeDescriptionRequired
environmentnumberPossible environment values are explained belowtrue
Environments
StatusDescription
1Uploaded files are deployed to staging(preview) environment. Website will be available through staging IPNS link
2Files from current staging environment are deployed to production environment. Website is pinned to CRUST, replicated and available through production IPNS link
3Same as 2, only that the source are uploaded files, not files in staging environment.

Possible errors

CodeDescription
42200039Request body is missing an environment field.
40406010Website does not exists
40006016There are no files to deploy.
40006017There are no changes to deploy.

Response

Endpoint triggers deployment of website to specific environment. As result, deployment record with below field is returned. This deployment is now waiting to be processed.

Note: Deployment is processed in background, which may take several minutes. When deploying to staging environment, files are added to IPFS and wrapped to directory, which is then accessible in IPFS via IPNS or CID. In production, this CID is pinned to CRUST and replicated to other nodes.

Deployment fields
FieldTypeDescription
deploymentUuidstringDeployment unique identifier
environmentnumberEnvironment to where website will be deployed
deploymentStatusnumberCurrent status of deployment. Possible values are listed below.
cidstringWhen deployment is successful, CID points to directory on IPFS, where this page is accessible
cidv1stringCID version 1
sizenumberSize of website
numbernumberDeployment serial number - for this environment
createTimeDateTimeDeployment create time
updateTimeDateTimeDeployment last update time
Website deployment statuses

Deployment goes through different stages and each stage updates deploymentStatus. Possible deployment statuses:

StatusDescription
0Deployment initiated
1In processing
2In review
3Website approved. Deployment will be executed
10Deployment successful
100Deployment failed
101Deployment rejected

Deployments (to environments 1 and 3) in projects without subscription go to review (deploymentStatus 3). Review can take some time (up to 1 day) and if the website passes it, then the deployment continues.

Websites with illegal/phishing content goes to status 101. The project owner is notified via mail and most likely banned from Apillon platform.

To speed up deployment process, make sure that project has one of subscription packages.


curl --location --request POST "https://api.apillon.io/hosting/websites/:websiteUuid/deploy" \
--header "Authorization: Basic :credentials" \
--header "Content-Type: application/json" \
--data-raw "{
    \"environment\": 1
}"
{
  "id": "dfe79ed9-e2fe-4195-b829-053dee1e6fd1",
  "status": 200,
  "data": {
    "createTime": "2023-10-13T12:23:51.721Z",
    "updateTime": "2023-10-13T12:23:51.721Z",
    "deploymentUuid": "583790dc-7b56-4563-8a33-d88243eed11e",
    "environment": 1,
    "deploymentStatus": 0,
    "cid": null,
    "cidv1": null,
    "size": null,
    "number": 1
  }
}

List website deployments

API to list website deployments. More about listing requests can be found here

GET /hosting/websites/:websiteUuid/deployments

URL parameters

NameDescriptionRequired
deploymentStatusCurrent deployment statusfalse
environmentDeployment environmentfalse

Response fields

Each item in list is a deployment instance.


curl --location --request GET "https://api.apillon.io/hosting/websites/:websiteUuid/deployments" \
--header "Authorization: Basic :credentials"
curl --location --request GET "https://api.apillon.io/hosting/websites/:websiteUuid/deployments?orderBy=number" \
--header "Authorization: Basic :credentials"
{
    "id": "75095bf9-e976-45c8-8a9d-e013ca3b203a",
    "status": 200,
    "data": {
        "items": [
            ...
            {
                "createTime": "2023-10-13T12:28:39.000Z",
                "updateTime": "2023-10-13T12:29:15.000Z",
                "deploymentUuid": "12b47aef-6a01-4799-a4da-79ea7595237d",
                "environment": 2,
                "deploymentStatus": 10,
                "cid": "QmTF31ediusaBTNn2Z1Jtr5fF1iVp9oDA8EWz9my6aVx8V",
                "cidv1": "bafybeici3ivncsgfszf7tbmttayyjk6hs25354zs5nczujv44rco4qiv7y",
                "size": 41,
                "number": 1
            },
            {
                "createTime": "2023-10-13T12:23:51.000Z",
                "updateTime": "2023-10-13T12:24:17.000Z",
                "deploymentUuid": "583790dc-7b56-4563-8a33-d88243eed11e",
                "environment": 1,
                "deploymentStatus": 10,
                "cid": "QmTF31ediusaBTNn2Z1Jtr5fF1iVp9oDA8EWz9my6aVx8V",
                "cidv1": "bafybeici3ivncsgfszf7tbmttayyjk6hs25354zs5nczujv44rco4qiv7y",
                "size": 41,
                "number": 1
            }
            ...
        ],
        "total": 10
    }
}

Get deployment

Endpoint to get deployment.

GET /hosting/websites/:websiteUuid/deployments/:deployment_uuid

URL parameters

NameDescriptionRequired
websiteUuidWebsite UUID, visible in developer console website overviewtrue
deploymentUuidDeployment unique identifier, returned from deploy website endpointtrue

Possible errors

CodeDescription
40406011Deployment does not exists

Response fields

Data property is a deployment instance.


curl --location --request GET "https://api.apillon.io/hosting/websites/:websiteUuid/deployments/:deploymentUuid" \
--header "Authorization: Basic :credentials"
{
  "id": "2d7d1b0c-15b1-4816-9aec-857182c7b617",
  "status": 200,
  "data": {
    "createTime": "2023-10-13T12:23:51.000Z",
    "updateTime": "2023-10-13T12:24:17.000Z",
    "deploymentUuid": "583790dc-7b56-4563-8a33-d88243eed11e",
    "environment": 1,
    "deploymentStatus": 10,
    "cid": "QmTF31ediusaBTNn2Z1Jtr5fF1iVp9oDA8EWz9my6aVx8V",
    "cidv1": "bafybeici3ivncsgfszf7tbmttayyjk6hs25354zs5nczujv44rco4qiv7y",
    "size": 41,
    "number": 1
  }
}