Server-Side Cloud Script - Execute Function

Cloud Script is one of PlayFab's most versatile features. It allows client code to request execution of any kind of custom server-side functionality you can implement, and it can be used in conjunction with virtually anything.

POST https://titleId.playfabapi.com/CloudScript/ExecuteFunction

Request Header

Name Required Type Description
None True
  • string

This API requires no authentication headers (usually provides one to other calls).

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.).

Entity

The entity to perform this action on.

FunctionParameter
  • object

Object that is passed in to the function as the FunctionArgument field of the FunctionExecutionContext data structure

GeneratePlayStreamEvent
  • boolean

Generate a 'entity_executed_cloudscript_function' 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.

Responses

Name Type Description
200 OK
400 Bad Request

This is the outer wrapper for all responses with errors

Security

None

This API requires no authentication headers (usually provides one to other calls).

Type: apiKey
In: header

Definitions

ApiErrorWrapper

The basic wrapper around every failed API response

EntityKey

Combined entity type and ID structure which uniquely identifies a single entity.

ExecuteFunctionRequest

Executes an Azure Function with the profile of the entity that is defined in the request.

ExecuteFunctionResult
FunctionExecutionError

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

EntityKey

Combined entity type and ID structure which uniquely identifies a single entity.

Name Type Description
Id
  • string

Unique ID of the entity.

Type
  • string

Entity type. See https://docs.microsoft.com/gaming/playfab/features/data/entities/available-built-in-entity-types

ExecuteFunctionRequest

Executes an Azure Function with the profile of the entity that is defined in the request.

Name Type Description
CustomTags
  • object

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

Entity

The entity to perform this action on.

FunctionName
  • string

The name of the CloudScript function to execute

FunctionParameter
  • object

Object that is passed in to the function as the FunctionArgument field of the FunctionExecutionContext data structure

GeneratePlayStreamEvent
  • boolean

Generate a 'entity_executed_cloudscript_function' 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.

ExecuteFunctionResult

Name Type Description
Error

Error from the CloudScript Azure Function.

ExecutionTimeMilliseconds
  • number

The amount of time the function took to execute

FunctionName
  • string

The name of the function that executed

FunctionResult
  • object

The object returned from the function, if any

FunctionResultTooLarge
  • boolean

Flag indicating if the FunctionResult was too large and was subsequently dropped from this event.

FunctionExecutionError

Name Type Description
Error
  • string

Error code, such as CloudScriptAzureFunctionsExecutionTimeLimitExceeded, CloudScriptAzureFunctionsArgumentSizeExceeded, CloudScriptAzureFunctionsReturnSizeExceeded or CloudScriptAzureFunctionsHTTPRequestError

Message
  • string

Details about the error

StackTrace
  • string

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

Error Codes

Name Code
CloudScriptAzureFunctionsArgumentSizeExceeded 1471
CloudScriptAzureFunctionsExecutionTimeLimitExceeded 1470
CloudScriptAzureFunctionsHTTPRequestError 1473
CloudScriptAzureFunctionsQueueRequestError 1494
CloudScriptAzureFunctionsReturnSizeExceeded 1472
InvalidEntityType 1373