Generate PDF Job ================ Queue a PDF generation job and retrieve its status and result. Authentication -------------- Influxion uses OAuth2 Bearer tokens issued by its `/token` endpoint. First obtain a token: .. code-block:: http POST /token HTTP/1.1 Content-Type: application/json .. code-block:: json { "client_id": "", "client_secret": "", "scope": "api://d88ae758-e67d-492d-bcc6-63f560ee1f04/.default" } .. note:: The scope is optional. A default scope will be assigned if not provided, and it will allow access to all API endpoints. Response: .. code-block:: json { "access_token": "", "token_type": "bearer" } All subsequent API calls must include the ``Authorization`` header with value ``Bearer ``. Create a job ------------ Request: .. code-block:: http POST /pdf/generate HTTP/1.1 Authorization: Bearer Content-Type: application/json .. code-block:: json { "data": { /* structured data for template */ }, "document_id": "my-doc-123", "pdf_standard": "pdf/a-1b", "sign_key_id": "sign-key-id", "html_template": { "id": null, "filename": null, "content": "...{{ data }}..." }, "css_template": { "id": null, "filename": null, "content": "body { font-family: Arial; }" } } Response: .. code-block:: json { "job_id": 1 } Check job status ---------------- .. code-block:: http GET /pdf/1 HTTP/1.1 Authorization: Bearer Response: .. code-block:: json { "id": 1, "status": "Received", "created_at": "2023-01-01T12:00:00Z", "started_at": null, "completed_at": null, "size": null, "error": null } The status can be ``Received``, ``InProgress``, ``Done``, or ``Error``. Download PDF ------------ .. code-block:: http GET /pdf/1/download HTTP/1.1 Authorization: Bearer Response: Binary PDF (``Content-Type: application/pdf``) Using Celery background workers (Optional) ------------------------------------------ When setting up Influxion, one can connect it to a RabbitMQ and use Celery for background PDF generation: .. code-block:: bash pip install -e . export INFLUXION_USE_CELERY=1 export INFLUXION_CELERY_BROKER_URL=amqp://guest@localhost// export INFLUXION_CELERY_RESULT_BACKEND=rpc:// celery -A influxion.celery_app worker --loglevel=info This enables asynchronous PDF generation, allowing the API to respond immediately and several jobs to be processed concurrently.