# API Access
Source: https://fuse-docs.swovo.com/accessing-data/api-access
An overview of how to get import data from the Fuse API
The records associated with an Import can be retried from the API. There are two relevant API requests:
1. [List Imports](/apis/resources/imports/list-imports), to get a list of all Imports
2. [Import Records](/apis/resources/records/import-records), to get the records associated with a specific Import
To get notified when a new Import is available, use a [Status Webhook](/accessing-data/status-webhooks).
# Incognito Mode
Source: https://fuse-docs.swovo.com/accessing-data/incognito-mode
When Incognito mode is enabled on an importer, API and webhook access in unavailable, and records must be submitted to your backend using the onSubmit hook
You can send data to your backend using the `onSubmit` hook.
## `onSubmit(records)`
This hook is called when a user submits the importer. The `records` array passed to it contains all rows in the spreadsheet.
The `onSubmit` hook expects you to submit data to your backend in whatever way you want. You are passed a JS array of records, and expected to handle the submission to your API or backend from there.
This function must return an object with three properties:
1. `message`: (required) A success or error message to display to the user.
2. `errors`: (required): An object that specifies which rows a backend error occurred on. Please take a look at the examples below for how to pass backend errors back to the spreadsheet UI.
3. `recordsToDisplay`: (optional): By default, when backend errors are present, the importer will only display the records with errors. The importer assumes that all records that didn't have errors were imported successfully in your backend. There might be situations in which an error on one row prevents you from importing other rows (or, perhaps, all rows). The `recordsToDisplay` property allows you to specify which records/rows should still be shown to the user for re-import after any backend errors are fixed.
## Example: Handling a Successful Backend Import
If there were no backend errors, pass back an empty errors object and a message to show to the user like so:
```javascript theme={null}
importer.onSubmit = async (records) => {
// add code to submit records to backend here
const message = "Data imported successfully";
return {
message,
errors: {},
};
};
```
## Example: Handling Backend Errors
Each record passed to the `onSubmit` hook will have a unique identifier location under `record._meta.id`. In this case of a backend validation or error occurring, you can use this identified to tell the importer to show a relevant error message for each row with an error.
```javascript theme={null}
importer.onSubmit = async (records) => {
// add code to submit records to the backend here
const message = "Some records had errors during import. Please correct the errors and re-submit.";
return {
message,
recordsToDisplay: records, // add this if you want to show all records after an error occurs
errors: {
[records[0]._meta.id]: {
"email": "Email is already taken. Emails must be unique.",
"first_name": "First Name must be capitalized."
}
}
};
};
```
# Overview
Source: https://fuse-docs.swovo.com/accessing-data/overview
An overview of how to get data from Fuse into your own system
There are three ways to get data from Fuse into your system:
* **API (pull)**: Recommended for most use cases.
* **Record Webhooks (push)**: Recommended only when your system needs to support backend validations.
* **Incognito Mode (manual submission)**: If for some reason your organization is unable to send data to Fuse servers, you can turn on Incognito Mode and submit data using the onSubmit hook.
## **API Access**
For most situations, accessing import data [via the API](/accessing-data/api-access) is the best way to get data out of Fuse and into your own database.
API access can be used in conjunction with [Status Webhooks](/accessing-data/status-webhooks) to get into your system right after it has been uploaded.
## **Record Webhooks**
[Record Webhooks](/accessing-data/record-webhooks) are processed **in real time** as the user is submitting an import. Record Webhooks are the recommended method if your system needs to pass backend validation errors back to the importer. Note that Accepting large amounts of data by webhook can be more complex than pulling data into your system by API.
## **Incognito Mode**
[Incognito Mode](/accessing-data/incognito-mode) should only be used if your organization is unable to send data to Fuse servers (despite our exhaustive security efforts). When Incognito Mode is enabled, you can use the onSubmit hook to submit data directly to your servers, bypassing the submission to Fuse.
# Record Webhooks
Source: https://fuse-docs.swovo.com/accessing-data/record-webhooks
Record Webhooks send import data to your system in real-time
## Overview
Record Webhooks send import data to your system in batches in real-time.
Receiving large amounts of data by webhook can be more complex than pulling data from the Fuse API, so you should only use Record Webhooks if you need to show backend validation errors to the user during import.
Record Webhooks send data in **batches** of up to 1,000. An import with 10,000 records will have ten batches of records sent by webhook, each with 1,000 records.
## Record Webhook Flow
There are three steps that you need to set up to get Record Webhooks working properly.
### Step 1: Receive Batches
Fuse will send records to your webhook in **batches** of 1,000. The payload looks like this:
```javascript theme={null}
{
batch_slug: '77db4861-6205-4344-b234-2d3ca0f9439a',
import_slug: '960e938b-b3ac-4948-8713-ea84fdc72121',
batches_count: 10,
records: [],
complete: false,
metadata: {
// Object containing metadata related to the import session
}
}
```
Here is the definition of each key in the payload:
* **batch\_slug**: A unique identifier for the batch.
* **import\_slug**: A unique identifier for the import.
* **batches\_count**: The number of batches that will be sent.
* **records**: The records in the current batch.
* **complete**: The final batch sent will have this marked as true.
Your server should respond to batches within **5 seconds**. If you can process each batch in less than 5 seconds, you can give us an inline response telling us that the batch has been `completed` with any associated validation issues, as seen below.
```javascript theme={null}
{
batch: {
status: 'completed',
validation_issues: [{
record_slug: '8971a303-8989-4b43-bb0b-dadf48bbace3',
validation_type: 'error',
column_name: 'email',
issue_description: 'Email already exists and must be unique.'
}]
}
}
```
If your server might take longer than 5 seconds to process a batch, then you should process the batch in a background job and respond to our webhook telling us that the batch is still `processing`.
```javascript theme={null}
{
batch: {
status: "processing"
}
}
```
Here is the definition of each key in the response payload:
* **status**: Must be 'completed' if you have finished processing the batch, or 'processing' if, for example, you are processing the batch in a background job.
* **record\_slug**: The unique slug of the record.
* **validation\_type**: Must be 'warning' or 'error'.
* **column\_name**: The `internal_key` from the column in Fuse.
* **issue\_description**: A user-facing message to show the user.
### Step 2: Update Batch Status
If you responded with a status of `processing` to any batches in step 1, then you must update us once each batch has been `completed`.
You can send an HTTP request to Fuse to update the status of your batch.
```javascript theme={null}
PUT https://fuse.swovo.com/api/v1/webhooks/batches/:batch_slug
Headers:
- Authorization: Bearer {API_KEY_TOKEN}
Body:
{
batch: {
status: 'completed',
validation_issues: [{
record_slug: 2,
validation_type: 'error',
column_name: 'email',
issue_description: 'Email already exists and must be unique.'
}]
}
}
```
## Security
See [Webhook Security](https://fuse-docs.swovo.com/accessing-data/webhook-security) to verify record webhook requests.
# Status Webhooks
Source: https://fuse-docs.swovo.com/accessing-data/status-webhooks
Status Webhooks notify your server when new imports are available for consumption via the API.
## Overview
Status Webhooks are sent to your server when a new import has been processed and is available for consumption through the Fuse API.
To add a Status Webhook, go to the [Developers tab](https://fuse.swovo.com/account/developers) of your Fuse account.
## Request Format
Fuse sends Status Webhook to your servers when a new import is available
Here is the request format:
```
{
import_slug: '123-123-123-123',
status: 'completed'
}
```
## Security
See [Webhook Security](https://fuse-docs.swovo.com/accessing-data/webhook-security) to verify status webhook requests.
## Getting Import Data
You can [use the API](https://fuse-docs.swovo.com/apis/resources/records/import-records) to get the data for the new import.
# Webhook Security
Source: https://fuse-docs.swovo.com/accessing-data/webhook-security
Learn how to implement signature verification for secure communication with webhooks
When creating webhooks, you have the option to provide a secret key for added security. This secret key is used to generate a signature for each outgoing payload. To ensure the integrity of incoming webhook payloads, you can validate the signature on your server.
To add a Webhook, go to the [Developers tab](https://fuse.swovo.com/account/developers) of your Fuse account.
## Providing a Secret Key
When creating or configuring a webhook, include a secret key in the webhook settings. This key is a shared secret between our server and the recipient of the webhook.
## Signature Generation
The signature is generated using the HMAC (Hash-based Message Authentication Code) algorithm with SHA-256. The process involves creating a hexdigest using the secret key and the raw payload of the webhook.
## Signature Verification
To validate the incoming webhook payload, you need to generate the signature on your end using the same process and compare it with the signature provided in the incoming request.
### Example Code
Below are samples for HTTP requests that handle the signature verifcation process.
```typescript Node.js (Nest.js / Express.js) theme={null}
import * as crypto from "crypto";
function validateSignature(
secretKey: string,
rawPayload: string,
receivedSignature: string
): boolean {
const expectedSignature = crypto
.createHmac("sha256", secretKey)
.update(rawPayload)
.digest("hex");
return receivedSignature === expectedSignature;
}
app.post("/webhook", (req, res) => {
// Retrieve the signature from the headers
const receivedSignature = req.headers["http_x_fuse_signature_256"];
const secretKey = "your_secret_key";
const isSignatureEqual = validateSignature(
secretKey,
JSON.stringify(req.body),
receivedSignature
);
// Compare the signatures
if (!isSignatureEqual) {
return res.status(401).send("Mismatched signatures");
}
// Process the webhook payload
// ...
res.status(200).send({ status: "complete" });
});
```
```ruby Ruby theme={null}
require 'openssl'
class WebhookController < ApplicationController
skip_before_action :verify_authenticity_token
def validate_signature(secret_key, raw_payload, received_signature)
expected_signature = OpenSSL::HMAC.hexdigest(
OpenSSL::Digest.new('sha256'),
secret_key,
raw_payload
)
received_signature == expected_signature
end
def webhook
received_signature = request.headers['HTTP_X_FUSE_SIGNATURE_256']
secret_key = 'your_secret_key'
is_signature_equal = validate_signature(secret_key, request.raw_post, received_signature)
unless is_signature_equal
return render json: { error: 'Mismatched signatures' }, status: :unauthorized
end
# Process the webhook payload
# ...
render json: { status: 'complete' }
end
end
```
```php PHP (Laravel) theme={null}
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Hash;
class WebhookController extends Controller
{
function validateSignature($secretKey, $rawPayload, $receivedSignature) {
$expectedSignature = Hash::hmac('sha256', $rawPayload, $secretKey);
return hash_equals($expectedSignature, $receivedSignature);
}
public function webhook(Request $request)
{
$receivedSignature = $request->header('http_x_fuse_signature_256');
$secretKey = 'your_secret_key';
$isSignatureEqual = $this->validateSignature($secretKey, $request->getContent(), $receivedSignature);
if (!$isSignatureEqual) {
return response()->json(['error' => 'Mismatched signatures'], 401);
}
// Process the webhook payload
// ...
return response()->json(['status' => 'complete']);
}
}
```
```python Python theme={null}
from flask import Flask, request, jsonify
import hashlib
import hmac
def validate_signature(secret_key, raw_payload, received_signature):
expected_signature = hmac.new(secret_key.encode('utf-8'), raw_payload.encode('utf-8'), hashlib.sha256).hexdigest()
return received_signature == expected_signature
@app.route('/webhook', methods=['POST'])
def webhook():
received_signature = request.headers.get('HTTP_X_FUSE_SIGNATURE_256')
secret_key = 'your_secret_key'
is_signature_equal = validate_signature(secret_key, request.get_data(), received_signature)
if not is_signature_equal:
return 'Mismatched signatures', 401
# Process the webhook payload
# ...
return jsonify({'status': 'complete'})
```
```java Java (Spring boot) theme={null}
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class WebhookController {
public static boolean validateSignature(String secretKey, String rawPayload, String receivedSignature) {
try {
Mac hmac = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKey = new SecretKeySpec(secretKey.getBytes(), "HmacSHA256");
hmac.init(secretKey);
byte[] hashBytes = hmac.doFinal(rawPayload.getBytes());
String expectedSignature = bytesToHex(hashBytes);
return receivedSignature.equals(expectedSignature);
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace(); // Handle the exception according to your needs
return false;
}
}
private static String bytesToHex(byte[] bytes) {
StringBuilder hexStringBuilder = new StringBuilder();
for (byte b : bytes) {
hexStringBuilder.append(String.format("%02x", b));
}
return hexStringBuilder.toString();
}
@PostMapping("/webhook")
public ResponseEntity> webhook(@RequestBody String requestBody, @RequestHeader("http_x_fuse_signature_256") String receivedSignature) {
String secretKey = "your_secret_key";
boolean isSignatureEqual = validateSignature(secretKey, requestBody, receivedSignature);
if (!isSignatureEqual) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Mismatched signatures");
}
// Process the webhook payload
// ...
return ResponseEntity.ok().body("{\"status\": \"complete\"}");
}
}
```
```cs C# theme={null}
using Microsoft.AspNetCore.Mvc;
using System.Security.Cryptography;
using System.Text;
public class WebhookController
{
public static bool ValidateSignature(string secretKey, string rawPayload, string receivedSignature)
{
using (var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secretKey)))
{
var expectedSignature = BitConverter.ToString(hmac.ComputeHash(Encoding.UTF8.GetBytes(rawPayload))).Replace("-", "").ToLower();
return receivedSignature == expectedSignature;
}
}
[HttpPost("/webhook")]
public IActionResult Webhook([FromBody] string requestBody, [FromHeader(Name = "HTTP_X_FUSE_SIGNATURE_256")] string receivedSignature)
{
string secretKey = "your_secret_key";
bool isSignatureEqual = ValidateSignature(secretKey, requestBody, receivedSignature);
if (!isSignatureEqual)
{
return Unauthorized("Mismatched signatures");
}
// Process the webhook payload
// ...
return Ok(new { status = "complete" });
}
}
```
# Authentication
Source: https://fuse-docs.swovo.com/apis/authentication
How to authenticate with the Fuse API
To access the Fuse API, you need to [create an API key](https://fuse.swovo.com/account/developers) in the Developers section of your account.
In each request you send to Fuse, you should send an API key from your account using [Bearer Authentication](https://swagger.io/docs/specification/authentication/bearer-authentication/).
To do this, include the following header in your requests:
```
Authorization: Bearer
```
# Pagination
Source: https://fuse-docs.swovo.com/apis/pagination
How pagination works in the Fuse API
Pagination endpoints come with a `pagination` payload. The payload contains various pieces of metadata about the resource:
* **current**: The current page
* **previous**: The previous page
* **next**: The next page
* **limit**: The maximum records per page
* **total\_pages**: The total numbers of pages
* **total\_count**: The total number of records
## Example
```
{
"data": [
// an array of the resource you are accessing
],
"paginiation": {
"current": 1,
"previous": null,
"next": 2,
"limit": 100,
"total_pages": 1000,
"total_count": 10000
}
}
```
# Create Session
Source: https://fuse-docs.swovo.com/apis/resources/import-session
post /api/v1/importer/sessions
Use this endpoint to generate an importer session token based on an importer slug. The session token should be used as part of creating a fuse importer instance.
# Retrieves a specific import
Source: https://fuse-docs.swovo.com/apis/resources/imports/get-import
get /api/v1/imports/{import_slug}
Get details of a specific import by ID.
# List Imports
Source: https://fuse-docs.swovo.com/apis/resources/imports/list-imports
get /api/v1/imports
# Import Records
Source: https://fuse-docs.swovo.com/apis/resources/records/import-records
get /api/v1/imports/{import_slug}/records
# Custom Theming
Source: https://fuse-docs.swovo.com/appearance/custom-theming
Customize the appearance of your Fuse Importer with colors and logos.
Custom theming is available for users with plans that include style
customization features.
Customize the Fuse Importer's appearance to match your brand's visual identity using the `setCustomStyles` method. This method **overrides Fuse's default theme**, allowing you to selectively customize specific colors and styles.
Using `setCustomStyles` will override any styles configured inside your [Fuse
account](https://fuse.swovo.com/account/importer-style-preferences).
## Basic Usage
```javascript theme={null}
const importer = new FuseImporter();
// Override only the colors to customize
// This will replace styles defined with your Fuse account
importer.setCustomStyles({
colors: {
primaryColor: "#3F51B5", // Only override primary color, keep other defaults
},
logoURL: "https://yourdomain.com/logo.png",
});
importer.show();
```
## Customization Options
### Colors
Override any combination of these color properties. Colors that are not defined will fall back to Fuse's default theme values.
```javascript theme={null}
importer.setCustomStyles({
colors: {
primaryColor: "#3F51B5", // Primary brand color
secondaryColor: "#FF4081", // Secondary accent color (buttons, highlights)
backgroundColor: "#F5F5F5", // Main background color
borderColor: "#E0E0E0", // Border and divider colors
contentColor: "#FFFFFF", // background color for selected areas
},
});
```
**Supported formats:** Hex (`#3F51B5`), RGB (`rgb(63, 81, 181)`), HSL (`hsl(231, 48%, 48%)`), named colors (`blue`)
### Logo
```javascript theme={null}
importer.setCustomStyles({
logoURL: "https://yourdomain.com/logo.png",
});
```
**Requirements:** PNG/JPG format
## Troubleshooting
Before applying your custom styles, the Fuse Importer runs a validation check. If any issues are found, the styles will be ignored and you'll see error messages in the browser console starting with:
**"Error on custom styles validation:"**
**Common validation errors include:**
* **Invalid color format** – Ensure all colors use valid CSS values (e.g., hex, RGB, HSL, or named colors).
* **Invalid URL format** – Logo URLs must be correctly formatted and valid.
If your custom styles aren’t appearing, open the browser console and look for messages beginning with **"Error on custom styles validation:"** to identify and resolve the issue.
# Using Modals
Source: https://fuse-docs.swovo.com/appearance/modals
How to display your importer in a modal.
Fuse has built-in support for launching the importer within a modal. Simply pass the `modal: true` option when you instantiate your importer.
```javascript theme={null}
const importerOptions = {
modal: true
};
const importer = new FuseImporter({ options: importerOptions });
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
importer.show();
```
# White Labeling
Source: https://fuse-docs.swovo.com/appearance/white-labeling
Guidance on customizing your importer.
You can white-label the importer from inside your Fuse account. Visit the [branding](https://fuse.swovo.com/account/importer-style-preferences) tab.
# Creating Column Types
Source: https://fuse-docs.swovo.com/extending/creating-your-own-column-type
Defining your own column type in Fuse.
If the built-in column types are not enough, you can define your own data structure using the String column. You do this through the use of `onValidateRecord`. You simply need to validate that the value passed to `onValidateRecord` matches your desired format.
## Example of Creating a "Currency" Column
```javascript theme={null}
// matches formats like $10
const currencyRegex = /\$[0-9]*/;
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
importer.addColumn({
internal_key: "total_charge",
label: "Total Charge",
column_type: "string",
required: true,
position: 1,
unique: true,
});
importer.onValidateRecord = async (record) => {
const errors = {};
const warnings = {};
// make sure the total charge matches the regex
if (!record.total_charge?.match(currencyRegex)) {
errors["total_charge"] =
"Total charge must be a dollar amount matching the format $xx";
}
return {
errors: errors,
warnings: warnings,
};
};
importer.show();
```
# Defining Custom Actions
Source: https://fuse-docs.swovo.com/extending/custom-actions
Fuse allows developers to define custom bulk actions.
Developers can add bulk action functionality to the importer using Custom Actions. See the preview below for an example.
## addCustomAction
The `addCustomAction` function accepts an object as an argument with the following properties:
* `action_type` (String) - required: Currently must be set to "record".
* `name` (String) - required: A succinct description of the action.
* `handler` (Function) - required: A function that takes a `record` and manipulates it when the action is performed.
Custom actions are hidden in the UI until you select a row in the spreadsheet.
## Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
importer.addCustomAction({
actionType: "record",
name: "Generate ID",
handler: (record) => {
record['id'] = Math.random();
return record;
}
});
importer.show();
```
## Preview
What a custom action called "Generate ID" would look like.
# Adding Columns
Source: https://fuse-docs.swovo.com/getting-started/adding-columns
Columns define data types, and support validations and transformations.
You can add a column in two different ways:
1. Through [your Fuse account](https://fuse.swovo.com/account/importers).
2. In code, using the `addColumn` function.
To add columns in code, see the documentation for a specific column type. See [String Column](/using-columns/string-columns/) for example.
# Adding Transformations
Source: https://fuse-docs.swovo.com/getting-started/adding-data-transformations
Transformations allow you to format data and manipulate schemas.
Each column type in Fuse has built-in transformations available. You refer to the documentation of a specific column type to see the available options.
When the built-in transformations are not enough for you, you can create your own custom data transformations using the `formatRecord` hook.
## `formatRecord(record)`
The `formatRecord` hook is called for every row in the importer. It allows you to auto-format, correct issues, and more.
Here are some samples of things you might want to do with this hook:
* Combine "first\_name" and "last\_name" into a "full\_name" column.
* Capitalize all of the values in a column.
* Prepend "https\://" to all of the URLs in a column.
The `record` passed to this hook is an object that represents a single row in the importer. You can access the properties of the record using the `internal_key` of each column.
## Example
```javascript theme={null}
importer.formatRecord = (record) => {
const newRecord = { ...record };
// capitalize the first letter in first_name
if (typeof newRecord.first_name === "string") {
newRecord.first_name =
newRecord.first_name.charAt(0).toUpperCase() +
newRecord.first_name.slice(1);
}
return newRecord;
};
```
# Adding Validations
Source: https://fuse-docs.swovo.com/getting-started/adding-data-validations
Validations allow you to provide error or warning messages to users when data is improperly formatted.
Each column type in Fuse has built-in validations. You refer to the documentation of a specific column type to see the available options.
When the built-in data validations are insufficient, you can create custom front-end data validations using the `onValidateRecord` hook on your importer.
## `onValidateRecord(record)`
The `onValidationRecord` hook is called for each row (record) in the importer. It allows you to display front-end validations in the importer for the user to fix.
The `record` object passed to `onValidateRecord` contains all of the values for a single row in the importer. You can access values in the record object using the `internal_key `of each column in your importer.
The `onValidateRecord` hook returns an errors object with two properties:
* `errors` block the user from submitting an import. These are items that must be fixed.
* `warnings` provide a warning message to the user about potential issues. However, a user can submit an import with warnings present.
## Example
```javascript theme={null}
importer.onValidateRecord = async (record) => {
const errors = {};
const warnings = {};
// force emails to include gmail
if (!record.email?.includes("gmail")) {
errors["email"] = "Email must from gmail";
}
return {
errors: errors,
warnings: warnings,
};
};
```
# Embedding Fuse
Source: https://fuse-docs.swovo.com/getting-started/embedding
Install our NPM package on your website.
Embedding Fuse in your website is simple. There are two steps:
1. Add the [fuse-importer NPM package](#adding-the-npm-package) to your application.
2. Add a small [JavaScript snippet](#launching-an-importer) to open your Fuse importer.
## Adding the NPM Package
To add Fuse, do:
```bash theme={null}
yarn add fuse-importer
```
To import it for use:
```typescript theme={null}
import FuseImporter from "fuse-importer";
```
To add Fuse, do:
```bash theme={null}
npm install fuse-importer --save
```
To import it for use:
```typescript theme={null}
import FuseImporter from "fuse-importer";
```
Fuse is also hosted on the [unpkg.com](https://unpkg.com/) CDN. Make sure to place the script tag before you initialize the importer.
```html theme={null}
```
## Launching an Importer
The `show` function does exactly what it sounds like; it displays the importer. Ensure you have initialized the importer properly beforehand. Use this function like so:
```javascript theme={null}
import FuseImporter, { getFuseClientSideToken } from 'fuse-importer';
// Initialize the importer
const importer = new FuseImporter();
// See https://fuse-docs.swovo.com/getting-started/sessions
importer.getSessionToken = getFuseClientSideToken({
importer_slug: 'YOUR_IMPORTER_SLUG',
api_key: 'YOUR_API_KEY'
});
importer.show();
```
```html theme={null}
```
```javascript theme={null}
import React from 'react';
import FuseImporter, { getFuseClientSideToken } from 'fuse-importer';
const App = () => {
const importer = new FuseImporter();
// See https://fuse-docs.swovo.com/getting-started/sessions
importer.getSessionToken = getFuseClientSideToken({
importer_slug: 'YOUR_IMPORTER_SLUG',
api_key: 'YOUR_API_KEY'
});
const showImporter = () => {
importer.show();
};
return (
);
};
export default App;
```
```typescript theme={null}
import { Component } from '@angular/core';
import FuseImporter, { getFuseClientSideToken } from 'fuse-importer';
@Component({
selector: 'app-root',
template: ``,
})
export class AppComponent {
showImporter() {
const importer = new FuseImporter();
// See https://fuse-docs.swovo.com/getting-started/sessions
importer.getSessionToken = getFuseClientSideToken({
importer_slug: 'YOUR_IMPORTER_SLUG',
api_key: 'YOUR_API_KEY'
});
importer.show();
}
}
```
```javascript theme={null}
```
# Overview
Source: https://fuse-docs.swovo.com/getting-started/overview
Get started setting up an Importer on Fuse.
To get up and running with Fuse, you should:
1. [Create an Importer](/getting-started/creating-an-importer) with columns, validations, and transformations.
2. [Embed your importer](/getting-started/embedding) or invite team members to use the Importer directly through Fuse.
3. [Access imported data](/accessing-data/overview) via the API or webhook.
# Sessions
Source: https://fuse-docs.swovo.com/getting-started/sessions
## **Sessions**
### Overview
A **session** in Fuse allows you to launch the importer by generating a session token. You can store metadata such as user IDs inside of a session so that when you retrieve imports from the Fuse API, you know which user in your system to associate them with.
Depending on your needs, you can choose between two options:
1. **Client-Side Sessions**: A simpler method that generates the session token directly in the frontend, though it exposes your API key and should only be used in trusted or testing environments.
2. **Server-Side Sessions**: The most secure method, as it prevents exposing sensitive data by handling session token generation on your backend.
### Client-Side Session
This option is simpler but less secure, as it involves exposing your API key in the frontend. It should only be used in testing environments or trusted internal tools.
**Steps:**
1. **Implement `getSessionToken`**: Directly generate the session token using the Fuse client-side token function and pass it to the importer.
#### Frontend Code Sample
```javascript theme={null}
import FuseImporter, { getFuseClientSideToken } from 'fuse-importer';
const importer = new FuseImporter();
importer.getSessionToken = getFuseClientSideToken({
importer_slug: 'YOUR_IMPORTER_SLUG',
api_key: 'YOUR_API_KEY'
});
importer.show();
```
```javascript theme={null}
import FuseImporter, { getFuseClientSideToken } from 'fuse-importer';
import React from 'react';
const App = () => {
const importer = new FuseImporter();
importer.getSessionToken = getFuseClientSideToken({
importer_slug: 'YOUR_IMPORTER_SLUG',
api_key: 'YOUR_API_KEY'
});
const showImporter = () => {
importer.show();
};
return (
);
};
export default App;
```
```vue theme={null}
```
```typescript theme={null}
import { Component } from '@angular/core';
import FuseImporter, { getFuseClientSideToken } from 'fuse-importer';
@Component({
selector: 'app-importer',
template: ``
})
export class ImporterComponent {
showImporter() {
const importer = new FuseImporter();
importer.getSessionToken = getFuseClientSideToken({
importer_slug: 'YOUR_IMPORTER_SLUG',
api_key: 'YOUR_API_KEY'
});
importer.show();
}
}
```
### Server-Side Sessions
This is the recommended approach for production environments, as it securely handles session token generation on your backend, keeping sensitive information safe.
**Steps**
1. **Add an API Endpoint**: Create an endpoint on your server that calls the [Session API](/apis/resources/import-session) to generate session tokens using an API key [from your account](https://fuse.swovo.com/account/developers).
2. **Implement `getSessionToken`**: In your frontend, implement `getSessionToken` to request the session token from your server's API endpoint and use it to launch the importer.
#### Backend Code Sample
```javascript theme={null}
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json());
app.post('/api/getSessionToken', async (req, res) => {
const { importerSlug } = req.body;
const metadata = { user_id: 123 };
try {
const response = await axios.post('https://fuse.swovo.com/api/v1/importer/sessions', {
importer_slug: importerSlug,
metadata: metadata
}, {
headers: { 'Authorization': `Bearer YOUR_API_TOKEN` }
});
res.json({ token: response.data.token });
} catch (error) {
res.status(500).json({ error: 'Failed to get session token' });
}
});
app.listen(3000, () => console.log('Server running on port 3000'));
```
```ruby theme={null}
require 'sinatra'
require 'net/http'
require 'json'
post '/api/getSessionToken' do
content_type :json
request_body = JSON.parse(request.body.read)
importer_slug = request_body['importerSlug']
metadata = { user_id: 123 }
uri = URI('https://fuse.swovo.com/api/v1/importer/sessions')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, { 'Authorization' => 'Bearer YOUR_API_TOKEN', 'Content-Type' => 'application/json' })
request.body = { importer_slug: importerSlug, metadata: metadata }.to_json
response = http.request(request)
if response.code == '200'
{ token: JSON.parse(response.body)['token'] }.to_json
else
status 500
{ error: 'Failed to get session token' }.to_json
end
end
```
```python theme={null}
from flask import Flask, request, jsonify
import requests
app = Flask(__name__)
@app.route('/api/getSessionToken', methods=['POST'])
def get_session_token():
data = request.json
importer_slug = data.get('importerSlug')
metadata = { 'user_id': 123 }
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
payload = {
'importer_slug': importer_slug,
'metadata': metadata
}
try:
response = requests.post('https://fuse.swovo.com/api/v1/importer/sessions', json=payload, headers=headers)
return jsonify({'token': response.json().get('token')})
except requests.exceptions.RequestException as e:
return jsonify({'error': 'Failed to get session token'}), 500
if __name__ == '__main__':
app.run(port=3000)
```
```java theme={null}
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
@RestController
public class SessionController {
@PostMapping("/api/getSessionToken")
public Map getSessionToken(@RequestBody Map requestBody) {
String importerSlug = (String) requestBody.get("importerSlug");
Map metadata = new HashMap<>();
metadata.put("user_id", 123);
RestTemplate restTemplate = new RestTemplate();
String url = "https://fuse.swovo.com/api/v1/importer/sessions";
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer YOUR_API_TOKEN");
Map body = new HashMap<>();
body.put("importer_slug", importerSlug);
body.put("metadata", metadata);
HttpEntity
```php theme={null}
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
Route::post('/api/getSessionToken', function (Request $request) {
$importerSlug = $request->input('importerSlug');
$metadata = [ 'user_id' => 123 ];
$response = Http::withHeaders([
'Authorization' => 'Bearer YOUR_API_TOKEN',
])->post('https://fuse.swovo.com/api/v1/importer/sessions', [
'importer_slug' => $importerSlug,
'metadata' => $metadata,
]);
if ($response->successful()) {
return response()->json(['token' => $response['token']]);
} else {
return response()->json(['error' => 'Failed to get session token'], 500);
}
});
```
#### Frontend Code Sample
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = async () => {
const response = await fetch('/api/getSessionToken', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
});
const data = await response.json();
return data.token;
};
importer.show();
```
```javascript theme={null}
import FuseImporter from 'fuse-importer';
import React from 'react';
const App = () => {
const importer = new FuseImporter();
importer.getSessionToken = async () => {
const response = await fetch('/api/getSessionToken', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
});
const data = await response.json();
return data.token;
};
const showImporter = () => {
importer.show();
};
return (
);
};
export default App;
```
```vue theme={null}
```
```typescript theme={null}
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import FuseImporter from 'fuse-importer';
@Component({
selector: 'app-importer',
template: ``
})
export class ImporterComponent {
constructor(private http: HttpClient) {}
getSessionToken() {
return this.http.post('/api/getSessionToken', {
importerSlug: 'YOUR_IMPORTER_SLUG',
metadata: {}
}).toPromise().then((res: any) => res.token);
}
showImporter() {
const importer = new FuseImporter();
importer.getSessionToken = this.getSessionToken.bind(this);
importer.show();
}
}
```
# Angular CSV Importer
Source: https://fuse-docs.swovo.com/js-implementations/angular-csv-importer
How to implement an Angular CSV Importer
Below is some sample Angular code to get you started with our CSV Importer. Be sure to insert your own Organization's API key and an Importer ID from your account. You can find them on the [Importers](https://fuse.swovo.com/account/importers) page.
```typescript theme={null}
import { Component } from "@angular/core";
import FuseImporter from "fuse-importer";
@Component({
selector: "app-root",
template: '',
})
export class AppComponent {
public showImporter() {
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
importer.onSubmit = async (records) => {
return {
message: "Data imported successfully",
errors: {},
};
};
importer.onValidateRecord = async (record) => {
return { errors: {}, warnings: {} };
};
importer.show();
}
}
```
# React CSV Importer
Source: https://fuse-docs.swovo.com/js-implementations/react-csv-importer
How to implement a React CSV Importer
Below is some sample React code. Be sure to insert your own Organization's API key and an Importer ID from your account. They can be found on the [Importers](https://fuse.swovo.com/account/importers) page.
> **Note for Next.js users:** This code can be used for Next.js versions lower than 14. For Next.js versions 14 and 15, add `"use client"` to the first line of the file.
```typescript theme={null}
import FuseImporter from "fuse-importer";
import React from "react";
const App = () => {
const showImporter = () => {
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
importer.onSubmit = async (records) => {
return {
message: "Data imported successfully",
errors: {}
};
};
importer.onValidateRecord = async (record) => {
return { errors: {}, warnings: {} };
};
importer.show();
};
return (
<>
>
);
};
export default App;
```
# Vue.js CSV Importer
Source: https://fuse-docs.swovo.com/js-implementations/vue.js-csv-importer
How to implement a Vue.js CSV Importer.
Below is some sample Vue.js code to get you started with our CSV Importer. Be sure to insert your own Organization's API key and an Importer ID from your account. You can find them on the [Importers](https://fuse.swovo.com/account/importers) page of your account.
```html theme={null}
```
# Translations (i18n)
Source: https://fuse-docs.swovo.com/more-to-love/translations-i18n
Guide to using other languages.
Fuse has official support for the following languages:
* German
* French
* Spanish
* English
* Italian
When you launch your importer, it will automatically load the language of the browser. For example, if your browser is set to Spanish, it will load in Spanish.
# Bulk Editing
Source: https://fuse-docs.swovo.com/use-cases/bulk-editing
How to use Fuse as a bulk editing tool.
The spreadsheet UI Fuse can be used to edit data in bulk. All of the functionality in Fuse outside of uploading and transforming CSV files is useful for bulk editing, including:
* Front-end Data Validations
* Back-end Data Validations
* Data Transformations
* Bulk Actions
* and more.
To use Fuse as a bulk editing tool, set the `records` property on your importer before launching it. This will force the importer to skip the CSV file upload process and allow the user to edit the records.
```javascript theme={null}
const options = {
records: [
{ name: "Mike", email: "mike@email.com" },
{ name: "Sandra", email: "sandra@mail.com" },
],
};
const importer = new FuseImporter(apiToken, templateSlug, { ...options });
// add columns, validations, and transformations here
importer.show();
```
## Preview
# CSV Imports
Source: https://fuse-docs.swovo.com/use-cases/csv-imports
How to use Fuse for importing CSV files.
Importing CSV files is the default use case for Fuse. There is no special configuration needed if you are using Fuse for importing CSV files. Simply [launch your importer](/getting-started/embedding#launching-an-importer), and the user will be prompted to import a CSV file.
## Preview
# Boolean Columns
Source: https://fuse-docs.swovo.com/using-columns/boolean-columns
How to add a boolean column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The Boolean column accepts "true" and "false" as values. It supports functionalities such as:
* Auto-transform 0/1 to true/false
* Auto-transform No/yes to true/false
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "boolean".
* `required` (String) - required: Whether or not the column is required.
* `position` (Optional): The position or order of the column.
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
importer.addColumn({
internal_key: "my_boolean",
label: "My Boolean",
column_type: "boolean",
required: true,
position: 1,
});
importer.show();
```
# Date Columns
Source: https://fuse-docs.swovo.com/using-columns/date-columns
How to add a date column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The Date column type validates that input is of a specific date format.
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "date".
* `required` (String) - required: Whether or not the column is required.
* `pattern` (String) - required: Must be one of [these patterns](#patterns).
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See [Built-in Date Validations](#built-in-date-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in Date Transformations](#built-in-date-transformations).
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const validations = [
{
validation_type: "before_date",
message: "Must be before 01/01/2023",
options: {
before_date: "2023-01-01T00:00:00.000Z",
},
},
];
const transformations = [
{
transformation_type: "autoformat",
},
];
importer.addColumn({
internal_key: "date",
label: "Date",
column_type: "date",
pattern: "MM/dd/yyyy",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"date">[] = [
{
validation_type: "before_date",
message: "Must be before 01/01/2023",
options: {
before_date: "2023-01-01T00:00:00.000Z",
},
},
];
// ColumnTransformations should be imported from "fuse-importer"
const transformations: ColumnTransformations<"date">[] = [
{
transformation_type: "autoformat",
},
];
importer.addColumn({
internal_key: "date",
label: "Date",
column_type: "date",
pattern: "MM/dd/yyyy",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
## Patterns
**MM/dd/yyyy**
Example: 08/31/2023; 12/15/2023
**yyyy-MM-dd**
Example: 2023-08-31; 2023-12-15
**dd/MM/yyyy**
Example: 31/08/2023; 15/12/2023
**MM-dd-yyyy**
Example: 08-31-2023; 12-15-2023
**yyyy/MM/dd**
Example: 2023/08/31; 2023/12/15
**dd-MMMM-yyyy**
Example: 31-August-2023; 15-December-2023
**MMMM dd, yyyy**
Example: August 31, 2023; December 15, 2023
**dd/MM/yy**
Example: 31/08/23; 15/12/23
**MMMM dd, yy**
Example: August 31, 23; December 15, 23
**yy/MM/dd**
Example: 23/08/31; 23/12/15
**EEEE MMMM yyyy**
Example: Tuesday August 2023; Thursday December 2023
**EEEE dd MMMM yyyy**
Example: Tuesday 08 August 2023; Thursday 15 December 2023
**MM-dd-yy**
Example: 01-15-90; 12-31-99
**M-dd-yy**
Example: 1-15-90; 12-31-99
**dd-MM-yy**
Example: 15-01-90; 31-12-99
**dd-MM-yyyy**
Example: 15-01-1990; 15-12-2023
**dd-M-yy**
Example: 15-1-90; 15-12-23
**MM/dd/yy**
Example: 01/15/90; 12/31/99
**M/dd/yy**
Example: 1/15/90; 12/31/99
**MM.dd.yy**
Example: 01.15.90; 12.31.99
**M.dd.yy**
Example: 1.15.90; 12.31.99
**MMM-dd-yy**
Example: Jan-15-90; Dec-31-99
**MMMM-dd-yy**
Example: January-15-90; December-31-99
**dd-MMM-yy**
Example: 15-Jan-90; 31-Dec-99
**yyyy-M-dd**
Example: 1990-1-15; 2023-12-31
**M-dd-yyyy**
Example: 1-15-1990; 12-31-2023
**M/dd/yyyy**
Example: 1/15/1990; 12/31/2023
**dd/M/yyyy**
Example: 15/1/1990; 31/12/2023
**yyyy/M/dd**
Example: 1990/1/15; 2023/12/31
**dd.MM.yyyy**
Example: 15.01.1990; 31.12.2023
**dd.M.yyyy**
Example: 15.1.1990; 31.12.2023
**yyyy.MM.dd**
Example: 1990.01.15; 2023.12.31
**yyyy.M.dd**
Example: 1990.1.15; 2023.12.31
**MMM. dd, yyyy**
Example: Jan. 15, 1990; Dec. 31, 2023
**dd MMM. yyyy**
Example: 15 Jan. 1990; 31 Dec. 2023
**dd. MMM. yyyy**
Example: 15. Jan. 1990; 31. Dec. 2023
**EEE, MMM dd, yyyy**
Example: Mon, Jan 15, 1990; Fri, Dec 31, 2023
## Built-in Date Validations
The options property of `addColumn` accepts an array of validations. Each validation has three properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
* `options:` options for the specific validation type
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message` and `options`. As the example below:
```javascript theme={null}
validations: [
{
validation_type: "before_date",
message: "Must be before 01/01/2023",
options: {
before_date: "2023-01-01T00:00:00.000Z",
},
},
];
```
### before\_date
Specifies that the value must be before a certain date.
```javascript theme={null}
validations: [
{
validation_type: "before_date",
message: "Must be before 01/01/2023",
options: {
before_date: "2023-01-01T00:00:00.000Z",
},
},
];
```
### after\_date
Specifies that the value must be after a certain date.
```javascript theme={null}
validations: [
{
validation_type: "after_date",
message: "Must be after 01/01/2023",
options: {
after_date: "2023-01-01T00:00:00.000Z",
},
},
];
```
### unique\_case\_sensitive
Specifies that the value must be unique using case-sensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique (case sensitive)",
},
];
```
### unique\_case\_insensitive
Specifies that the value must be unique using case-insensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
```
## Built-in Date Transformations
The options property of `addColumn` accepts an array of transformations. For the date transformations, you can specify one property:
* `transformation_type:` the name of the transformation
The transformations property accepts an array of objects that contains these possible values: `transformation_type`. As the example below:
```javascript theme={null}
transformations: [
{
transformation_type: "autoformat",
},
];
```
### autoformat
The autoformat transformation automatically transforms the date in the column to a standardized format specified by the `pattern` on the column.
```javascript theme={null}
transformations: [
{
transformation_type: "autoformat",
},
];
```
## Date Handling by File Type
### CSV Files
When importing CSV files, Fuse handles dates in a straightforward manner:
* Dates are read directly as text strings
* Fuse importer uses your date column's pattern as a hint to parse and transform dates
* No locale-specific formatting is applied during preview or processing
### Excel Files (.xls/.xlsx)
Excel files require special handling due to their native date storage format. Excel can store dates in cells as date, datetime, or time types. This means that the way dates are stored internally in Excel may differ from how they are displayed, special care must be taken to correctly interpret and process these values during import:
1. **Fuse Importer's First Step Preview**:
* For any Excel cells containing date, datetime, or time values, Fuse first converts them to raw date values
* These raw date values are then formatted according to your operating system's locale/region settings
* The same Excel file may result in different date formats being displayed in the preview stage depending on the user's region. For example the same date "December 31, 2023" may look like this in the preview stage for US and Europe:
* US: "12/31/2023, 00:00:44"
* Europe: "31/12/2023, 00:00:44"
* Excel uses a unique numbering system to store dates internally, where each date is represented as a count of days since January 1, 1900 (for more details, see [Microsoft's documentation on Excel date systems](https://support.microsoft.com/en-us/office/date-systems-in-excel-e7fe7167-48a9-4b96-bb53-5612a800b487)). Fuse converts these numerical values into familiar date formats during import. Here's how Fuse handles Excel's internal date representation versus what users see:
* Excel display: "01/12/2024" (what users see in Excel)
* Excel raw value: "2024-12-01 00:00:44" (the complete date and time information Excel actually stores)
* Fuse extracts the complete raw value that Excel stores internally, including any time components that may be hidden by Excel's date formatting options in order to preserve all date-time information for future processing.
2. **Fuse Importer's Processing Stage**:
* In this stage, the text format of dates, already extracted from Excel's native format during the first step, is used for further processing.
* Similar to date processing based on CSV files, text date values are parsed using your importer's date pattern as a hint and later transformed to the format specified by the importer date column pattern.
### Example: Excel Import Process
Take an Excel file with the date "January 15, 2023":
1. Preview stage appearance:
* US locale: "1/15/2023"
* UK locale: "15/1/2023"
2. Parsing stage:
* The date is parsed according to the importer's date pattern, converting it to raw date values for further processing.
3. Processing stage (with pattern "yyyy-MM-dd"):
* Final output: "2023-01-15"
### Two-Digit Year Rules
For both CSV and Excel files, Fuse applies these rules when processing two-digit years:
* Years 00-49 → 2000-2049
* Years 50-99 → 1950-1999
* Example: "23" becomes "2023", "50" becomes "1950"
### Best Practices
To ensure consistent results across file types and regions:
* Use four-digit years in your data files
* Test your setup with sample files, especially when working with two-digit years
* Be cautious of uploading data with ambiguous dates, such as "01/02/03" or "04/05/06", as it can lead to incorrect parsing and data inconsistencies
* Consider using date patterns that reduce ambiguity, such as "yyyy-MM-dd" or "dd-MMMM-yyyy". For example, "2023-01-15" or "15-January-2023" are less likely to be misinterpreted compared to "01/02/03".
# DateTime Columns
Source: https://fuse-docs.swovo.com/using-columns/datetime-columns
How to add a datetime column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The DateTime column type validates that values are a specific DateTime format.
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "datetime".
* `required` (String) - required: Whether or not the column is required.
* `pattern` (String) - required: must be one of [these patterns](#patterns).
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See [Built-in DateTime Validations](#built-in-date-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in DateTime Transformations](#built-in-date-validations).
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const validations = [
{
validation_type: "before_date",
message: "Must be before 01/01/2023"
options: {
before_date: "2023-01-01T00:00:00.000Z"
}
}
];
const transformations = [
{
transformation_type: "autoformat",
}
];
importer.addColumn({
internal_key: "datetime",
label: "Date and Time",
column_type: "datetime",
pattern: "MM/dd/yyyy HH:mm:ss",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"datetime">[] = [
{
validation_type: "before_date",
message: "Must be before 01/01/2023",
options: {
before_date: "2023-01-01T00:00:00.000Z",
},
},
];
// ColumnTransformations should be imported from "fuse-importer"
const transformations: ColumnTransformations<"datetime">[] = [
{
transformation_type: "autoformat",
},
];
importer.addColumn({
internal_key: "datetime",
label: "Date and Time",
column_type: "datetime",
pattern: "MM/dd/yyyy HH:mm:ss",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
## Patterns
**MM/dd/yyyy HH:mm**
Example: 08/31/2023 12:30; 09/31/2005 12:30
**MM/dd/yyyy HH:mm:ss**
Example: 08/31/2023 12:30:45; 08/31/2005 12:30:45
**MM/dd/yyyy HH:mm:ss.SSS**
Example: 08/31/2023 12:30:45.500; 08/31/2005 12:30:45.500
**MM/dd/yyyy h:mm a**
Example: 08/31/2023 1:30 PM; 08/31/2023 1:30 PM
**MM/dd/yyyy h:mm:ss a**
Example: 08/31/2023 1:30:45 PM; 08/31/2005 1:30:45 PM
**MMM dd HH:mm:ss yyyy**
Example: Jan 15 00:34:59 1990; Feb 15 00:34:59 1990
**dd MMM HH:mm:ss yyyy**
Example: 15 Jan 00:34:59 1990; 15 Feb 00:34:59 1990
**MM/dd/yyyy h:mm:ss.SSS a**
Example: 08/31/2023 1:30:45.500 PM; 06/11/2030 1:30:45.500 PM
**MMMM dd, yyyy HH:mm**
Example: August 31, 2023 12:30; January 15, 2023 12:30
**MMMM dd, yyyy HH:mm:ss**
Example: August 31, 2023 12:30:45; January 15, 2023 12:30:45
**MMMM dd, yyyy h:mm a**
Example: August 31, 2023 1:30 PM; January 15, 2023 1:30 PM
**MMMM dd, yyyy h:mm:ss a**
Example: August 31, 2023 1:30:45 PM; January 15, 2023 1:30:45 PM
**MMMM dd, yyyy h:mm:ss.SSS a**
Example: August 31, 2023 1:30:45.500 PM; January 15, 2023 1:30:45.500 PM
**MM-dd-yy HH:mm**
Example: 01-15-90 10:10; 05-15-90 10:10
**dd-MM-yyyy HH:mm**
Example: 15-01-1990 10:10; 15-01-1990 10:10
**dd/MM/yyyy HH:mm**
Example: 15/01/1990 10:10; 12/11/1990 10:10
**dd-MM-yyyy h:mm a**
Example: 15-01-1990 10:10 AM; 15-01-1990 10:10 AM
**dd/MM/yyyy h:mm a**
Example: 12/11/1990 10:10 AM; 15/01/1990 10:10 AM
**MM/dd/yy HH:mm**
Example: 01/15/90 10:10; 05/15/90 10:10
**MM/dd/yy HH:mm:ss**
Example: 01/15/90 10:10:14; 05/15/90 10:10:14
**MM/dd/yy h:mm:ss a**
Example: 01/15/90 5:10:14 AM; 05/15/90 5:10:14 AM
**yyyy/MM/dd HH:mm**
Example: 1990/01/15 10:10; 2007/11/16 10:10
**MM-dd-yyyy HH:mm**
Example: 01-15-1990 10:10; 05-15-1990 10:10
**yyyy-MM-dd HH:mm**
Example: 1990-01-15 10:10; 2007-11-16 10:10
**yyyy-MM-dd'T'HH:mm:ss.SSSZ**
Example: 1990-01-15T00:34:55.020+09:30; 2007-11-16T00:34:55.020+09:30
**yyyy-MM-dd'T'HH:mm:ss.SSS**
Example: 1990-01-15T00:34:55.020; 2007-11-16T00:34:55.020
**yyyy-MM-dd'T'HH:mmZ**
Example: 1990-01-15T10:10+09:30; 2007-11-16T10:10+09:30
**yyyy-MM-dd'T'HH:mm**
Example: 1990-01-15T10:10; 2007-11-16T10:10
**dd/MM/yyyy**
Example: 25/04/2023; 15/11/2023
## Built-in DateTime Validations
The options property of `addColumn` accepts an array of validations. Each validation has three properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
* `options:` options for the specific validation type
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message` and `options`. As the example below:
##
```javascript theme={null}
validations: [
{
validation_type: "before_date",
message: "Must be before 01/01/2023"
options: {
before_date: "2023-01-01T00:00:00.000Z"
}
}
]
```
### before\_date
Specifies that the value must be before a certain date.
```javascript theme={null}
validations: [
{
validation_type: "before_date",
message: "Must be before 01/01/2023"
options: {
before_date: "2023-01-01T00:00:00.000Z"
}
}
]
```
### after\_date
Specifies that the value must be after a certain date.
```javascript theme={null}
validations: [
{
validation_type: "after_date",
message: "Must be after 01/01/2023",
options: {
after_date: "2023-01-01T00:00:00.000Z",
},
},
];
```
### unique\_case\_sensitive
Specifies that the value must be unique using case-sensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique (case sensitive)",
},
];
```
### unique\_case\_insensitive
Specifies that the value must be unique using case-insensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
```
## Built-in DateTime Transformations
The options property of `addColumn` accepts an array of transformations. For the datetime transformations, you can specify one property:
* `transformation_type:` the name of the transformation
The transformations property accepts an array of objects that contains these possible values: `transformation_type`. As the example below:
```javascript theme={null}
transformations: [
{
transformation_type: "autoformat",
},
];
```
### autoformat
The autoformat transformation automatically transforms the date in the column to a standardized format specified by the `pattern` on the column.
```javascript theme={null}
transformations: [
{
transformation_type: "autoformat",
},
];
```
# Dropdown Columns
Source: https://fuse-docs.swovo.com/using-columns/dropdown-columns
How to add a dropdown column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The Dropdown column type displays a select box for the user to pick from an array of values.
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* label (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "enum".
* `required` (String) - required: Whether or not the column is required.
* `values` (Array) - required: An array of values for the dropdown.
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See Built-in [Enum Validations](#built-in-enum-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in Enum Transformations](#built-in-enum-transformations)
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const values = ["Pizza", "Sushi", "Burger"];
const validations = [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
const transformations = [
{
transformation_type: "autodetect",
},
];
importer.addColumn({
internal_key: "food_options",
label: "Food Options",
column_type: "enum",
required: true,
position: 1,
unique: true,
values: values,
validations: validations,
transformations: transformations,
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const values = ["Pizza", "Sushi", "Burger"];
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"enum">[] = [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
// ColumnTransformations should be imported from "fuse-importer"
const transformations: ColumnTransformations<"enum">[] = [
{
transformation_type: "autodetect",
},
];
importer.addColumn({
internal_key: "food_options",
label: "Food Options",
column_type: "enum",
required: true,
position: 1,
unique: true,
values: values,
validations: validations,
transformations: transformations,
});
importer.show();
```
## Built-in Enum Validations
The options property of `addColumn` accepts an array of validations. For the Enum validation, you can specify two properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message`. As the example below:
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique (case sensitive)",
},
];
```
### unique\_case\_sensitive
Specifies that the value must be unique using case-sensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique (case sensitive)",
},
];
```
### unique\_case\_insensitive
Specifies that the value must be unique using case-insensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
```
## Built-in Enum Transformations
The options property of `addColumn` accepts an array of transformations. For the time transformations, you can specify one property:
* `transformation_type:` the name of the transformation
The transformations property accepts an array of objects that contains these possible values: `transformation_type`. As the example below:
```javascript theme={null}
transformations: [
{
transformation_type: "autodetect",
},
];
```
### autodetect
The autodetect transformation analyzes the values in the column and automatically converts them to a more meaningful representation. For example, it can convert numerical values like 0 and 1 to boolean values like true and false.
```javascript theme={null}
transformations: [
{
transformation_type: "autodetect",
},
];
```
# Email Columns
Source: https://fuse-docs.swovo.com/using-columns/email-columns
How to add an email column to your importer through code.
You can add an Email column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The Email column type validates that input is a valid email address.
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "email".
* `required` (String) - required: Whether or not the column is required.
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See [Built-in Email Validations](#built-in-email-validations).
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const validations = [
{
validation_type: "contain",
message: "Must be a gmail address",
options: {
pattern: "gmail.com",
},
},
];
importer.addColumn({
internal_key: "email",
label: "Email",
column_type: "email",
required: true,
position: 1,
unique: true,
validations: validations,
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"email">[] = [
{
validation_type: "contain",
message: "Must be a gmail address",
options: {
pattern: "gmail.com",
},
},
];
importer.addColumn({
internal_key: "email",
label: "Email",
column_type: "email",
required: true,
position: 1,
unique: true,
validations: validations,
});
importer.show();
```
## Built-in Email Validations
The options property of `addColumn` accepts an array of validations. Each validation has three properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
* `options:` options for the specific validation type
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message` and `options`. As the example below:
```javascript theme={null}
validations: [
{
validation_type: "cannot_contain",
message: "Cannot contain 'john'",
options: {
pattern: "john",
},
},
];
```
### cannot\_contains
Specifies that the column cannot contain a specific pattern.
```javascript theme={null}
validations: [
{
validation_type: "cannot_contain",
message: "Cannot contain 'john'",
options: {
pattern: "john",
},
},
];
```
### contain
Specifies that column must contain a specific pattern.
```javascript theme={null}
validations: [
{
validation_type: "contain",
message: "Must contain 'john'",
options: {
pattern: "john",
},
},
];
```
### max\_length
Specifies the maximum character length of the column.
```javascript theme={null}
validations: [
{
validation_type: "max_length",
message: "Must be less than 10 characters",
options: {
max_length: 9,
},
},
];
```
### min\_length
Specifies the minimum character length of the column.
```javascript theme={null}
validations: [
{
validation_type: "min_length",
message: "Must be at least 10 characters",
options: {
min_length: 10,
},
},
];
```
### length\_exactly
Specifies the exact length that the column must have.
```javascript theme={null}
validations: [
{
validation_type: "length_exactly",
message: "Must be exactly 10 characters",
options: {
length: 10,
},
},
];
```
### unique\_case\_sensitive
Specifies that the value must be unique using case-sensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique",
},
];
```
### unique\_case\_insensitive
Specifies that the value must be unique using case-insensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_insensitive",
message: "Must be unique",
},
];
```
### regex
Specifies that the value must match a regex.
```javascript theme={null}
validations: [
{
validation_type: "regex",
message: "Must be a valid domain name",
options: {
pattern: /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/,
},
},
];
```
# Float Columns
Source: https://fuse-docs.swovo.com/using-columns/float-columns
How to add a float column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The Float column type can accept whole integers and decimals. It supports functionalities such as:
* Validate that input is greater than or less than a certain number
* Round values to the nearest integer
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "float".
* `required` (String) - required: Whether or not the column is required.
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See [Built-in Float Validations](#built-in-float-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in Float Transformations](#built-in-float-transformations).
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const validations = [
{
validation_type: "less_than",
message: "Must be less than 10",
options: {
less_than: 10,
},
},
];
const transformations = [
{
validation_type: "number_of_decimals",
},
];
importer.addColumn({
internal_key: "age",
label: "Age",
column_type: "float",
required: true,
position: 1,
validations: validations,
transformations: transformations,
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"float">[] = [
{
validation_type: "less_than",
message: "Must be less than 10",
options: {
less_than: 10,
},
},
];
// ColumnTransformations should be imported from "fuse-importer"
const transformations: ColumnTransformations<"float">[] = [
{
validation_type: "number_of_decimals",
},
];
importer.addColumn({
internal_key: "age",
label: "Age",
column_type: "float",
required: true,
position: 1,
validations: validations,
transformations: transformations,
});
importer.show();
```
## Built-in Float Validations
The `addColumn` object accepts an array of validations. Each validation has three properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
* `options:` options for the specific validation type
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message` and `options`. As the example below:
```javascript theme={null}
validations: [
{
validation_type: "less_than",
message: "Must be less than 10",
options: {
less_than: 10,
},
},
];
```
### less\_than
Specifies that the value must be less than a certain number.
```javascript theme={null}
validations: [
{
validation_type: "less_than",
message: "Must be less than 10",
options: {
less_than: 10,
},
},
];
```
### greater\_than
Specifies that the value must be greater than a certain number.
```javascript theme={null}
validations: [
{
validation_type: "greater_than",
message: "Must be greater than 10",
options: {
greater_than: 10,
},
},
];
```
### even
Specifies that the value must be even.
```javascript theme={null}
validations: [
{
validation_type: "even",
message: "Must be an even number",
},
];
```
### odd
Specifies that the value must be odd.
```javascript theme={null}
validations: [
{
validation_type: "odd",
message: "Must be an odd number",
},
];
```
### regex
Specifies that the value must match a regex
```javascript theme={null}
validations: [
{
validation_type: "regex",
message: "Must not have a leading zero",
options: {
pattern: /^([+-]?[1-9]\d*|0)$/,
},
},
];
```
## Built-in Float Transformations
The options property of `addColumn` accepts an array of transformations. Each transformation has two possible properties:
* `transformation_type:` the name of the transformation
* `options:` options for the specific transformation type
The transformations property accepts an array of objects that contains these possible values: `transformation_type` and `options`. As the example below:
```javascript theme={null}
transformations: [
{
transformation_type: "number_of_decimals",
options: {
number_of_decimals: 2,
},
},
];
```
### number\_of\_decimals
This transformation allows you to specify the desired number of decimal places for the float values in the column. For example, if the original value is 3.14159 and you specify 2 decimal places, it becomes 3.14. You should pass an `options` object to the transformation object with a `number_of_decimals` integer value in your desired format.
```javascript theme={null}
transformations: [
{
transformation_type: "number_of_decimals",
options: {
number_of_decimals: 2,
},
},
];
```
# Integer Columns
Source: https://fuse-docs.swovo.com/using-columns/integer-columns
How to add an integer column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The Integer column type accepts whole numbers (integers) as input. It supports functionalities such as:
* Validate that input is greater than or less than a certain number
* Round values to the nearest integer
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "integer".
* `required` (String) - required: Whether or not the column is required.
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See [Built-in Integer Validations](#built-in-integer-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in Integer Transformations](#built-in-integer-transformations).
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const validations = [
{
validation_type: "less_than",
message: "Must be less than 10",
options: {
less_than: 10,
},
},
];
const transformations = [
{
validation_type: "ceiling",
},
];
importer.addColumn({
internal_key: "age",
label: "Age",
column_type: "integer",
required: true,
position: 1,
validations: validations,
transformations: transformations,
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"integer">[] = [
{
validation_type: "less_than",
message: "Must be less than 10",
options: {
less_than: 10,
},
},
];
// ColumnTransformations should be imported from "fuse-importer"
const transformations: ColumnTransformations<"integer">[] = [
{
validation_type: "ceiling",
},
];
importer.addColumn({
internal_key: "age",
label: "Age",
column_type: "integer",
required: true,
position: 1,
validations: validations,
transformations: transformations,
});
importer.show();
```
## Built-in Integer Validations
The `addColumn` object accepts an array of validations. Each validation has three properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
* `options:` options for the specific validation type
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message` and `options`. As the example below:
```javascript theme={null}
validations: [
{
validation_type: "less_than",
message: "Must be less than 10",
options: {
less_than: 10,
},
},
];
```
### less\_than
Specifies that the value must be less than a certain number.
```javascript theme={null}
validations: [
{
validation_type: "less_than",
message: "Must be less than 10",
options: {
less_than: 10,
},
},
];
```
### greater\_than
Specifies that the value must be greater than a certain number.
```javascript theme={null}
validations: [
{
validation_type: "greater_than",
message: "Must be greater than 10",
options: {
greater_than: 10,
},
},
];
```
### even
Specifies that the value must be even.
```javascript theme={null}
validations: [
{
validation_type: "even",
message: "Must be an even number",
},
];
```
### odd
Specifies that the value must be odd.
```javascript theme={null}
validations: [
{
validation_type: "odd",
message: "Must be an odd number",
},
];
```
### regex
Specifies that the value must match a regex
```javascript theme={null}
validations: [
{
validation_type: "regex",
message: "Must not have a leading zero",
options: {
pattern: /^([+-]?[1-9]\d*|0)$/,
},
},
];
```
## Built-in Integer Transformations
The options property of `addColumn` accepts an array of transformations. For the integer transformations, you can specify one property:
* `transformation_type:` the name of the transformation
The transformations property accepts an array of objects that contains these possible values: `transformation_type`. As the example below:
```javascript theme={null}
transformations: [
{
transformation_type: "floor",
},
];
```
### round
The round transformation rounds the integer values in the column to the nearest whole number. For example, 36.6 becomes 37.
```javascript theme={null}
transformations: [
{
transformation_type: "round",
},
];
```
### floor
The floor transformation rounds down the integer values in the column to the nearest whole number that is less than or equal to the original value. For example, 9.8 becomes 9.
```javascript theme={null}
transformations: [
{
transformation_type: "floor",
},
];
```
### ceiling
The ceiling transformation rounds up the integer values in the column to the nearest whole number that is greater than or equal to the original value. For example, 9.2 becomes 10.
```javascript theme={null}
transformations: [
{
transformation_type: "ceiling",
},
];
```
# String Columns
Source: https://fuse-docs.swovo.com/using-columns/string-columns
How to add a string column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The String column is the most versatile column type. It accepts any strings, and has a number of different ways to validate or transform values.
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "string".
* `required` (String) - required: Whether or not the column is required.
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See [Built-in String Validations](#built-in-string-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in String Transformations](#built-in-string-transformations).
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const validations = [
{
validation_type: "max_length",
message: "My Label should not be longer than 18 characters",
options: {
max_length: 18,
},
},
];
const transformations = [
{
transformation_type: "lowercase",
},
];
importer.addColumn({
internal_key: "my_key",
label: "My Label",
column_type: "string",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"string">[] = [
{
validation_type: "max_length",
message: "My Label should not be longer than 18 characters",
options: {
max_length: 18,
},
},
];
// ColumnTransformations should be imported from "fuse-importer"
const transformations: ColumnTransformations<"string">[] = [
{
transformation_type: "lowercase",
},
];
importer.addColumn({
internal_key: "my_key",
label: "My Label",
column_type: "string",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
## Built-in String Validations
The `addColumn` object accepts an array of validations. Each validation has three properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
* `options:` options for the specific validation type
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message` and `options`. As the example below:
```javascript theme={null}
validations: [
{
validation_type: "cannot_contain",
message: "Cannot contain 'john'",
options: {
pattern: "john",
},
},
];
```
### cannot\_contain
Specifies that the column cannot contain a specific pattern.
```javascript theme={null}
validations: [
{
validation_type: "cannot_contain",
message: "Cannot contain 'john'",
options: {
pattern: "john",
},
},
];
```
### contain
Specifies that column must contain a specific pattern.
```javascript theme={null}
validations: [
{
validation_type: "contain",
message: "Must contain 'john'",
options: {
pattern: "john",
},
},
];
```
### max\_length
Specifies the maximum character length of the column.
```javascript theme={null}
validations: [
{
validation_type: "max_length",
message: "Must be less than 10 characters",
options: {
max_length: 9,
},
},
];
```
### min\_length
Specifies the minimum character length of the column.
```javascript theme={null}
validations: [
{
validation_type: "min_length",
message: "Must be at least 10 characters",
options: {
min_length: 10,
},
},
];
```
### length\_exactly
Specifies the exact length that the column must have.
```javascript theme={null}
validations: [
{
validation_type: "length_exactly",
message: "Must be exactly 10 characters",
options: {
length: 10,
},
},
];
```
### unique\_case\_sensitive
Specifies that the value must be unique using case-sensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique (case sensitive)",
},
];
```
### unique\_case\_insensitive
Specifies that the value must be unique using case-insensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
```
### regex
Specifies that the value must match a regex.
```javascript theme={null}
validations: [
{
validation_type: "regex",
message: "Must be a valid domain name",
options: {
pattern: /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/,
},
},
];
```
## Built-in String Transformations
The options property of `addColumn` accepts an array of transformations. For the string transformations, you can specify one property:
* `transformation_type:` the name of the transformation
The transformations property accepts an array of objects that contains these possible values: `transformation_type`. As the example below:
```javascript theme={null}
transformations: [
{
transformation_type: "trim_whitespace",
},
];
```
### sentence\_case
This transformation converts all the strings in the column to sentence case. For example, "hello world" becomes "Hello world".
```javascript theme={null}
transformations: [
{
transformation_type: "sentence_case",
},
];
```
### capitalize
This transformation capitalizes the first letter of each string in the column while making the remaining letters lowercase. For example, "apple" becomes "Apple".
```javascript theme={null}
transformations: [
{
transformation_type: "capitalize",
},
];
```
### uppercase
This transformation converts all the strings in the column to uppercase. For example, "hello" becomes "HELLO".
```javascript theme={null}
transformations: [
{
transformation_type: "uppercase",
},
];
```
### lowercase
This transformation converts all the strings in the column to lowercase. For example, "WORLD" becomes "world".
```javascript theme={null}
transformations: [
{
transformation_type: "lowercase",
},
];
```
### trim\_whitespace
This transformation removes any leading or trailing whitespace characters (spaces, tabs, etc.) from each string in the column. For example, " hello " becomes "hello".
```javascript theme={null}
transformations: [
{
transformation_type: "trim_whitespace",
},
];
```
# Time Columns
Source: https://fuse-docs.swovo.com/using-columns/time-columns
How to add a time column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The Time column type validates that values are a specific time format.
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing label shown in the interface.
* `column_type` (String) - required: Should be "time".
* `required` (String) - required: Whether or not the column is required.
* `pattern` (String) - required: must be one of [these patterns](#patterns).
* `position` (Optional): The position or order of the column.
* `validations` (Optional): An array of built-in data validations. See [Built-in Time Validations](#built-in-time-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in Time Transformations](#built-in-time-transformations).
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const validations = [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
const transformations = [
{
transformation_type: "autoformat",
},
];
importer.addColumn({
internal_key: "time",
label: "Time",
column_type: "time",
pattern: "HH:mm:ss",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"time">[] = [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
// ColumnTransformations should be imported from "fuse-importer"
const transformations: ColumnTransformations<"time">[] = [
{
transformation_type: "autoformat",
},
];
importer.addColumn({
internal_key: "time",
label: "Time",
column_type: "time",
pattern: "HH:mm:ss",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
## Patterns
**HH:mm**
Example: 12:30; 23:45
**HH:mm:ss**
Example: 12:30:45; 23:45:30
**hh:mm a**
Example: 01:30 PM; 11:45 AM
**hh:mm:ss a**
Example: 01:30:45 PM; 11:45:30 AM
## Built-in Time Validations
The options property of `addColumn` accepts an array of validations. For the Time validation, you can specify two properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message`. As the example below:
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique (case sensitive)",
},
];
```
### unique\_case\_sensitive
Specifies that the value must be unique using case-sensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique (case sensitive)",
},
];
```
### unique\_case\_insensitive
Specifies that the value must be unique using case-insensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_insensitive",
message: "Must be unique (case insensitive)",
},
];
```
## Built-in Time Transformations
The options property of `addColumn` accepts an array of transformations. For the time transformations, you can specify one property:
* `transformation_type:` the name of the transformation
The transformations property accepts an array of objects that contains these possible values: `transformation_type`. As the example below:
```javascript theme={null}
transformations: [
{
transformation_type: "autoformat",
},
];
```
### autoformat
The autoformat transformation automatically transforms the date in the column to a standardized format specified by the `pattern` on the column.
```javascript theme={null}
transformations: [
{
transformation_type: "autoformat",
},
];
```
# URL Columns
Source: https://fuse-docs.swovo.com/using-columns/url-columns
How to add an url column to your importer through code.
You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.
The URL column type validates that values are a valid URL. By default, this column type accepts formats like:
* example.com
* [https://example.com](https://example.com)
If you want to validate that all URLs in the column contain a protocol (e.g., "https\://"), you can [add a custom validation](/getting-started/adding-data-validations).
## addColumn Function
The `addColumn` function accepts an object as an argument.
* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "url".
* `required` (String) - required: Whether or not the column is required.
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See [Built-in URL Validations](#built-in-url-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in URL Transformations](#built-in-url-transformations)
### Example Code
```javascript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
const validations = [
{
validation_type: "max_length",
message: "The URL should not be longer than 18 characters",
options: {
max_length: 18,
},
},
];
const transformations = [
{
validation_type: "prefix",
options: {
prefix: "https://",
},
},
];
importer.addColumn({
internal_key: "url",
label: "URL",
column_type: "url",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
```typescript theme={null}
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.swovo.com/getting-started/sessions
// ColumnValidations should be imported from "fuse-importer"
const validations: ColumnValidations<"url">[] = [
{
validation_type: "max_length",
message: "The URL should not be longer than 18 characters",
options: {
max_length: 18,
},
},
];
// ColumnTransformations should be imported from "fuse-importer"
const transformations: ColumnTransformations<"url">[] = [
{
validation_type: "prefix",
options: {
prefix: "https://",
},
},
];
importer.addColumn({
internal_key: "url",
label: "URL",
column_type: "url",
required: true,
position: 1,
unique: true,
validations: validations,
transformations: transformations,
});
importer.show();
```
## Built-in URL Validations
The options property of `addColumn` accepts an array of validations. Each validation has three properties:
* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
* `options:` options for the specific validation type
The validations property accepts an array of objects that contains these possible values: `validation_type`, `message,` and `options`. As the example below:
```javascript theme={null}
validations: [
{
validation_type: "cannot_contain",
message: "Cannot contain .net",
options: {
pattern: ".net",
},
},
];
```
### cannot\_contains
Specifies that the column cannot contain a specific pattern.
```javascript theme={null}
validations: [
{
validation_type: "cannot_contain",
message: "Cannot contain .net",
options: {
pattern: ".net",
},
},
];
```
### contain
Specifies that column must contain a specific pattern.
```javascript theme={null}
validations: [
{
validation_type: "contain",
message: "Must contain https://",
options: {
pattern: "https://",
},
},
];
```
### max\_length
Specifies the maximum character length of the column.
```javascript theme={null}
validations: [
{
validation_type: "max_length",
message: "Must be less than 10 characters",
options: {
max_length: 9,
},
},
];
```
### min\_length
Specifies the minimum character length of the column.
```javascript theme={null}
validations: [
{
validation_type: "min_length",
message: "Must be at least 10 characters",
options: {
min_length: 10,
},
},
];
```
### length\_exactly
Specifies the exact length that the column must have.
```javascript theme={null}
validations: [
{
validation_type: "length_exactly",
message: "Must be exactly 10 characters",
options: {
length: 10,
},
},
];
```
### unique\_case\_sensitive
Specifies that the value must be unique using case-sensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_sensitive",
message: "Must be unique",
},
];
```
### unique\_case\_insensitive
Specifies that the value must be unique using case-insensitive comparison.
```javascript theme={null}
validations: [
{
validation_type: "unique_case_insensitive",
message: "Must be unique",
},
];
```
### regex
Specifies that the value must match a regex.
```javascript theme={null}
validations: [
{
validation_type: "regex",
message: "Must be a valid domain name",
options: {
pattern: /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/,
},
},
];
```
## Built-in URL Transformations
The options property of `addColumn` accepts an array of transformations. For the string transformations, you can specify one property:
* `transformation_type:` the name of the transformation
The transformations property accepts an array of objects that contains these possible values: `transformation_type`. As the example below:
```javascript theme={null}
transformations: [
{
transformation_type: "prefix",
options: {
prefix: "https://",
},
},
];
```
### prefix
The prefix transformation adds a specified prefix, such as "https\://", to each URL in the column. For example, "example.com" becomes "[https://example.com](https://example.com)". You should pass an `options` object to the transformation object with a `prefix` string value with your prefix.
```javascript theme={null}
transformations: [
{
transformation_type: "prefix",
options: {
prefix: "https://",
},
},
];
```