new_releases Updates: Check the
release notes for new features and product updates.
Revoke messages
Stay organized with collections
Save and categorize content based on your preferences.
In the following example, rbm_api_helper.js
(not used for Python) assumes the
file you are working in is one directory below the main app folder. You may
need to adjust the location depending on your project's configuration.
The following code revokes an existing, undelivered message with a
client library.
Node.js
// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');
// Stop the message associated with messageId from being delivered
rbmApiHelper.revokeMessage('+12223334444', messageId, function(err, response) {
console.log(response);
});
This code is an excerpt from an RBM sample agent.
Java
import com.google.rbm.RbmApiHelper;
…
try {
// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper();
// Stop the message associated with messageId from being delivered
rbmApiHelper.revokeMessage(messageId, "+12223334444");
} catch(Exception e) {
e.printStackTrace();
}
This code is an excerpt from an RBM sample agent.
Python
# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
# Stop the message associated with message_id from being delivered
rbm_service.revoke('+12223334444', message_id)
This code is an excerpt from an RBM sample agent.
C#
using RCSBusinessMessaging;
…
// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
projectId);
// Stop the message associated with messageId from being delivered
rbmApiHelper.RevokeMessage(messageId, "+12223334444");
This code is an excerpt from an RBM sample agent.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-10 UTC.
[null,null,["Last updated 2025-04-10 UTC."],[[["\u003cp\u003eThis page demonstrates how to revoke an undelivered message using the RBM API with code examples in Node.js, Java, Python, and C#.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code snippets show how to utilize the respective language's RBM API helper or client library to stop a message from being delivered, referencing a specific \u003ccode\u003emessageId\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach language example requires referencing a helper library, such as \u003ccode\u003erbmApiHelper\u003c/code\u003e for Node.js, Java and C#, and \u003ccode\u003erbm_service\u003c/code\u003e for Python.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003erevokeMessage\u003c/code\u003e or \u003ccode\u003erevoke\u003c/code\u003e function is used in all examples to revoke a message associated with a provided \u003ccode\u003emessageId\u003c/code\u003e, and each language shows the necessary parameters.\u003c/p\u003e\n"]]],[],null,["# Revoke messages\n\nIn the following example, `rbm_api_helper.js` (not used for Python) assumes the\nfile you are working in is one directory below the main app folder. You may\nneed to adjust the location depending on your project's configuration.\n\nThe following code [revokes](/business-communications/rcs-business-messaging/guides/build/messages/revoke) an existing, undelivered message with a\nclient library. \n\n### Node.js\n\n```javascript\n// Reference to RBM API helper\nconst rbmApiHelper = require('@google/rcsbusinessmessaging');\n\n// Stop the message associated with messageId from being delivered\nrbmApiHelper.revokeMessage('\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e', messageId, function(err, response) {\n console.log(response);\n});\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### Java\n\n```java\nimport com.google.rbm.RbmApiHelper;\n...\n\ntry {\n // Create an instance of the RBM API helper\n RbmApiHelper rbmApiHelper = new RbmApiHelper();\n\n // Stop the message associated with messageId from being delivered\n rbmApiHelper.revokeMessage(messageId, \"\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e\");\n} catch(Exception e) {\n e.printStackTrace();\n}\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### Python\n\n```python\n# Reference to RBM Python client helper and messaging object structure\nfrom rcs_business_messaging import rbm_service\n\n# Stop the message associated with message_id from being delivered\nrbm_service.revoke('\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e', message_id)\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### C#\n\n```c#\nusing RCSBusinessMessaging;\n...\n\n// Create an instance of the RBM API helper\nRbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,\n projectId);\n\n// Stop the message associated with messageId from being delivered\nrbmApiHelper.RevokeMessage(messageId, \"\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e\");\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples)."]]