Setup Capyflow CSV import step by step
Before integrate Capyflow, you must have a Capyflow account with an active subscription. You also have to setup your first schema and create an importer linked to this schema.
The Capyflow”s api URL is https://api.capyflow.com
1. Generate your API key
Look at the authentication page
2. Request API for an import attempt
When your user want to import a file, create an import attempt with a POST request at the following url
/api/import-attempts/
The body must be:
Field | Description |
---|---|
success_url | The url where the user is redirected after a successful import |
return_url | The url where the user is redirected when the import is cancelled |
importer_uuid | The importer uuid |
metadata | Metadata fields: {key_1:value, key_2:value} |
and the response is an import attempt object with the following structure:
Key | Description |
---|---|
id | The unique identifier for the import attempt |
importer | The importer associated with the import attempt |
schema | The schema used for the import attempt |
uuid | The unique identifier for the import attempt |
importer_uuid | The unique identifier for the importer |
url | The URL for the import attempt portal |
metadata | Metadata fields: {key_1:value, key_2:value} |
success_url | The URL where the user is redirected after a successful import |
return_url | The URL where the user is redirected when the import is cancelled |
state | The current state of the import attempt. More details import attempt |
created_at | The timestamp when the import attempt was created |
updated_at | The timestamp when the import attempt was last updated |
You now have to redirect your user to the url field value.
3. Prepare your backend webhook url
Capyflow will send a request to your webhook target url parametrized in your importer form in the dashboard. The request sent to your url is an import attempt object with a DATA_AVAILABLE state.
4. Pull the data
Use the importer_uuid value of the import attempt object sent to your webhook endpoint, to request the following paginated endpoint
/api/import-attempts/IMPORTER_UUID/pull/
The data, in the results field, is an array. Each items is a CSV row and have the structure of your schema (keys are the Internal name of your schema fields).
5. Finish the import
Once you pulled all your data, you can send a POST request to the
/api/import-attempts/IMPORTER_UUID/pull/finish/
endpoint in order to terminate the import attempt.
After that, the user is redirected to your success_url