Skip to main content

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.

info

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

paperspace scripts create \
--apiKey "edc20a51d9b2145..." \
--scriptName "My Script" \
--scriptText "services start nginx"

Parameters

NameTypeAttributesDescription
scriptNamestringA unique name for the script
scriptFilestringoptionalFile path to a file containing the script data; either scriptFile or scriptText must be provide.
scriptTextstringoptionalA string containing the script text; either scriptFile or scriptText must be provide.
scriptDescriptionstringoptionalDescription of the script
isEnabledbooleanoptionalDetermines if the script is enabled or not. Defaults to true
runOncebooleanoptionalDetermines if the script is run on first boot or every boot. Defaults to false
machineIdstringoptionalMachine 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

paperspace scripts destroy \
--apiKey "edc20a51d9b2145..." \
--scriptId "sckro9u2p"

Parameters

NameTypeAttributesDescription
scriptIdstringrequiredThe 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

paperspace scripts list \
--apiKey "edc20a51d9b2145..."

Parameters

NameTypeAttributesDescription
idstringoptionalOptional script id to match on
ownerTypestringoptionalOptional ownerType to match on, either 'user' or 'team'
ownerIdstringoptionalOptional ownerId to match on, either a userId or teamId
namestringoptionalOptional name to match on
descriptionstringoptionalOptional description to match on
dtCreatedstringoptionalOptional datetime created value to match on
isEnabledbooleanoptionalOptional isEnabled value to match on, either true or false
runOncebooleanoptionalOptional 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

paperspace scripts show \
--apiKey "edc20a51d9b2145..." \
--scriptId "sc7ir6fkx"

Parameters

NameTypeAttributesDescription
scriptIdstringrequiredId 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

paperspace scripts text \
--apiKey "edc20a51d9b2145..." \
--scriptId "sc7ir6fkx"

Parameters

NameTypeAttributesDescription
scriptIdstringrequiredId of the script to get the text for

Response

Type string

"services start nginx"