CamposCloudSDK is the entry point of the SDK. Every method is asynchronous and performs exactly one request to https://api.camposcloud.com/v1/.
Constructor
Your CamposCloud API Key. See Authentication.
Error("API Token is required to initialize CamposCloudSDK.") when apiToken is empty. The base URL is fixed and no request timeout is configured.
Methods validate some of their arguments before sending the request and throw a plain
Error when they are invalid. Errors returned by the API are thrown as Axios errors. See Errors and pitfalls.Account
getMe
GET /v1/users/@me). The SDK unwraps the user object of the API response.
UserData
Applications
getApplications
GET /v1/apps).
totalUsedRAM is declared as string in the SDK types, but the API returns a number (megabytes).getApplication
GET /v1/apps/{appId}) and wraps it in an Application instance.
Application. The raw API response is in app.data.
Throws: Error("Application ID (appId) must be a valid string.") when appId is empty or not a string.
createApplication
POST /v1/apps/create) and returns it as an Application instance.
The application source as a
.zip file. It is always sent to the API with the file name file.zip.Runtime of the application. The API also accepts
"bun", but the SDK type does not include it (see pitfalls).Custom command used to start the application. When omitted, the API uses the default of the runtime.
Expose the application to the web. Do not set it to
true: the API then requires port and assignedSubdomain, which the SDK cannot send, so the request fails with 400.Application
Throws: a plain Error before sending the request when file, appName, mainFile or runtimeEnvironment is missing, when memoryMB is missing or not a number, or when an environment variable has a key or value that is not a string.
updateApplication
POST /v1/apps/{appId}/update).
Command used to start the application. It is required by the TypeScript type; at runtime it is only sent when it is not empty.
Expose the application to the web. Only
false is useful here: true makes the API require port, which the SDK cannot send.Replaces all environment variables. Omit it to keep the current ones; pass
[] to remove all of them.ApplicationResponseData with the updated application (not an Application instance).
Throws: a plain Error before sending the request when appId, appName or runtimeEnvironment is missing, when memoryMB is missing or not a number, or when an environment variable has a key or value that is not a string.
Even though the API can update a single field, the SDK always requires and sends
appName, memoryMB and runtimeEnvironment. Most changes only take effect after the application is started or restarted; check restartRequired in the result.startApplication
POST /v1/apps/{appId}/start).
ApplicationResponseData
stopApplication
POST /v1/apps/{appId}/stop).
ApplicationResponseData
restartApplication
POST /v1/apps/{appId}/restart). If the application has pending settings (restartRequired), it is rebuilt with them.
ApplicationResponseData
deleteApplication
DELETE /v1/apps/{appId}/delete). This cannot be undone.
response.data.
startApplication, stopApplication, restartApplication and deleteApplication throw Error("Application ID (appId) must be a valid string.") when appId is empty or not a string.
Files
uploadFile
POST /v1/apps/{appId}/upload).
A
.zip file. The API only accepts zip files and extracts them into path. To upload a single file, put it in a zip first.Directory of the application where the zip is extracted, for example
/ or /src. Optional in the signature, but always pass it (see the warning below).{ message: string }. The AxiosError in the declared return type is never actually returned: failures are thrown.
Throws: a plain Error when appId is not a string, when path is not a string, or when file is not a Buffer.
The SDK cannot send the
restart query parameter of the API, so the application is not restarted after the upload. Call restartApplication if you need it. The API accepts 1 upload every 3 seconds.downloadFile
GET /v1/apps/{appId}/download).
Buffer with a zip archive. The API always answers with a zip, even when path points to a single file, so unzip the result to get the file.
Throws: a plain Error when appId is not a string or when path is not a string.
As in
uploadFile, path is not URL encoded by the SDK. The API accepts 20 downloads per minute and does not include node_modules, .npm, .git, .cache and .bun folders in the archive.Teams
getTeams
GET /v1/teams). Teams you own come first.
TeamResponseData[]
getTeam
GET /v1/teams/{teamId}).
TeamResponseData. The API does not return applicationsCount for a single team, so that property is undefined here even though the type declares it.
Throws: Error("Team ID (teamId) must be a valid string.") when teamId is empty or not a string.
The SDK has no method to list the applications of a team, nor to create, rename or delete teams or manage their members and invites. Use the Teams endpoints of the API for that.