[GH-ISSUE #1119] Can Firebase and Cache be disabled via the JSON payload? #791

Closed
opened 2026-05-07 00:27:34 +02:00 by BreizhHardware · 6 comments

Originally created by @stendler on GitHub (May 26, 2024).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1119

Question

The documentation explains how to disable firebase or message caching via http request headers.
But these are not listed in the corresponding table on publishing via JSON.

Is this just missing from the documentation or not implemented?
If not implemented, could the JSON payload be paired with the request headers?

Is there a simple way to test this? The message payload does not seem to include any hint about how these properties were set.

Originally created by @stendler on GitHub (May 26, 2024). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1119 <!-- Before you submit, consider asking on Discord/Matrix instead. You'll usually get an answer sooner, and there are more people there to help! - Discord: https://discord.gg/cT7ECsZj9w - Matrix: https://matrix.to/#/#ntfy:matrix.org / https://matrix.to/#/#ntfy-space:matrix.org --> :question: **Question** <!-- Go ahead and ask your question here :) --> The documentation explains how to disable [firebase](https://docs.ntfy.sh/publish/#disable-firebase) or [message caching](https://docs.ntfy.sh/publish/#message-caching) via http request headers. But these are not listed in the corresponding table on [publishing via JSON](https://docs.ntfy.sh/publish/#publish-as-json). Is this just missing from the documentation or not implemented? If not implemented, could the JSON payload be paired with the request headers? Is there a simple way to test this? The message payload does not seem to include any hint about how these properties were set.
BreizhHardware 2026-05-07 00:27:34 +02:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@wunter8 commented on GitHub (May 26, 2024):

I'm pretty sure those parameters are not parsed in a JSON body (see github.com/binwiederhier/ntfy@9d3fc20e58/server/server.go (L1811)).

You can try including them, and if they're not supported, ntfy will reject the request as "invalid JSON".

You can also turn on debug logs on the server and see if things are written to the cache or forwarded to firebase

<!-- gh-comment-id:2132267643 --> @wunter8 commented on GitHub (May 26, 2024): I'm pretty sure those parameters are not parsed in a JSON body (see https://github.com/binwiederhier/ntfy/blob/9d3fc20e583564e40af5afb90233f4714fdfcb4c/server/server.go#L1811). You can try including them, and if they're not supported, ntfy will reject the request as "invalid JSON". You can also turn on debug logs on the server and see if things are written to the cache or forwarded to firebase
Author
Owner

@stendler commented on GitHub (May 26, 2024):

That's the right code, thank you!

So this looks like adding them via headers in addition to the JSON message payload should work.

You can try including them, and if they're not supported, ntfy will reject the request as "invalid JSON".

I did send messages against ntfy.sh with "firebase": "no" in the JSON payload, and it did not get rejected (or rather the notification went through - not sure if there was a response with an error message).

<!-- gh-comment-id:2132353008 --> @stendler commented on GitHub (May 26, 2024): That's the right code, thank you! So this looks like adding them via headers in addition to the JSON message payload should work. > You can try including them, and if they're not supported, ntfy will reject the request as "invalid JSON". I did send messages against ntfy.sh with `"firebase": "no"` in the JSON payload, and it did not get rejected (or rather the notification went through - not sure if there was a response with an error message).
Author
Owner

@wunter8 commented on GitHub (May 26, 2024):

So this looks like adding them via headers in addition to the JSON message payload should work.

Sorry, I missed this question. Yes, you can definitely combine JSON body and HTTP headers.

I just did a quick test, and a JSON body with "cache":"no" was not rejected by the ntfy server, BUT it was written to the cache. So "cache" (and I'm pretty sure "firebase") needs to be included as a header right now and not in the JSON body

<!-- gh-comment-id:2132426912 --> @wunter8 commented on GitHub (May 26, 2024): > So this looks like adding them via headers in addition to the JSON message payload should work. Sorry, I missed this question. Yes, you can definitely combine JSON body and HTTP headers. I just did a quick test, and a JSON body with `"cache":"no"` was not rejected by the ntfy server, BUT it _was_ written to the cache. So "cache" (and I'm pretty sure "firebase") needs to be included as a header right now and not in the JSON body
Author
Owner

@stendler commented on GitHub (May 29, 2024):

Thanks for confirming!

Now the question would be: should firebase and cache be added to the JSON functionality? Looking at the code, this seems straightforward to implement, and I would create a PR for this.

<!-- gh-comment-id:2137786578 --> @stendler commented on GitHub (May 29, 2024): Thanks for confirming! Now the question would be: *should* firebase and cache be added to the JSON functionality? Looking at the code, this seems straightforward to implement, and I would create a PR for this.
Author
Owner

@wunter8 commented on GitHub (May 29, 2024):

I'm not sure. I don't know what @binwiederhier's preferences are regarding fields in the JSON body vs fields in HTTP headers

<!-- gh-comment-id:2137796450 --> @wunter8 commented on GitHub (May 29, 2024): I'm not sure. I don't know what @binwiederhier's preferences are regarding fields in the JSON body vs fields in HTTP headers
Author
Owner

@stendler commented on GitHub (May 29, 2024):

I've implemented it and opened a PR as an exercise :)

Feel free to close it, if the feature is not desired. Though, I believe, since the JSON API is intended as a workaround for apps that make it difficult or impossible to define http headers, that this change just completes the API.

github.com/binwiederhier/ntfy@9d3fc20e58/docs/publish.md (L1082-L1084)

<!-- gh-comment-id:2138138072 --> @stendler commented on GitHub (May 29, 2024): I've implemented it and opened a PR as an exercise :) Feel free to close it, if the feature is not desired. Though, I believe, since the JSON API is intended as a workaround for apps that make it difficult or impossible to define http headers, that this change just completes the API. https://github.com/binwiederhier/ntfy/blob/9d3fc20e583564e40af5afb90233f4714fdfcb4c/docs/publish.md?plain=1#L1082-L1084
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#791
No description provided.