Start an application only when it is off
startApplication throws a 500 when the application is already running, so check first.
Create an application and wait until it is ready
A new application iscreating for a while, and actions on it are refused until it is active. Poll with getApplication, and keep the pause longer than the 3 seconds the API needs between requests.
The
data of an Application is never refreshed, so call getApplication again on every attempt, as above.Change one setting and apply it
updateApplication always needs appName, memoryMB, runtimeEnvironment and, by its type, startupCommand. Read the current values from data and send them back with the one you want to change.
Deploy a new version of the code
Zip your project, send it to the root of the application and restart. Always passpath.
start instead of restart.
Save a copy before you change something
node_modules, .npm, .git, .cache and .bun. The API accepts 20 downloads per minute.
List every application
getApplications returns only the first 10 personal applications. To go through all of them, call the API with the page and limit parameters:
team: "YOUR_TEAM_ID" to params to list the applications of a team. axios is already installed with the SDK.
Find out why an application is offline
The SDK types do not include thesuspension and shutdownNotice fields, but the API returns them, so read them with a cast:
Retry when the API answers 429
The SDK never retries. A429 means the request was refused, so waiting and sending it again is safe.