Prerequisite
The Headless API is a premium add-on to the Dromo Enterprise Plan, get in touch and we can get you ready to go! These limits help ensure service stability. For high-volume use cases, we recommend using webhooks instead of polling to avoid hitting rate limits.Using the Headless Importer
A headless import can be run either on a file or a JSON object. The steps below walk through the procedure for either type of import. You will need a saved schema to guide the import. For more information about saved schemas, check out the Schema Studio Guide or the Saved Schema API.Importing a File
1
Create a New Headless Import
The import process starts by creating a new headless import record. You will use this record ID to check the status of the import and retrieve the results.To create a headless import, use the create headless import endpoint.You must provide two things when creating the import:
- The ID of the saved schema you want to use
- The original filename of the file you want to import
Each headless import allows you to import only one file.
2
Upload the File
Once you’ve created the import record, Dromo will return an ID and a URL (in the
"upload"
field) where you can upload the file. Store the ID for later use (you need it to fetch the import status and results).To upload the file, make a PUT request to the URL, with the file as the body. Note that the upload URL is only valid for 30 minutes, so only create the import record when you are ready to upload the file.Here is an example request for uploading the file:3
Wait for the Import to Run
Dromo will automatically begin the import process once the upload is complete.
Importing a JSON Object
1
Create a New Headless Import
The import process starts by creating a new headless import record. You will use this record to check the status of the import and retrieve the results.To create a headless import, use the create headless import endpoint.You must provide two things when creating the import:
- The ID of the saved schema you want to use
- The complete JSON data
2
Wait for the Import to Run
Dromo will automatically begin the import process once the upload is complete.
Handling Import Results
You can query for the current import status using the retrieve headless import endpoint. The import status will be one of the following:AWAITING_UPLOAD
: The import record has been created, but the import file has not yet been uploaded.PENDING
: The import file has been received, and the import process will begin shortly.RUNNING
: The import process is currently running.SUCCESSFUL
: The import was successful and the result data is ready to be retrieved.NEEDS_REVIEW
: The import could not be completed due to data validation errors, and requires human attention.FAILED
: The import encountered a fatal error, and cannot be processed.
Successful import
If the import data did not have any issues, the import will be in theSUCCESSFUL
state.
You can be notified when an import completes in two ways:
-
Dashboard-configured webhooks (RECOMMENDED):
The recommended approach is to configure webhooks in the Dromo dashboard under the Webhooks section. This method provides several advantages:
- More reliable delivery with retry mechanisms
- Detailed event information
- Easier configuration and management
- Better security
- Legacy webhookUrl (DEPRECATED): If you define a legacy webhookUrl in your schema, it will still fire when the import completes successfully, but this method is deprecated and may be removed in the future.
SUCCESSFUL
, you can then retrieve the presigned URL using the headless import URL endpoint:
Remember that polling is subject to rate limits (12 requests per minute per
import). For production systems with many imports, webhooks are strongly
recommended to avoid hitting these limits.
Import needs review
If the import has issues that need manual review, the import will be in theNEEDS_REVIEW
state.
This can happen for several reasons:
- The header row could not be determined
- The columns could not be mapped automatically
- There are failing data validations, and invalidDataBehavior is set to
BLOCK_SUBMIT
NEEDS_REVIEW
state, the data returned by the retrieve headless import endpoint will include a "review_url"
field. This is a URL which you can navigate to in a browser to resolve the import issues using Dromo’s import UI.
After resolving the issues and completing the import, the import will transition to the SUCCESSFUL
state.
Import failed
An import will enter theFAILED
state if it has an unrecoverable error.
Some examples of unrecoverable errors are:
- The import file was corrupted and could not be parsed
- The import file was completely empty
- A custom hook threw an unhandled exception
Rate Limits
The Headless API has the following rate limits:- Creating headless imports: 20 requests per minute
- Polling import status: 12 requests per minute per import