Executes a CloudScript function, with the 'currentPlayerId' variable set to the specified PlayFabId parameter value.

Request Details

Request Properties
FunctionName (required) 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.

PlayFabId (required) String

The unique user identifier for the player on whose behalf the script is being run

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 int32

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

POST https://{{TitleID}}
    Content-Type: application/json
    X-SecretKey: <developer_secret_key>
  "PlayFabId": "1337D00D",
  "FunctionName": "levelCompleted",
  "FunctionParameter": {
    "level": 3,
    "points": 400
  "RevisionSelection": "Live",
  "GeneratePlayStreamEvent": true

Response Details

Result Properties
APIRequestsIssued (required) int32

Number of PlayFab API requests issued by the CloudScript function

Error ScriptExecutionError

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

ExecutionTimeSeconds (required) double

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 (required) int32

Number of external HTTP requests issued by the CloudScript function

Logs List<LogStatement>

Entries logged during the function execution. These include both entries logged in the function code using 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 (required) uint32

ProcessorTimeSeconds (required) double

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

Revision (required) int32

The revision of the CloudScript that executed

Sample Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
  "code": 200,
  "status": "OK",
  "data": {
    "Revision": 3,
    "FunctionResult": {
      "newScore": 25,
      "isWinner": false
    "Logs": [
        "Level": "Info",
        "Message": "Something normal happened",
        "Data": {
          "secondsAfterStart": 75
        "Level": "Error",
        "Message": "Something unexpected happened"
    "ExecutionTimeSeconds": 0.03670790046453476,
    "ProcessorTimeSeconds": 0.0,
    "MemoryConsumedBytes": 38904,
    "APIRequestsIssued": 2,
    "HttpRequestsIssued": 0



Possible Error Codes

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