This guide proposes an integration architecture for PHP 7.4 and 8.x applications. The integration must be implemented and tested with your software and its specific version.
1. Keep credentials on the server
Request the environment URL, client_id and client_secret. Obtain a token with auth_api. The public documentation does not define the token header for subsequent calls: confirm it with support first.
2. Separate issuance from transmission
Use the invoice issuance event in your application to store a job linked to the invoice. A queue or cron worker submits the record so AEAT delays do not block the sales screen. Use your software’s extension points to keep the integration separate from its core.
3. Persist identifiers
Store the internal ID, invoice number, queueId and status. Use a unique constraint to prevent duplicate jobs for the same invoice. Do not rely on process memory for deduplication.
4. Verify the result
Process queries and authenticated webhooks. Review rejections and acceptance with errors. If submission returns no response, query by reference before retrying.
PHP authentication example
The downloadable example uses cURL with TLS verification, timeouts and JSON validation. It reads environment variables and makes no requests until you run it with your test environment configuration.
PHP · Authentication ↓