[Bug]: Some payloads in Swagger give errors when testing.
Pre-flight
- [x] I searched existing issues and this isn't a duplicate
- [x] I'm on the latest released version (or noted my version below)
OpenWA version
0.13.1
Deployment
Docker Compose
Database
SQLite (default)
WhatsApp engine
whatsapp-web.js
What happened?
Hello, I encountered some errors while building using the Swagger API:
As per the attached request, this doesn't work at all and gives an error. The reason is the presence of the value:
"mentions": [
"[email protected]"
]
I removed it, and then the interface worked without any errors.
{
"chatId": "[email protected]",
"text": "Hello from OpenWA!",
"mentions": [
"[email protected]"
]
}
These values are either outdated, inactive, or haven't been updated by you.
After updating from version 0.10.1 to the current versions, I made some additions, including changing the connection source via the Swagger API.
As shown in the attached image, you should have added an option to add the connection server because now I'm getting the message: Failed to fetch.
Possible Reasons:
CORS Network Failure URL scheme must be "http" or "https" for CORS request.
This error appears even when I'm in production mode.
Steps to reproduce
1- Payload like this is work fine
{
"chatId": "[email protected]",
"text": "Hello from OpenWA!"
}
Expected behavior
No response
Relevant logs
Environment / additional context
No response
Thanks for reporting this — both halves turned out to be real, and both are fixed in v0.14.1.
The Swagger "Failed to fetch"
You were right that this appeared after upgrading, and right that the server was the problem. The spec declared a single server, http://{host}:{port}, whose defaults resolve to http://localhost:2785. Swagger UI aims "Try it out" at that first server rather than at the address you loaded the docs from — so on any other host or port it called your own machine. 0.10.1 declared no server at all, which is why it worked for you before.
The docs now list a relative server first, so Try-it targets whatever origin served the page. The {host}/{port} entry is still in the Servers dropdown if you want to point the docs at a different instance.
If you are on an older build, the workaround is that same dropdown: set host and port to the address you opened the docs on.
The payload with mentions
Here the cause was somewhere other than where it looked, and it is worth being precise because two separate bugs were involved.
mentions itself was fine. What failed was the chatId in the example — 628123456789 is a placeholder that is not a WhatsApp account, and whatsapp-web.js cannot resolve it. That produced a bare No LID for user from inside WhatsApp Web, which the gateway passed straight through as 500 Internal server error — no message, nothing to act on. Tested against a live session, a text send with mentions to a real number returns 201 normally.
Three fixes went in:
- Sending to a number WhatsApp cannot resolve now answers
400naming the recipient, instead of an empty 500. It says either the number is not on WhatsApp, or the session has no existing chat with it — the gateway genuinely cannot tell those apart, and the second case is an upstream whatsapp-web.js limitation. - A malformed
mentionsentry (a bare number, anything without a proper suffix) is now rejected with a400naming the field. Previously it reached WhatsApp Web's id parser and threw from minified code, so the log line was literallyt: t. - The Try-it body itself was broken in a way you would have hit next: since 0.14.0 it also carried
linkPreview: falsetogether with acustomLinkPreview, a combination the endpoint rejects, so every Execute returned400regardless of what you typed. Swagger UI builds that body from every field in the schema, not just the required ones. All the send routes now ship explicit examples — the media routes had the same problem, where the sampled body sent the literal string"string"instead of the example URL.
One note on the example
mentions is documented for group chats, and needs the @<number> token present in the text as well:
{ "chatId": "[email protected]", "text": "Hello @62811", "mentions": ["[email protected]"] }
That is now one of the two examples offered in the dropdown above the request body, alongside a plain text send.
Small correction on the version: there is no 0.10.1→0.13.1 — 0.13.0 was the release before this one. Nothing turns on it, just so the numbers line up if you compare.
Upgrade to v0.14.1 and both should be sorted. Please reopen if anything still misbehaves.