Home
Home
  1. Embeddable Widgets
  • Getting started
  • Authentication
  • Webhooks
  • Embeddable Widgets
    • Overview
    • Document Upload Widget
      • UI/UX Best Practices
  • Guides
    • Verifying a new business
    • Verifying bank accounts
    • Supported document types
  • API Reference
    • Submissions
      • Reports
        • List available report templates
        • Download a report
      • Create new submission
      • Get submission
      • Update submission
      • Update submission status
      • Run business verification
      • Get submission checks
      • Delete submission
    • Documents
      • Public Documents API
        • List documents
        • Upload document
        • Get document
        • Delete document
      • List documents
      • Upload document for submission
      • Get document
      • Delete document
      • Download document file
      • Rerun validations
    • RPC Search
      • Get company with ID
      • Company RFC Lookup
      • Company Name Search
      • Download document
    • Utilities
      • Matcher
        • Run name matching
  1. Embeddable Widgets

Document Upload Widget

Use the Document Upload Widget to collect important documents (PDF, JPG, PNG) from your end users. This page covers everything from basic usage to handling events and addressing common questions.

Overview#

The <niva-document-input> element behaves like a standard HTML <input>:
Dropzone or Click-to-Browse UI: Provides a drag-and-drop area for file selection.
Built-In Validation: Ensures files meet basic validation criteria like file size and file type, but also that it is the correct document type, recently issued, etc.
Minimal Configuration: You only need to provide public-token, submission-token, and any relevant attributes like name.
Embeddable document upload widget

Basic Usage#

Here’s the simplest way to place the Document Upload Widget in your HTML. Make sure you’ve completed the steps in Embeddable Widgets: Overview & Installation first (i.e., added the script tag and created a submission on your backend).

User Flow#

1.
Empty State
The widget shows a drag-and-drop area or “Browse files” link.
2.
Uploading State
After the user selects a file or drops it in, the widget displays “Uploading…” with a progress indicator.
3.
Success State
When the file is fully uploaded, the widget shows a success message. The component’s “value” now holds the document’s ID.
Success state
4.
Warning State
When the file fails a validation check with a "warning". A warning message is shown to the user, but the file is ultimately accepted.
Warning state
5.
Error State
When the file fails a validation check with a "fail" state, a failure message is displayed. This file is immediately deleted and not accepted.
Error state
When placed within a form, these states also interact with standard HTML validation (if required is specified).

Events & Callbacks#

The Niva Document Upload widget emits standard DOM events and supports callback function properties.

Available Events#

Event NameDescriptionDetail Payload
widget-initializedFired when the widget is loaded and ready to use{ documentType, files }
upload-startedFired when a file upload begins{ file }
successFired when a document is successfully uploaded and validated{ file }
delete-successFired when a document is successfully deleted{ file }
errorFired when any part of the process fails{ key, message, file, error? }

Error Types#

The error event includes a key property identifying the specific error type:
Error KeyDescription
invalid_api_keyProvided API key is invalid
invalid_tokenProvided submission token is invalid or expired
initialization_failedInitial loading of documents failed
file_size_too_bigFile exceeds the 50MB size limit
unsupported_file_typeFile type not supported (only JPG, PNG, PDF allowed)
upload_errorNetwork or server error during upload
document_incompleteDocument uploaded but incomplete
document_validation_failedDocument rejected by validation
deletion_failedFailed to delete a document

Basic Usage Example#

File Object Structure#

Event Flow#

A typical successful upload follows this sequence: widget-initialized → upload-started → success. If an error occurs at any stage, the error event is fired with the appropriate error key.

Handling Multiple Documents#

Each <niva-document-upload> widget accepts a single document type. You must add multiple widgets if you require differnet kinds of documents-one for each document type you require.
Optionally, if you allow multiple documents of the same document type (for example you accept multiple Acta Asamblea documents), you can specify the multiple attribute. The widget will then allow your user to upload multiple of the same document type, and will run validations against each one.
Example:

Accepted Files & Limits#

Accepted Types: PDF, PNG, JPG
Maximum File Size: 50MB per file
Document Validation: The widget handles smart instant validation of the document by checking if the correct document type was provided, that it is legible and complete and is associated with the correct business, among others. These validation rules are preconfigured for your account.

Custom Validations#

You can pass custom validation data to the widget which can be used to validate the document. Provide this to the component like so:
During normal validations, the name on the document will be matched against the business name in the submission. But when passing a custom name in the validation data, the name on the document must match the custom data ("Juan Pérez" in the example). Use this property to ensure the document is associated with a different entity, like a legal representative or shareholder.
Note: Currently only name-matching validations support custom data. Name-matching is only supported for mx_address_proof, mx_bank_statement, and mx_ine document types.

Component Properties#

AttributeTypeDescription
apiKeyStringRequired. Your public API key, safe to use on the frontend.
tokenStringRequired. The token obtained from your backend after creating a submission with your private token. Expires after 24 hours.
documentTypeStringRequired. This specifies the document type accepted by the widget. Refer to our list of supported document types.
nameStringOptional, but strongly recommended. Acts as the name for the form field.
requiredBooleanOptional. If present, the widget integrates with standard HTML5 form validation, preventing form submission if no valid file is uploaded.
disabledBooleanOptional. If present, widget will be disabled.
multipleBooleanOptional. If present, the widget will accept multiple documents of the same document type.
localeStringOptional. You can pass "en" or "es" to localize the widget’s built-in texts. Default: "en".
external_idStringOptional. User defined ID for the document
Previous
Overview
Next
UI/UX Best Practices