Error format

Errors always have a message. Many also have a code: a stable identifier you can match in your code. Match on code, never on the wording of message.
A validation error (400) lists everything to fix:

Status codes

Error codes

Which errors to retry

Retry

Network errors and timeouts, 429, and 5xx. Use exponential backoff with jitter, and honour Retry-After. Send an idempotency key on writes.

Do not retry

400, 401, 403, 404, 409 and 422. The same request will fail the same way.