Server-Side Cloud Script - Execute Cloud Script

Executes a CloudScript function, with the 'currentPlayerId' set to the PlayFab ID of the authenticated player. The PlayFab ID is the entity ID of the player's master_player_account entity.

POST https://titleId.playfabapi.com/Client/ExecuteCloudScript

Request Header

Name Required Type Description
X-Authorization True

string

This API requires a client session ticket, available from any Client Login function.

Request Body

Name Required Type Description
FunctionName True

string

The name of the CloudScript function to execute

CustomTags

object

The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).

FunctionParameter

object

Object that is passed in to the function as the first argument

GeneratePlayStreamEvent

boolean

Generate a 'player_executed_cloudscript' PlayStream event containing the results of the function execution and other contextual information. This event will show up in the PlayStream debugger console for the player in Game Manager.

RevisionSelection

CloudScriptRevisionOption

Option for which revision of the CloudScript to execute. 'Latest' executes the most recently created revision, 'Live' executes the current live, published revision, and 'Specific' executes the specified revision. The default value is 'Specific', if the SpeificRevision parameter is specified, otherwise it is 'Live'.

SpecificRevision

number

The specivic revision to execute, when RevisionSelection is set to 'Specific'

Responses

Name Type Description
200 OK

ExecuteCloudScriptResult

400 Bad Request

ApiErrorWrapper

This is the outer wrapper for all responses with errors

Security

X-Authorization

This API requires a client session ticket, available from any Client Login function.

Type: apiKey
In: header

Definitions

Name Description
ApiErrorWrapper

The basic wrapper around every failed API response

CloudScriptRevisionOption
ExecuteCloudScriptRequest
ExecuteCloudScriptResult
LogStatement
ScriptExecutionError

ApiErrorWrapper

The basic wrapper around every failed API response

Name Type Description
code

integer

Numerical HTTP code

error

string

Playfab error code

errorCode

integer

Numerical PlayFab error code

errorDetails

object

Detailed description of individual issues with the request object

errorMessage

string

Description for the PlayFab errorCode

status

string

String HTTP code

CloudScriptRevisionOption

Name Type Description
Latest

string

Live

string

Specific

string

ExecuteCloudScriptRequest

Name Type Description
CustomTags

object

The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).

FunctionName

string

The name of the CloudScript function to execute

FunctionParameter

object

Object that is passed in to the function as the first argument

GeneratePlayStreamEvent

boolean

Generate a 'player_executed_cloudscript' PlayStream event containing the results of the function execution and other contextual information. This event will show up in the PlayStream debugger console for the player in Game Manager.

RevisionSelection

CloudScriptRevisionOption

Option for which revision of the CloudScript to execute. 'Latest' executes the most recently created revision, 'Live' executes the current live, published revision, and 'Specific' executes the specified revision. The default value is 'Specific', if the SpeificRevision parameter is specified, otherwise it is 'Live'.

SpecificRevision

number

The specivic revision to execute, when RevisionSelection is set to 'Specific'

ExecuteCloudScriptResult

Name Type Description
APIRequestsIssued

number

Number of PlayFab API requests issued by the CloudScript function

Error

ScriptExecutionError

Information about the error, if any, that occurred during execution

ExecutionTimeSeconds

number

FunctionName

string

The name of the function that executed

FunctionResult

object

The object returned from the CloudScript function, if any

FunctionResultTooLarge

boolean

Flag indicating if the FunctionResult was too large and was subsequently dropped from this event. This only occurs if the total event size is larger than 350KB.

HttpRequestsIssued

number

Number of external HTTP requests issued by the CloudScript function

Logs

LogStatement[]

Entries logged during the function execution. These include both entries logged in the function code using log.info() and log.error() and error entries for API and HTTP request failures.

LogsTooLarge

boolean

Flag indicating if the logs were too large and were subsequently dropped from this event. This only occurs if the total event size is larger than 350KB after the FunctionResult was removed.

MemoryConsumedBytes

number

ProcessorTimeSeconds

number

Processor time consumed while executing the function. This does not include time spent waiting on API calls or HTTP requests.

Revision

number

The revision of the CloudScript that executed

LogStatement

Name Type Description
Data

object

Optional object accompanying the message as contextual information

Level

string

'Debug', 'Info', or 'Error'

Message

string

ScriptExecutionError

Name Type Description
Error

string

Error code, such as CloudScriptNotFound, JavascriptException, CloudScriptFunctionArgumentSizeExceeded, CloudScriptAPIRequestCountExceeded, CloudScriptAPIRequestError, or CloudScriptHTTPRequestError

Message

string

Details about the error

StackTrace

string

Point during the execution of the script at which the error occurred, if any

Error Codes

Name Code
CloudScriptAPIRequestCountExceeded 1209
CloudScriptAPIRequestError 1210
CloudScriptFunctionArgumentSizeExceeded 1208
CloudScriptHTTPRequestError 1211
CloudScriptNotFound 1136
JavascriptException 1099
TitleDeleted 1347