Sends a message to one or more game friend(s). A game friend is someone in the players social network who also plays the game.

View interactive version here

Request Parameters

Parameter Required Type Description
friendIds Yes string[] One or more friend ID's. This can be supplied as a single string, or a JSON array
message Yes string The message to send

Response Parameters

A response to a send friend message request.

Parameter Type Description
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
friendId NOT_FRIEND The friend ID passed is not linked to the current player as a game friend
friendId INVALID The value passed is not a valid ID

Code Samples


    using GameSparks.Api;
    using GameSparks.Api.Requests;
    using GameSparks.Api.Responses;
    new SendFriendMessageRequest()
        .Send((response) => {
        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.SendFriendMessageResponse):void {
        var scriptData:ScriptData = response.getScriptData(); 


    #import "GS.h"
    #import "GSAPI.h"
    GSSendFriendMessageRequest* request = [[GSSendFriendMessageRequest alloc] init];
    [request setFriendIds:friendIds;
    [request setMessage:message;
    [request setCallback:^ (GSSendFriendMessageResponse* response) {
    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 SendFriendMessageRequest_Response(GS& gsInstance, const SendFriendMessageResponse& response) {
    GSData scriptData = response.getScriptData(); 

    SendFriendMessageRequest request(gsInstance);


import com.gamesparks.sdk.api.autogen.GSRequestBuilder.SendFriendMessageRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.SendFriendMessageResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;

    .send(new GSEventListener<SendFriendMessageResponse>() {
        public void onEvent(SendFriendMessageResponse response) {

Cloud Code

    var request = new SparkRequests.SendFriendMessageRequest();
    request.friendIds = ...;
    request.message = ...;
    var response = request.Send();

var scriptData = response.scriptData;