scripts
Paperspace Core API reference guide for scripts
.
Creates a new startup script. Optionally specify a machine to use this startup script. For Linux machines, the script should be a bash script. For Windows machines, the script should be a PowerShell script. See the samples directory for sample startup scripts for Windows. Note: script data is limited to 16KB per script. See the Script Guide for more info on using scripts.
Paperspace can run a script automatically on the startup of a paperspace virtual machine. This feature is similar to user_data
in other cloud provider frameworks.
The running of scripts automatically can be a path for malware to get access to your machine. Make sure your account and paperspace apiKey are kept secure, and review your scripts closely to make sure the software you are running is safe. Paperspace supports two-factor authentication for securing your paperspace account info. This can add an extra level of security to your account to help keep your apiKeys, scripts, and script assignments secure.
Paperspace stores scripts within a secure area associated with your account, and encrypts and protects scripts while they are being downloaded to machines during startup. Scripts cannot be modified once uploaded to paperspace, however a new script can be defined and assigned to a machine using your apiKey. Hence the importance of keeping your apiKey and account secure.
create
Examples
- CLI
- curl
- Node
- Go
paperspace scripts create \
--apiKey "edc20a51d9b2145..." \
--scriptName "My Script" \
--scriptText "services start nginx"
curl -X POST 'https://api.paperspace.io/scripts/createScript' \
-H 'X-Api-Key: edc20a51d9b2145...' \
-H 'Content-Type: application/json' \
--data-raw '{
"scriptName": "My Script",
"scriptText": "services start nginx"
}'
paperspace.scripts.create(
{
scriptName: "My Script",
scriptText: "services start nginx",
},
function (err, res) {
// handle error or result
}
);
Coming soon...
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
scriptName | string | A unique name for the script | |
scriptFile | string | optional | File path to a file containing the script data; either scriptFile or scriptText must be provide. |
scriptText | string | optional | A string containing the script text; either scriptFile or scriptText must be provide. |
scriptDescription | string | optional | Description of the script |
isEnabled | boolean | optional | Determines if the script is enabled or not. Defaults to true |
runOnce | boolean | optional | Determines if the script is run on first boot or every boot. Defaults to false |
machineId | string | optional | Machine id of a machine that should execute this script at startup |
Response
Type object
{
"id": "sckro9u2p",
"ownerType": "team",
"ownerId": "tewr3st2z",
"name": "My Script",
"description": null,
"dtCreated": "2022-03-14T19:44:47.542Z",
"isEnabled": true,
"runOnce": false
}
destroy
Destroys the startup script with the given id. When this action is performed, the script is immediately disassociated from any machines it is assigned to as well.
Examples
- CLI
- curl
- Node
- Go
paperspace scripts destroy \
--apiKey "edc20a51d9b2145..." \
--scriptId "sckro9u2p"
curl -X POST 'https://api.paperspace.io/scripts/sckro9u2p/destroy' \
-H 'X-Api-Key: edc20a51d9b2145...'
paperspace.scripts.destroy(
{
scriptId: "sckro9u2p",
},
function (err, res) {
// handle error or result
}
);
Coming soon...
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
scriptId | string | required | The id of the script to destroy |
list
List information about all scripts assigned to either the current authenticated user or the team, if the user belongs to a team. The list method takes an optional first argument to limit the returned script objects.
Examples
- CLI
- curl
- Node
- Go
paperspace scripts list \
--apiKey "edc20a51d9b2145..."
curl -X GET 'https://api.paperspace.io/scripts/getScripts' \
-H 'X-Api-Key: edc20a51d9b2145...'
paperspace.scripts.list(function (err, res) {
// handle error or result
});
Coming soon...
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
id | string | optional | Optional script id to match on |
ownerType | string | optional | Optional ownerType to match on, either 'user' or 'team' |
ownerId | string | optional | Optional ownerId to match on, either a userId or teamId |
name | string | optional | Optional name to match on |
description | string | optional | Optional description to match on |
dtCreated | string | optional | Optional datetime created value to match on |
isEnabled | boolean | optional | Optional isEnabled value to match on, either true or false |
runOnce | boolean | optional | Optional runOnce value to match on, either true or false |
Response
Type array
[
{
"id": "scv4447ig",
"ownerType": "team",
"ownerId": "tewr3st2z",
"name": "My Script",
"description": "A startup script",
"dtCreated": "2022-03-14T19:41:54.025Z",
"isEnabled": true,
"runOnce": false
},
{
"id": "scf2rb8aj",
"ownerType": "team",
"ownerId": "tewr3st2z",
"name": "My Script",
"description": null,
"dtCreated": "2022-03-14T19:42:52.876Z",
"isEnabled": true,
"runOnce": false
},
{
"id": "scodg97l0",
"ownerType": "team",
"ownerId": "tewr3st2z",
"name": "My Script",
"description": null,
"dtCreated": "2022-03-14T19:45:58.277Z",
"isEnabled": true,
"runOnce": false
}
]
show
Show information for the script with the given id, except for the script text. Use the scripts text method retrieve the script text.
Examples
- CLI
- curl
- Node
- Go
paperspace scripts show \
--apiKey "edc20a51d9b2145..." \
--scriptId "sc7ir6fkx"
curl -X GET 'https://api.paperspace.io/scripts/getScript?scriptId=sc7ir6fkx' \
-H 'X-Api-Key: edc20a51d9b2145...'
paperspace.scripts.show(
{
scriptId: "sc7ir6fkx",
},
function (err, res) {
// handle error or result
}
);
Coming soon...
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
scriptId | string | required | Id of the script to show |
Response
Type object
{
"id": "sc7ir6fkx",
"ownerType": "team",
"ownerId": "tewr3st2z",
"name": "My Script",
"description": null,
"dtCreated": "2022-03-14T20:00:37.722Z",
"isEnabled": true,
"runOnce": false,
"machines": []
}
text
Gets the text of the script with the given id.
Examples
- CLI
- curl
- Node
- Go
paperspace scripts text \
--apiKey "edc20a51d9b2145..." \
--scriptId "sc7ir6fkx"
curl -X GET 'https://api.paperspace.io/scripts/getScriptText?scriptId=sc7ir6fkx' \
-H 'X-Api-Key: edc20a51d9b2145...'
paperspace.scripts.text(
{
scriptId: "sc7ir6fkx",
},
function (err, res) {
// handle error or result
}
);
Coming soon...
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
scriptId | string | required | Id of the script to get the text for |
Response
Type string
"services start nginx"