Accepts a challenge that has been issued to the current player.

View interactive version here

Request Parameters

Parameter Required Type Description
challengeInstanceId Yes string The ID of the challenge
message No string An optional message to send with the challenge

Response Parameters

A response containing the challenge instance id that was accepted.

Parameter Type Description
challengeInstanceId string The ID of the challenge
scriptData ScriptData A JSON Map of any data added either to the Request or the Response by your Cloud Code

Nested types


A collection of arbitrary data that can be added to a message via a Cloud Code script.

Parameter Type Description
myKey string An arbitrary data key
myValue JSON An arbitrary data value.

Error Codes

Key Value Description
challengeInstanceId INVALID The ID does not match a challenge the user is involved with

Code Samples


    using GameSparks.Api;
    using GameSparks.Api.Requests;
    using GameSparks.Api.Responses;
    new AcceptChallengeRequest()
        .Send((response) => {
        string challengeInstanceId = response.ChallengeInstanceId;
        GSData scriptData = response.ScriptData;

ActionScript 3

    import com.gamesparks.*;
    import com.gamesparks.api.requests.*;
    import com.gamesparks.api.responses.*;
    import com.gamesparks.api.types.*;

        .send(function(response:com.gamesparks.api.responses.AcceptChallengeResponse):void {
        var challengeInstanceId:String = response.getChallengeInstanceId(); 
        var scriptData:ScriptData = response.getScriptData(); 


    #import "GS.h"
    #import "GSAPI.h"
    GSAcceptChallengeRequest* request = [[GSAcceptChallengeRequest alloc] init];
    [request setChallengeInstanceId:challengeInstanceId;
    [request setMessage:message;
    [request setCallback:^ (GSAcceptChallengeResponse* response) {
    NSString* challengeInstanceId = [response getChallengeInstanceId]; 
    NSDictionary* scriptData = [response getScriptData]; 
    [gs send:request];


    #include <GameSparks/generated/GSRequests.h>
    using namespace GameSparks::Core;
    using namespace GameSparks::Api::Responses;
    using namespace GameSparks::Api::Requests;

    void AcceptChallengeRequest_Response(GS& gsInstance, const AcceptChallengeResponse& response) {
    gsstl::string challengeInstanceId = response.getChallengeInstanceId(); 
    GSData scriptData = response.getScriptData(); 

    AcceptChallengeRequest request(gsInstance);


import com.gamesparks.sdk.api.autogen.GSRequestBuilder.AcceptChallengeRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.AcceptChallengeResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;

    .send(new GSEventListener<AcceptChallengeResponse>() {
        public void onEvent(AcceptChallengeResponse response) {
            String challengeInstanceId = response.getChallengeInstanceId(); 

Cloud Code

    var request = new SparkRequests.AcceptChallengeRequest();
    request.challengeInstanceId = ...;
    request.message = ...;
    var response = request.Send();

var challengeInstanceId = response.challengeInstanceId; 
var scriptData = response.scriptData; 
Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here