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.

Create

Examples
1
paperspace.scripts.create({
2
scriptName: 'My Script',
3
scriptFile: './my_script_file.sh', // must specify either scriptFile or scriptText
4
scriptDescription: 'A startup script', // optional
5
isEnabled: true, // optional
6
runOnce: false, // optional
7
machineId: 'ps123abc', // optional
8
}, function(err, res) {
9
// handle error or result
10
});
Copied!
1
# HTTP request:
2
https://api.paperspace.io
3
POST /scripts/createScript {"scriptName": "My Script", "scriptDescription": "A startup script", "isEnabled": true, "runOnce": false, "machineId": "ps123abc"}
4
x-api-key: 1ba4f98e7c0...
5
(file contents as multipart form data)
6
# Returns 200 on success
Copied!
Parameters
Name
Type
Description
params
object
Script create parameters
Properties
cb
function
Node-style error-first callback function
Returns
script - The created script JSON object
Type object
1
// Example return value:
2
{
3
"id": "sc123abc",
4
"ownerType": "user",
5
"ownerId": "u456def",
6
"name": "My Script",
7
"description": "my_script_file.sh",
8
"dtCreated": "2017-06-15T19:22:13.507Z",
9
"isEnabled": true,
10
"runOnce": false
11
}
Copied!

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
1
paperspace.scripts.destroy({
2
scriptId: 'sc123abc',
3
}, function(err, res) {
4
// handle error or result
5
});
Copied!
1
# HTTP request:
2
https://api.paperspace.io
3
POST /scripts/sc123abc/destroy
4
x-api-key: 1ba4f98e7c0...
5
# Returns 204 on success
Copied!
Parameters
Name
Type
Description
params
object
Script destroy parameters
Properties
cb
function
Node-style error-first callback function

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
1
paperspace.scripts.list(function(err, res) {
2
// handle error or result
3
});
Copied!
1
# HTTP request:
2
https://api.paperspace.io
3
GET /scripts/getScripts
4
x-api-key: 1ba4f98e7c0...
5
# Returns 200 on success
Copied!
Parameters
Name
Type
Attributes
Description
filter
object
An optional filter object to limit the returned script objects
Properties
cb
function
Node-style error-first callback function
Returns
[ script, ... ] - JSON array of script objects
Type array
1
//Example return value:
2
[
3
{
4
"id": "sc123abc",
5
"ownerType": "user",
6
"ownerId": "u456def",
7
"name": "My Script",
8
"description": "original file: my_script.sh",
9
"dtCreated": "2017-05-30T14:49:16.724Z",
10
"isEnabled": true,
11
"runOnce": false
12
}
13
]
Copied!

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
1
paperspace.scripts.show({
2
scriptId: 'sc123abc',
3
}, function(err, res) {
4
// handle error or result
5
});
Copied!
1
# HTTP request:
2
https://api.paperspace.io
3
GET /scripts/getScript?scriptId=sc123abc
4
x-api-key: 1ba4f98e7c0...
5
# Returns 200 on success
Copied!
Parameters
Name
Type
Description
params
object
Script show parameters
Properties
cb
function
Node-style error-first callback function
Returns
script - The script JSON object
Type object
1
//Example return value:
2
{
3
"id": "sc123abc",
4
"ownerType": "user",
5
"ownerId": "u456def",
6
"name": "My Script",
7
"description": "original file: my_script.sh",
8
"dtCreated": "2017-05-30T14:49:16.724Z",
9
"isEnabled": true,
10
"runOnce": false
11
"machines": [
12
{
13
"machineId": "ps123abc",
14
"dtLastRun": "2017-07-06T12:38:17.325Z"
15
},
16
{
17
"machineId": "ps456def",
18
"dtLastRun": null
19
}
20
]
21
}
Copied!

Text

Gets the text of the script with the given id.
Examples
1
paperspace.scripts.text({
2
scriptId: 'sc123abc',
3
}, function(err, res) {
4
// handle error or result
5
});
Copied!
1
# HTTP request:
2
https://api.paperspace.io
3
GET /scripts/getScriptText?scriptId=sc123abc
4
x-api-key: 1ba4f98e7c0...
5
# Returns 200 on success
Copied!
Parameters
Name
Type
Description
params
object
Script text parameters
Properties
cb
function
Node-style error-first callback function
Returns
script - The script JSON object
Type string
1
//Example return value:
2
"services start nginx"
Copied!
Last modified 5mo ago
Copy link