Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(sdk): expose quotedMessageId on the send request types
Yudhi Armyndharisc4bb6383828e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ac54ae4db..0f2a54e5a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- `AUDIT_RETENTION_DAYS` is checked at boot, so a typo fails startup with a named error instead of silently reverting to the 90-day default. It is validated as an integer of any sign rather than a positive one, because both `0` and any negative value are documented switches that disable audit-log pruning entirely.- `message.controller.spec.ts` holds the two headers the stored-media download sends, `X-Content-Type-Options: nosniff` and `Content-Disposition: attachment`; deleting either had passed every suite in the repo.- Optional `quotedMessageId` on every `send-*` message endpoint and its MCP tool, so a reply can carry media, a location, a contact card or a poll instead of only text. An id the engine cannot resolve now fails the send rather than delivering the message unquoted. Thanks @nirizr for the report.+- All five SDK clients expose `quotedMessageId` on their send request types, so a typed caller can reply with media, a location, a contact card or a poll without hand-building the body.### Fixeddiff --git a/sdk/go/quoted_send_test.go b/sdk/go/quoted_send_test.gonew file mode 100644index 000000000..91efde119--- /dev/null+++ b/sdk/go/quoted_send_test.go@@ -0,0 +1,70 @@+package openwa++import (+ "context"+ "encoding/json"+ "testing"+)++// The body is what matters here, not the path. A dropped key is the failure mode this guards: Go's+// `omitempty` and Java's Gson both omit an unset value, so a request type that forgot the field+// still compiles, still routes correctly, and simply sends nothing — a 400 on one client while the+// others work.+func TestQuotedMessageIDReachesTheBody(t *testing.T) {+ ctx := context.Background()+ cases := []struct {+ name string+ call func(*Client)+ }{+ {"send-text", func(c *Client) {+ c.Messages.SendText(ctx, "s1", SendTextRequest{ChatID: "[email protected]", Text: "hi", QuotedMessageID: "q1"})+ }},+ {"send-image", func(c *Client) {+ c.Messages.SendImage(ctx, "s1", SendMediaRequest{ChatID: "[email protected]", URL: "http://u", QuotedMessageID: "q1"})+ }},+ {"send-audio", func(c *Client) {+ c.Messages.SendAudio(ctx, "s1", SendAudioRequest{ChatID: "[email protected]", URL: "http://u", QuotedMessageID: "q1"})+ }},+ {"send-location", func(c *Client) {+ c.Messages.SendLocation(ctx, "s1", SendLocationRequest{ChatID: "[email protected]", Latitude: 1, Longitude: 2, QuotedMessageID: "q1"})+ }},+ {"send-contact", func(c *Client) {+ c.Messages.SendContact(ctx, "s1", SendContactRequest{ChatID: "[email protected]", ContactName: "A", ContactNumber: "628", QuotedMessageID: "q1"})+ }},+ {"send-poll", func(c *Client) {+ c.Messages.SendPoll(ctx, "s1", SendPollRequest{ChatID: "[email protected]", Name: "Q", Options: []string{"a", "b"}, QuotedMessageID: "q1"})+ }},+ }++ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ rt := &recordTransport{status: 200, body: `{}`}+ tc.call(newTestClient(t, rt))++ var body map[string]any+ if err := json.Unmarshal(rt.lastRaw, &body); err != nil {+ t.Fatalf("request body was not JSON: %v (%s)", err, rt.lastRaw)+ }+ if body["quotedMessageId"] != "q1" {+ t.Fatalf("quotedMessageId missing from body: %s", rt.lastRaw)+ }+ })+ }+}++// Known-negative control. `omitempty` is the whole reason the field is a plain string rather than a+// pointer, and without this an implementation that emitted `"quotedMessageId": ""` on every send+// would satisfy nothing above yet ship a wrong body on the ordinary path.+func TestOrdinarySendOmitsTheQuoteKey(t *testing.T) {+ rt := &recordTransport{status: 200, body: `{}`}+ c := newTestClient(t, rt)+ c.Messages.SendImage(context.Background(), "s1", SendMediaRequest{ChatID: "[email protected]", URL: "http://u"})++ var body map[string]any+ if err := json.Unmarshal(rt.lastRaw, &body); err != nil {+ t.Fatalf("request body was not JSON: %v", err)+ }+ if _, present := body["quotedMessageId"]; present {+ t.Fatalf("ordinary send carried a quote key: %s", rt.lastRaw)+ }+}diff --git a/sdk/go/types_message.go b/sdk/go/types_message.goindex 159db809a..dbdbfec82 100644--- a/sdk/go/types_message.go+++ b/sdk/go/types_message.go@@ -26,6 +26,10 @@ type SendTextRequest struct {// fetched, so it works even for a URL the gateway cannot reach. Baileys only — whatsapp-web.js// takes a boolean and answers 501. Cannot be combined with LinkPreview=false.CustomLinkPreview *CustomLinkPreview `json:"customLinkPreview,omitempty"`+ // QuotedMessageID quotes an earlier message, turning this send into a reply. Engine-specific:+ // whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message it has+ // already stored. Omitted when empty, so an ordinary send carries no quote key.+ QuotedMessageID string `json:"quotedMessageId,omitempty"`}// SendMediaRequest sends image/video/document/sticker media. Provide exactly@@ -37,6 +41,10 @@ type SendMediaRequest struct {Mimetype string `json:"mimetype,omitempty"`Filename string `json:"filename,omitempty"`Caption string `json:"caption,omitempty"`+ // QuotedMessageID quotes an earlier message, turning this send into a reply. Engine-specific:+ // whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message it has+ // already stored. Omitted when empty, so an ordinary send carries no quote key.+ QuotedMessageID string `json:"quotedMessageId,omitempty"`}// SendAudioRequest sends audio. PTT sends as a voice note. Server only accepts@@ -49,6 +57,10 @@ type SendAudioRequest struct {Filename string `json:"filename,omitempty"`Caption string `json:"caption,omitempty"`PTT *bool `json:"ptt,omitempty"`+ // QuotedMessageID quotes an earlier message, turning this send into a reply. Engine-specific:+ // whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message it has+ // already stored. Omitted when empty, so an ordinary send carries no quote key.+ QuotedMessageID string `json:"quotedMessageId,omitempty"`}// SendLocationRequest sends a location pin. ChatID/Latitude/Longitude required.@@ -58,6 +70,10 @@ type SendLocationRequest struct {Longitude float64 `json:"longitude"`Description string `json:"description,omitempty"`Address string `json:"address,omitempty"`+ // QuotedMessageID quotes an earlier message, turning this send into a reply. Engine-specific:+ // whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message it has+ // already stored. Omitted when empty, so an ordinary send carries no quote key.+ QuotedMessageID string `json:"quotedMessageId,omitempty"`}// SendContactRequest sends a contact card.@@ -65,6 +81,10 @@ type SendContactRequest struct {ChatID string `json:"chatId"`ContactName string `json:"contactName"`ContactNumber string `json:"contactNumber"`+ // QuotedMessageID quotes an earlier message, turning this send into a reply. Engine-specific:+ // whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message it has+ // already stored. Omitted when empty, so an ordinary send carries no quote key.+ QuotedMessageID string `json:"quotedMessageId,omitempty"`}// SendTemplateRequest sends a stored template. Provide exactly one of@@ -85,6 +105,10 @@ type SendPollRequest struct {Options []string `json:"options"`// AllowMultipleAnswers lets voters pick several options (default single choice).AllowMultipleAnswers *bool `json:"allowMultipleAnswers,omitempty"`+ // QuotedMessageID quotes an earlier message, turning this send into a reply. Engine-specific:+ // whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message it has+ // already stored. Omitted when empty, so an ordinary send carries no quote key.+ QuotedMessageID string `json:"quotedMessageId,omitempty"`}// ReplyMessageRequest replies to a quoted message.diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendContactRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendContactRequest.javaindex 0f619a735..3285724e4 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendContactRequest.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendContactRequest.java@@ -1,7 +1,8 @@package com.rmyndharis.openwa.model;/** Request body for sending a contact card. */-public record SendContactRequest(String chatId, String contactName, String contactNumber) {+public record SendContactRequest(String chatId, String contactName, String contactNumber,+ String quotedMessageId) {public static Builder builder() {return new Builder();}@@ -10,6 +11,7 @@ public record SendContactRequest(String chatId, String contactName, String contaprivate String chatId;private String contactName;private String contactNumber;+ private String quotedMessageId;public Builder chatId(String v) {this.chatId = v;@@ -26,8 +28,18 @@ public record SendContactRequest(String chatId, String contactName, String contareturn this;}+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific:+ * whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message+ * it has already stored.+ */+ public Builder quotedMessageId(String v) {+ this.quotedMessageId = v;+ return this;+ }+public SendContactRequest build() {- return new SendContactRequest(chatId, contactName, contactNumber);+ return new SendContactRequest(chatId, contactName, contactNumber, quotedMessageId);}}}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendLocationRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendLocationRequest.javaindex 90b1c1379..3dd47944f 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendLocationRequest.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendLocationRequest.java@@ -6,7 +6,8 @@ public record SendLocationRequest(double latitude,double longitude,String description,- String address) {+ String address,+ String quotedMessageId) {public static Builder builder() {return new Builder();@@ -18,6 +19,7 @@ public record SendLocationRequest(private double longitude;private String description;private String address;+ private String quotedMessageId;public Builder chatId(String v) {this.chatId = v;@@ -44,8 +46,18 @@ public record SendLocationRequest(return this;}+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific:+ * whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message+ * it has already stored.+ */+ public Builder quotedMessageId(String v) {+ this.quotedMessageId = v;+ return this;+ }+public SendLocationRequest build() {- return new SendLocationRequest(chatId, latitude, longitude, description, address);+ return new SendLocationRequest(chatId, latitude, longitude, description, address, quotedMessageId);}}}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendMediaRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendMediaRequest.javaindex 612c932e9..2134ab8be 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendMediaRequest.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendMediaRequest.java@@ -7,7 +7,8 @@ public record SendMediaRequest(String base64,String mimetype,String filename,- String caption) {+ String caption,+ String quotedMessageId) {public static Builder builder() {return new Builder();@@ -20,6 +21,7 @@ public record SendMediaRequest(private String mimetype;private String filename;private String caption;+ private String quotedMessageId;public Builder chatId(String v) {this.chatId = v;@@ -55,8 +57,18 @@ public record SendMediaRequest(return this;}+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific:+ * whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message+ * it has already stored.+ */+ public Builder quotedMessageId(String v) {+ this.quotedMessageId = v;+ return this;+ }+public SendMediaRequest build() {- return new SendMediaRequest(chatId, url, base64, mimetype, filename, caption);+ return new SendMediaRequest(chatId, url, base64, mimetype, filename, caption, quotedMessageId);}}}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendPollRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendPollRequest.javaindex 06f5dc833..b9e77f8a1 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendPollRequest.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendPollRequest.java@@ -3,7 +3,8 @@ package com.rmyndharis.openwa.model;import java.util.List;/** Request body for sending a native WhatsApp poll (2–12 options). */-public record SendPollRequest(String chatId, String name, List<String> options, Boolean allowMultipleAnswers) {+public record SendPollRequest(String chatId, String name, List<String> options, Boolean allowMultipleAnswers,+ String quotedMessageId) {public static Builder builder() {return new Builder();}@@ -13,6 +14,7 @@ public record SendPollRequest(String chatId, String name, List<String> options,private String name;private List<String> options;private Boolean allowMultipleAnswers;+ private String quotedMessageId;public Builder chatId(String v) {this.chatId = v;@@ -37,8 +39,18 @@ public record SendPollRequest(String chatId, String name, List<String> options,return this;}+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific:+ * whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message+ * it has already stored.+ */+ public Builder quotedMessageId(String v) {+ this.quotedMessageId = v;+ return this;+ }+public SendPollRequest build() {- return new SendPollRequest(chatId, name, options, allowMultipleAnswers);+ return new SendPollRequest(chatId, name, options, allowMultipleAnswers, quotedMessageId);}}}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendTextRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendTextRequest.javaindex 3ee3cec39..b7fb880a3 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendTextRequest.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SendTextRequest.java@@ -4,15 +4,16 @@ import java.util.List;/** Request body for sending a text message. */public record SendTextRequest(- String chatId, String text, List<String> mentions, Boolean linkPreview, CustomLinkPreview customLinkPreview) {+ String chatId, String text, List<String> mentions, Boolean linkPreview, CustomLinkPreview customLinkPreview,+ String quotedMessageId) {/** Back-compatible constructor without mentions. */public SendTextRequest(String chatId, String text) {- this(chatId, text, null, null, null);+ this(chatId, text, null, null, null, null);}/** Back-compatible constructor without a link-preview choice. */public SendTextRequest(String chatId, String text, List<String> mentions) {- this(chatId, text, mentions, null, null);+ this(chatId, text, mentions, null, null, null);}public static Builder builder() {@@ -25,6 +26,7 @@ public record SendTextRequest(private List<String> mentions;private Boolean linkPreview;private CustomLinkPreview customLinkPreview;+ private String quotedMessageId;public Builder chatId(String v) {this.chatId = v;@@ -62,8 +64,18 @@ public record SendTextRequest(return this;}+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific:+ * whatsapp-web.js matches the serialized message id, Baileys the raw key id of a message+ * it has already stored.+ */+ public Builder quotedMessageId(String v) {+ this.quotedMessageId = v;+ return this;+ }+public SendTextRequest build() {- return new SendTextRequest(chatId, text, mentions, linkPreview, customLinkPreview);+ return new SendTextRequest(chatId, text, mentions, linkPreview, customLinkPreview, quotedMessageId);}}}diff --git a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/MessagesResourceTest.java b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/MessagesResourceTest.javaindex f960ccfe1..744195ddb 100644--- a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/MessagesResourceTest.java+++ b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/MessagesResourceTest.java@@ -172,6 +172,62 @@ class MessagesResourceTest {assertTrue(tx.lastRequest().body().contains("welcome-tpl"));}+ // Asserted on the body rather than the path: Gson omits a null component, so a record that+ // forgot the field would still compile and still route correctly while sending nothing.+ @Test+ void quotedMessageIdReachesTheBodyOnEverySend() {+ tx.respond(200, MSG);+ client.messages.sendText(+ "s", SendTextRequest.builder().chatId("[email protected]").text("hi").quotedMessageId("q-text").build());+ assertTrue(tx.lastRequest().body().contains("q-text"));++ tx.respond(200, MSG);+ client.messages.sendImage(+ "s", SendMediaRequest.builder().chatId("[email protected]").url("http://u").quotedMessageId("q-media").build());+ assertTrue(tx.lastRequest().body().contains("q-media"));++ tx.respond(200, MSG);+ client.messages.sendLocation(+ "s",+ SendLocationRequest.builder()+ .chatId("[email protected]")+ .latitude(1.0)+ .longitude(2.0)+ .quotedMessageId("q-loc")+ .build());+ assertTrue(tx.lastRequest().body().contains("q-loc"));++ tx.respond(200, MSG);+ client.messages.sendContact(+ "s",+ SendContactRequest.builder()+ .chatId("[email protected]")+ .contactName("A")+ .contactNumber("628")+ .quotedMessageId("q-contact")+ .build());+ assertTrue(tx.lastRequest().body().contains("q-contact"));++ tx.respond(200, MSG);+ client.messages.sendPoll(+ "s",+ SendPollRequest.builder()+ .chatId("[email protected]")+ .name("Q")+ .options(java.util.List.of("a", "b"))+ .quotedMessageId("q-poll")+ .build());+ assertTrue(tx.lastRequest().body().contains("q-poll"));+ }++ // Known-negative control: an ordinary send must not carry the key at all.+ @Test+ void ordinarySendOmitsTheQuoteKey() {+ tx.respond(200, MSG);+ client.messages.sendImage("s", SendMediaRequest.builder().chatId("[email protected]").url("http://u").build());+ assertTrue(!tx.lastRequest().body().contains("quotedMessageId"));+ }+@Testvoid replyHitsReplyPath() {tx.respond(200, MSG);diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.tsindex 0a4aab6f7..3d7096aff 100644--- a/sdk/javascript/src/types.ts+++ b/sdk/javascript/src/types.ts@@ -240,6 +240,12 @@ export interface SendTextRequest {* boolean and answers 501. Cannot be combined with `linkPreview: false`.*/customLinkPreview?: { url: string; title: string; description?: string };+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ * matches the serialized message id, Baileys the raw message key id of a message it has already+ * stored. An id the engine cannot resolve fails the send rather than delivering it unquoted.+ */+ quotedMessageId?: string;}export interface SendMediaRequest {@@ -253,6 +259,12 @@ export interface SendMediaRequest {filename?: string;/** Max 1024 chars. */caption?: string;+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ * matches the serialized message id, Baileys the raw message key id of a message it has already+ * stored. An id the engine cannot resolve fails the send rather than delivering it unquoted.+ */+ quotedMessageId?: string;}export interface SendAudioRequest extends SendMediaRequest {@@ -276,12 +288,24 @@ export interface SendLocationRequest {longitude: number;description?: string;address?: string;+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ * matches the serialized message id, Baileys the raw message key id of a message it has already+ * stored. An id the engine cannot resolve fails the send rather than delivering it unquoted.+ */+ quotedMessageId?: string;}export interface SendContactRequest {chatId: Jid;contactName: string;contactNumber: string;+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ * matches the serialized message id, Baileys the raw message key id of a message it has already+ * stored. An id the engine cannot resolve fails the send rather than delivering it unquoted.+ */+ quotedMessageId?: string;}export interface ReplyMessageRequest {@@ -408,6 +432,12 @@ export interface SendPollRequest {options: string[];/** Allow voters to pick several options (default single choice). */allowMultipleAnswers?: boolean;+ /**+ * Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ * matches the serialized message id, Baileys the raw message key id of a message it has already+ * stored. An id the engine cannot resolve fails the send rather than delivering it unquoted.+ */+ quotedMessageId?: string;}export interface ListMessagesQuery {diff --git a/sdk/javascript/test/messages.test.ts b/sdk/javascript/test/messages.test.tsindex 8afad9c4d..8e93d4b85 100644--- a/sdk/javascript/test/messages.test.ts+++ b/sdk/javascript/test/messages.test.ts@@ -84,7 +84,17 @@ describe('MessagesResource — exact paths', () => {const t = new MockTransport().on('GET', /\/messages$/, {body: {messages: [- { id: '1', sessionId: 's', chatId: '[email protected]', from: '[email protected]', to: 's', type: 'text', direction: 'incoming', status: 'delivered', createdAt: '' },+ {+ id: '1',+ sessionId: 's',+ chatId: '[email protected]',+ from: '[email protected]',+ to: 's',+ type: 'text',+ direction: 'incoming',+ status: 'delivered',+ createdAt: '',+ },],total: 1,},@@ -94,6 +104,52 @@ describe('MessagesResource — exact paths', () => {expect(res.messages).toHaveLength(1);});+ // Asserted on the BODY, not the URL: the field is what this is about, and a URL assertion cannot+ // see a dropped key. One case per request type, because each is a separate declaration — a type+ // that forgot the field would still send it from JS but would not compile for a typed caller.+ it.each([+ [+ 'send-text',+ (c: OpenWAClient) => c.messages.sendText('s1', { chatId: '[email protected]', text: 'hi', quotedMessageId: 'q1' }),+ ],+ [+ 'send-image',+ (c: OpenWAClient) => c.messages.sendImage('s1', { chatId: '[email protected]', url: 'http://u', quotedMessageId: 'q1' }),+ ],+ [+ 'send-location',+ (c: OpenWAClient) =>+ c.messages.sendLocation('s1', { chatId: '[email protected]', latitude: 1, longitude: 2, quotedMessageId: 'q1' }),+ ],+ [+ 'send-contact',+ (c: OpenWAClient) =>+ c.messages.sendContact('s1', {+ chatId: '[email protected]',+ contactName: 'A',+ contactNumber: '628',+ quotedMessageId: 'q1',+ }),+ ],+ [+ 'send-poll',+ (c: OpenWAClient) =>+ c.messages.sendPoll('s1', { chatId: '[email protected]', name: 'Q', options: ['a', 'b'], quotedMessageId: 'q1' }),+ ],+ ])('%s forwards quotedMessageId in the body', async (route, call) => {+ const t = new MockTransport().on('POST', new RegExp(`${route}$`), { body: { messageId: 'm', timestamp: 1 } });+ await call(client(t));+ expect(t.lastCall!.body).toMatchObject({ quotedMessageId: 'q1' });+ });++ // Known-negative control: an ordinary send must not carry the key at all, so an implementation+ // that always emitted it (as `undefined`, which JSON.stringify drops but a proxy may not) fails.+ it('omits quotedMessageId entirely on an ordinary send', async () => {+ const t = new MockTransport().on('POST', /send-image$/, { body: { messageId: 'm', timestamp: 1 } });+ await client(t).messages.sendImage('s1', { chatId: '[email protected]', url: 'http://u' });+ expect(t.lastCall!.body).not.toHaveProperty('quotedMessageId');+ });+it('reply / forward / react / delete', async () => {const t = new MockTransport().on('POST', /\/messages\/reply$/, { body: { messageId: 'm', timestamp: 1 } })@@ -149,7 +205,11 @@ describe('MessagesResource — exact paths', () => {},}).on('POST', /\/batch\/b\/cancel$/, {- body: { batchId: 'b', status: 'cancelled', progress: { total: 1, sent: 0, failed: 0, pending: 0, cancelled: 1 } },+ body: {+ batchId: 'b',+ status: 'cancelled',+ progress: { total: 1, sent: 0, failed: 0, pending: 0, cancelled: 1 },+ },});const c = client(t);await c.messages.sendBulk('s', { messages: [{ chatId: '[email protected]', type: 'text', content: { text: 'x' } }] });diff --git a/sdk/php/tests/MessagesTest.php b/sdk/php/tests/MessagesTest.phpindex 13497c0df..af6c5d391 100644--- a/sdk/php/tests/MessagesTest.php+++ b/sdk/php/tests/MessagesTest.php@@ -109,6 +109,47 @@ class MessagesTest extends TestCase$this->assertStringContainsString('/messages/delete', $backend->calls()[3]['url']);}+ /**+ * This client takes an untyped array, so nothing here checks the shape at compile time — the+ * body assertion is the only thing standing between a caller and a silently dropped key.+ */+ public function testQuotedMessageIdReachesTheBodyOnEverySend(): void+ {+ $backend = new MockBackend();+ foreach (range(1, 5) as $ignored) {+ $backend->on(201, ['messageId' => 'm', 'timestamp' => 1]);+ }+ $client = $backend->makeClient();++ $client->messages->sendText('s', ['chatId' => '[email protected]', 'text' => 'hi', 'quotedMessageId' => 'q1']);+ $client->messages->sendImage('s', ['chatId' => '[email protected]', 'url' => 'http://u', 'quotedMessageId' => 'q1']);+ $client->messages->sendLocation(+ 's',+ ['chatId' => '[email protected]', 'latitude' => 1, 'longitude' => 2, 'quotedMessageId' => 'q1']+ );+ $client->messages->sendContact(+ 's',+ ['chatId' => '[email protected]', 'contactName' => 'A', 'contactNumber' => '628', 'quotedMessageId' => 'q1']+ );+ $client->messages->sendPoll(+ 's',+ ['chatId' => '[email protected]', 'name' => 'Q', 'options' => ['a', 'b'], 'quotedMessageId' => 'q1']+ );++ foreach ($backend->calls() as $call) {+ $this->assertSame('q1', $call['body']['quotedMessageId'] ?? null, $call['url']);+ }+ }++ public function testOrdinarySendCarriesNoQuoteKey(): void+ {+ $backend = new MockBackend();+ $backend->on(201, ['messageId' => 'm', 'timestamp' => 1]);+ $backend->makeClient()->messages->sendImage('s', ['chatId' => '[email protected]', 'url' => 'http://u']);++ $this->assertArrayNotHasKey('quotedMessageId', $backend->lastCall()['body']);+ }+public function testEditMessageUsesEditPath(): void{$backend = (new MockBackend())->on(200, ['messageId' => 'm1', 'timestamp' => 123]);diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.pyindex 190440531..5dd7a8c54 100644--- a/sdk/python/openwa/types.py+++ b/sdk/python/openwa/types.py@@ -297,6 +297,9 @@ class SendTextRequest(TypedDict, total=False):# so this works even for a URL the gateway cannot reach. Baileys only -- whatsapp-web.js takes a# boolean and answers 501. Cannot be combined with linkPreview=False.customLinkPreview: CustomLinkPreview+ # Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ # matches the serialized message id, Baileys the raw key id of a message it has already stored.+ quotedMessageId: strclass SendMediaRequest(TypedDict, total=False):@@ -306,6 +309,9 @@ class SendMediaRequest(TypedDict, total=False):mimetype: strfilename: strcaption: str+ # Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ # matches the serialized message id, Baileys the raw key id of a message it has already stored.+ quotedMessageId: strclass SendAudioRequest(SendMediaRequest, total=False):@@ -329,14 +335,25 @@ class SendLocationRequest(TypedDict, total=False):longitude: floatdescription: straddress: str+ # Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ # matches the serialized message id, Baileys the raw key id of a message it has already stored.+ quotedMessageId: str-class SendContactRequest(TypedDict):+class _SendContactRequired(TypedDict):chatId: JidcontactName: strcontactNumber: str+# Split so the optional key can be added without loosening the three required ones — the same+# inheritance shape SendAudioRequest already uses.+class SendContactRequest(_SendContactRequired, total=False):+ # Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ # matches the serialized message id, Baileys the raw key id of a message it has already stored.+ quotedMessageId: str++class ReplyMessageRequest(TypedDict):chatId: JidquotedMessageId: str@@ -386,6 +403,9 @@ class SendPollRequest(TypedDict, total=False):# Options to vote on (WhatsApp allows between 2 and 12).options: list[str]allowMultipleAnswers: bool+ # Quote an earlier message, turning this send into a reply. Engine-specific: whatsapp-web.js+ # matches the serialized message id, Baileys the raw key id of a message it has already stored.+ quotedMessageId: str# ``from`` is a Python keyword, so use the functional TypedDict form.diff --git a/sdk/python/tests/test_sdk.py b/sdk/python/tests/test_sdk.pyindex 71707dcb4..1363c34ba 100644--- a/sdk/python/tests/test_sdk.py+++ b/sdk/python/tests/test_sdk.py@@ -192,6 +192,36 @@ class TestMessages:assert res["total"] == 1assert len(res["messages"]) == 1+ def test_quoted_message_id_reaches_the_body_on_every_send(self):+ # Asserted on the BODY, not the URL: a URL assertion cannot see a dropped key, and dropping+ # one is exactly how a client ends up 400ing while its four siblings work.+ backend = MockBackend()+ for route in ("send-text", "send-image", "send-location", "send-contact", "send-poll"):+ backend.on("POST", f"/{route}", body={"messageId": "m", "timestamp": 1})+ client = make_client(backend)++ client.messages.send_text("s", {"chatId": "[email protected]", "text": "hi", "quotedMessageId": "q1"})+ client.messages.send_image("s", {"chatId": "[email protected]", "url": "http://u", "quotedMessageId": "q1"})+ client.messages.send_location(+ "s", {"chatId": "[email protected]", "latitude": 1, "longitude": 2, "quotedMessageId": "q1"}+ )+ client.messages.send_contact(+ "s", {"chatId": "[email protected]", "contactName": "A", "contactNumber": "628", "quotedMessageId": "q1"}+ )+ client.messages.send_poll(+ "s", {"chatId": "[email protected]", "name": "Q", "options": ["a", "b"], "quotedMessageId": "q1"}+ )++ for call in backend.calls[-5:]:+ assert call.body["quotedMessageId"] == "q1", call.url++ def test_ordinary_send_carries_no_quote_key(self):+ # Known-negative control: without it an implementation that always emitted the key — as null,+ # which some clients drop and others send — would satisfy the assertion above.+ backend = MockBackend().on("POST", "/send-image", body={"messageId": "m", "timestamp": 1})+ make_client(backend).messages.send_image("s", {"chatId": "[email protected]", "url": "http://u"})+ assert "quotedMessageId" not in backend.calls[-1].body+def test_reply_forwardReactDelete(self):backend = MockBackend()backend.on("POST", "/reply", body={"messageId": "m", "timestamp": 1})