Absolutely. In fact, you're almost perfectly describing the JsonAPI standard for returning errors: https://jsonapi.org/format/#errors
One improvement I'd steal from theirs and drop in yours - constant (or enum) string codes. It's a lot more scannable when debugging/reviewing/maintaining than having to look up integer codes in a table.