Trying to add the retainFlag gpio events

Brand ‘newbie’ here, looks like what I have been looking for for a while.

Topic is pretty well self explanatory exactly how to a set the retain flag and/or q flag on both simple and/or json messages?

Thanks in advance

It depends on your MQTT client, with MQTT explorer there is a check box for this:
image