How to Use Custom Callback Urls

You can use Callbacks to run separate, customized Cloud Code scripts against different Callback URLs. Each of the different Callback URLs are linked to a single custom Credential and you can create the Credentials you need for this purpose in the portal's Credentials section.

Multiple Callback URLs! Previously, only one Callback URL could be created per game. You can now create as many custom Callback URLs as there are custom Credentials.

1. Before we can create a Callback URL script, we'll first need to create a customized Credential. In the portal, go to Configurator > Credentials.

2. Click to Add two new custom Credentials:

Creating Credentials! For a refresher, see Security Credentials.

3. When you create each Credential, make sure you turn on the Callback switch. This tells the platform that the Credential is going to be exclusively used for Callback scripts:

4. In the portal, select Configurator > Cloud Code.

5. On the Cloud Code page under Scripts select Callbacks and edit one of the custom Credentials that you created in Step 2.

6. Enter the Cloud Code you want to be executed for the Callback. For the purposes of our tutorial, we'll just write a Script to return a message:

Spark.setScriptData("RESPONSE_RAW", "Hello World!");

7. Now that the Callback script is created, we can see this working by using an API Post Request in the following format:



Hello World!