Let's do this properly and explain all the aspects you need to take into account when designing in capacitors on a mains-connected circuit.
First, there is the voltage rating. The voltage rating on a capacitor is of course a maximum DC (i.e. a peak) rating. For 50/60Hz mains we're talking about a sinusoidal voltage waveform with an RMS value of for instance 230V, so the DC peak value of such a supply is \$V_{rms} \cdot \sqrt{2}\$ or about 1.4 times this quoted value. If you're already dealing with a DC system, there is no math involved. The peak rating of your cap should be more than the peak DC voltage you expect over the device.
For longevity and nonlinear effects at high stresses, it is recommended to keep ample margin on these ratings, especially on the voltage rating. For 230VAC applications, even though typical you wouldn't expect more than about 325V peak over your lines, choose at least a 400V or better even a 450V capacitor. And yes, even when the manufacturer specifies survivability of the part at higher voltages. Survivability does not mean proper operation. It just means that it doesn't blow up and cause a mess.
The next important consideration is the location of your capacitor with respect to the mains net. Any capacitor that is directly connected across live (L) and neutral (N) on the mains lines is required to have self-healing properties in case of arc-over. Capacitors with this property are marked as X-class (X1, X2 denote different levels of this specification). For capacitors connected between either of the mains wires and earth, so between live (L) and earth (E), or between neutral (N) and earth (E) you are required to use a capacitor that will never fail short, as this can compromise protection earth safety. These capacitors are marked as Y class, with again Y1, Y2, etc. as different levels within this specification. Voltage ratings on these parts may not reflect what you would expect according to VDC=sqrt(2)*VAC. This is because DC and AC safety tests are conducted differently, and may cause different certified working voltages.
Any non-X/Y-class capacitor may never be directly connected to any of the mains lines. They need to be behind some kind of protection circuitry, at minimum a fuse or circuit breaker. Best practice is to implement a complete line filter (MOV, varistor/fusible resistor/fuse, common-mode filter, differential filter, optional rectifier).
Lastly, any non-X/Y rated capacitor needs to be checked if it is capable of handling the expected current ripple. Some technologies to get higher capacity at high voltage cause high ESR in this type of capacitor, which makes them unsuitable for e.g. SMPS usage.
I think this is all there is to it, let me know if I forgot something or borked up.