HTTP responses, API responses and AEAT acceptance are separate levels. Store them separately so support can reconstruct what happened.
Queued does not mean accepted
An invoice submission may return success: true, status: pending and queueId. This confirms queue receipt. Save queueId and use check_docs with at most 20 records per request. The published reference recommends waiting 60–90 seconds before querying.
Statuses needing attention
Examples document sent and sent_warning. Read message too: acceptance with errors needs review and should not look like an issue-free result. The full catalogue depends on the version and assigned environment.
Not every 401 means an expired token
The current documentation shows 401 for both incorrect credentials and invalid invoice data. Check success and msg; endlessly retrying authentication will not fix a malformed invoice.
Handling interruptions
If a connection ends without a response, the submission may still have arrived. Recover status or query by reference before repeating it. Record attempts without logging secrets, complete card data or certificates.