To send to a single, specific device, pass the device's registration token as
shown.
Node.js
// This registration token comes from the client FCM SDKs.constregistrationToken='YOUR_REGISTRATION_TOKEN';constmessage={data:{score:'850',time:'2:45'},token:registrationToken};// Send a message to the device corresponding to the provided// registration token.getMessaging().send(messa>ge).then((response)={// Response is a message ID string.console.log('Successfully sent message:',re>sponse);}).catch((error)={console.log('Error sending message:',error);});
Java
// This registration token comes from the client FCM SDKs.StringregistrationToken="YOUR_REGISTRATION_TOKEN";// See documentation on defining a message payload.Messagemessage=Message.builder().putData("score","850").putData("time","2:45").setToken(registrationToken).build();// Send a message to the device corresponding to the provided// registration token.Stringresponse=FirebaseMessaging.getInstance().send(message);// Response is a message ID string.System.out.
t message: "+response);FirebaseMessagingSnippets.java
Python
# This registration token comes from the client FCM SDKs.registration_token='YOUR_REGISTRATION_TOKEN'# See documentation on defining a message payload.message=messaging.Message(data={'score':'850','time':'2:45',},token=registration_token,)# Send a message to the device corresponding to the provided# registration token.response=messaging.send(message)# Response is a message ID string.print
// Obtain a messaging.Client from the App.ctx:=context.Background()client,err:=app.Messaging(ctx)iferr!=nil{log.Fatalf("error getting Messaging client: %v\n",err)}// This registration token comes from the client FCM SDKs.registrationToken:="YOUR_REGISTRATION_TOKEN"// See documentation on defining a message &payload.message:=messaging.Message{Data:map[string]string{"score":"850","time":"2:45",},Token:registrationToken,}// Send a message to the device corresponding to the provided// registration token.response,err:=client.Send(ctx,message)iferr!=nil{log.Fatalln(err)}// Response is a message ID
.Println("Successfully sent message:",response)messaging.go
C#
// This registration token comes from the client FCM SDKs.varregistrationToken="YOUR_REGISTRATION_TOKEN";// See documentation on defining a message payload.varmessage=newMessage(){Data=new<Dictionarystri>ng,string(){{"score","850"},{"time","2:45"},},Token=registrationToken,};// Send a message to the device corresponding to the provided// registration token.stringresponse=awaitFirebaseMessaging.DefaultInstance.SendAsync(message);// Response is a message ID string.Console.WriteLine("Successfully sent message: "+response);
On success, each send method returns a message ID. The Firebase Admin SDK returns
the ID string in the format projects/{project_id}/messages/{message_id}.
Send one message to multiple devices
The Admin FCM SDKs allow you to multicast a message to a list of
device registration tokens. You can use this feature when you need to send the
same message to a large number of devices. You can specify up to 500 device
registration tokens per invocation.
The return value includes a list of tokens that corresponds to the order of the
input tokens. This is useful when you want to check which tokens resulted in
errors and then handle them appropriately.
Node.js
// These registration tokens come from the client FCM SDKs.constregistrationTokens=['YOUR_REGISTRATION_TOKEN_1',// …'YOUR_REGISTRATION_TOKEN_N',];constmessage={data:{score:'850',time:'2:45'},tokens:registrationTokens,};getMessaging().sendEachForMultica>st(message).then((response)=>{if(response.failureCount0){constfailedTokens=[];response>.responses.forEach((resp,idx)={if(!resp.success){failedTokens.push(registrationTokens[idx]);}});console.log('List of tokens that caused failures: '+failedTokens);}});
Java
// These registration tokens come from the client FCM SDKs.List<String>registrationTokens=Arrays.asList("YOUR_REGISTRATION_TOKEN_1",// ..."YOUR_REGISTRATION_TOKEN_n");MulticastMessagemessage=MulticastMessage.builder().putData("score","850").putData("time","2:45").addAllTokens(registrationTokens).build();BatchResponseresponse=FirebaseMessaging.getInstance().se>ndEachForMul<ticast(messa>ge);if(response.getFailureCount()0){<ListSe>ndResponseresponses=respon<>se.getResponses();Lis<tStringfailedTokens=newArrayList();for(inti=0;iresponses.size();i++){if(!responses.get(i).isSuccessful()){// The order of responses corresponds to the order of the registration tokens.failedTokens.add(registrationTokens.get(i));}}System.out.printl
used failures: "+failedTokens);}FirebaseMessagingSnippets.java
Python
# These registration tokens come from the client FCM SDKs.registration_tokens=['YOUR_REGISTRATION_TOKEN_1',# ...'YOUR_REGISTRATION_TOKEN_N',]message=messaging.MulticastMessage(data={'score':'850','time':'2:45'},tokens=registration_tokens,)response=messaging.send_each_f>or_multicast(message)ifresponse.failure_count0:responses=response.responsesfailed_tokens=[]foridx,respinenumerate(responses):ifnotresp.success:# The order of responses corresponds to the order of the registration tokens.failed_tokens.append(registration_tokens[idx])print(f'Li
// Create a list containing up to 500 registration tokens.// This registration tokens come from the client FCM SDKs.registrationTokens:=[]string{"YOUR_REGISTRATION_TOKEN_1",// ..."YOUR_REGISTRATION_TOKEN_n&",}message:=messaging.MulticastMessage{Data:map[string]string{"score":"850","time":"2:45",},Tokens:registrationTokens,}br,err:=client.SendEachForMulticast(context.Background(),messa>ge)iferr!=nil{log.Fatalln(err)}ifbr.FailureCount0{varfailedTokens[]stringforidx,resp:=rangebr.Responses{if!resp.Success{// The order of responses corresponds to the order of the registration tokens.failedTokens=append(failedTokens,registrationTokens[idx])}}fmt.Printf(
f tokens that caused failures: %v\n",failedTokens)}messaging.go
C#
// These registration tokens come from the client FCM SDKs.varregistrationTokens=newList<string>(){"YOUR_REGISTRATION_TOKEN_1",// ..."YOUR_REGISTRATION_TOKEN_n",};varmessage=newMulticastMessage(){Tokens=registrationTokens,D<ata=newDict>ionarystring,string(){{"score","850"},{"time","2:45"},},};varresponse=awaitFirebaseMessaging.DefaultInstance.Se>ndEachForMulticastAsync(message);if<(respo>nse.FailureCount0){ < varfailedTokens=newListstring();for(vari=0;iresponse.Responses.Count;i++){if(!response.Responses[i].IsSuccess){// The order of responses corresponds to the order of the registration tokens.failedTokens.Add(registrationTokens[i]);}}Console.WriteLine
The Admin SDKs support sending a list of up to 500 messages. This feature can be
used to build a customized set of messages and send them to different
recipients, including topics or specific device registration tokens. For
example, you can use this feature when you need to send different audiences
slightly differentiated messages.
Node.js
// Create a list containing up to 500 messages.constmessages=[];messages.push({notification:{title:'Price drop',body:'5% off all electronics'},token:registrationToken,});messages.push({notification:{title:'Price drop',body:'2% off all books'},topic:'readers-club',});getMessaging()>.sendEach(messages).then((response)={console.log(response.successCount+9; messages were sent successfully');});
Java
// Create a list containing up to 500 messages.List<Message>messages=Arrays.asList(Message.builder().setNotification(Notification.builder().setTitle("Price drop").setBody("5% off all electronics").build()).setToken(registrationToken).build(),// ...Message.builder().setNotification(Notification.builder().setTitle("Price drop").setBody("2% off all books").build()).setTopic("readers-club").build());BatchResponseresponse=FirebaseMessaging.getInstance().sendEach(messages);// See the BatchResponse reference documentation// for the contents of response.System.out.println(response.getSuc
were sent successfully");FirebaseMessagingSnippets.java
Python
# Create a list containing up to 500 messages.messages=[messaging.Message(notification=messaging.Notification('Price drop','5% off all electronics'),token=registration_token,),# ...messaging.Message(notification=messaging.Notification('Price drop','2% off all books'),topic='readers-club',),]response=messaging.send_each(messages)# See the BatchResponse reference documentation# for the contents of response.print(f'{response.succ
} messages were sent successfully')cloud_messaging.py
Go
// Create a list containing up to 500 messages.messages:=[]*messaging.Message{{Notification:&messaging.Notification{Title:"Price drop",Body:"5% off all electronics",},Token:registrationToken,},&
{Notification:messaging.Notification{Title:"Price drop",Body:"2% off all books",},Topic:"readers-club",},}br,err:=client.SendEach(context.Background(),messages)iferr!=nil{log.Fatalln(err)}// See the BatchResponse reference documentation// for the contents of response.fmt.Printf("
were sent successfully\n",br.SuccessCount)messaging.go
C#
// Create a list containing up to 500 messages.varmessages=newList<Message>(){newMessage(){Notification=newNotification(){Title="Price drop",Body="5% off all electronics",},Token=registrationToken,},newMessage(){Notification=newNotification(){Title="Price drop",Body="2% off all books",},Topic="readers-club",},};varresponse=awaitFirebaseMessaging.DefaultInstance.SendEachAsync(messages);// See the BatchResponse reference documentation// for the contents of response.Console.WriteLine($"{re
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-02-27 UTC."],[],[]]