#972 — Update application data after document upload and add an AI activity for the application update.

Repo: Twill-AI/facade State: closed | Status: done Assignee: meliascosta

Created: 2026-02-03 · Updated: 2026-02-25

Description

Context

Document uploads currently save the document and log document-related activities, but they do not automatically update the merchant application. Application updates are only triggered via the generate-application endpoint. We need to trigger application updates after upload and record a dedicated AI activity that includes document context.

Scope

  • Add a background trigger after successful document upload to generate/update the merchant application.
  • Extend activity logging for application updates to capture document-triggered context.

Acceptance Criteria

  1. Document upload endpoints:
    • /api/v1/partner/merchants/{merchant_id}/documents
    • /api/v1/master/partners/{partner_id}/merchants/{merchant_id}/documents After a successful document upload (and non-duplicate), a background task runs to update the application.
  2. The background task uses existing application generation logic (generate_merchant_application_from_documents) and updates the merchant via update_merchant.
  3. The upload response remains fast; application update runs asynchronously and does not block the upload response.
  4. The application update is skipped when skip_ai=true, when the document is a duplicate, or when AI classification is not available.
  5. A new activity is created for the application update initiated by document upload:
    • Uses an appropriate change type (existing or new, if needed).
    • Includes metadata that indicates the trigger source (document_upload)

Notes

Add implementation notes, blockers, and context here

Add wikilinks to related people, meetings, or other tickets