For lawyers and agents: consulate or local notary with apostille, compared for the client’s country, with every step and the powers to name.
Plus a client letter.
Yes, where the country that issued it is a party to the Hague Apostille Convention. A public document issued in one of those states is accepted in Spain with an apostille, instead of consular legalisation. So the first thing to check is whether the country where you sign is a party to that convention, because the apostille route depends on it.