I'm studying Friedman and Susskind's Special Relativity and Classical Field Theory and follow them in using $c=1$.
They derive the above relation by first using Lagrangian of a free particle $\mathcal L=-m\sqrt{1-v^2}$ to show that conjugate momenta are given by $P^i = mU^i$ (where $U^\mu$ is the 4-velocity). Then they write out the Hamiltonian for the free particle using this Lagrangian and show that $H=mU^0$. Then writing $E$ for $H$ and since $U^\mu$ is a 4-vector and $m$ a scalar, they conclude that the quadruple $(E, P^1, P^2, P^3)$ forms a 4-vector. Then they use the invariance of the norm of the this 4-vector to show that $E^2 - P^2 = m^2$ (by observing the free particle in its rest frame, which is possible only since the particle was free to start with, otherwise there'd be no inertial frame in which the particle is seen at rest always).
Now the entire argument above was for a free particle. My question is whether the oft-used relation $E^2-P^2=m^2$ (or a modification thereof) also valid for a non-free particle (by which I mean a particle whole Lagrangian differs by that of a free particle).
Edit:
I realized (thanks to probably_someone in a comment below) that the original argument that the authors give is slightly different than mine. They multiply the equation $(U^0)^2-(U^i)^2 = 1$ with $m^2$ to yield $E^2-P^2=m^2$. Nevertheless, I still like my argument better. :)