### Install Ivandt Framework Wrappers
Source: https://docs.ivandt.com/getting-started
Installs framework-specific wrappers for React, Angular, and Vue. These provide a slightly more integrated experience within their respective frameworks.
```bash
npm install @ivandt/importer-react
npm install @ivandt/importer-angular
npm install @ivandt/importer-vue
```
--------------------------------
### Install Ivandt SDK with npm
Source: https://docs.ivandt.com/getting-started
Installs the core Ivandt SDK package using npm. This is the primary method for adding the SDK to your project for general use.
```bash
npm install @ivandt/importer
```
--------------------------------
### Use Ivandt Modal Dialog Importer Component
Source: https://docs.ivandt.com/getting-started
This example demonstrates the usage of the `` component for integrating the importer within a modal window. It requires a trigger button to open the dialog and includes an `onClose` event handler. The `open` attribute controls the visibility of the modal.
```html
```
--------------------------------
### Use Ivandt Full-page Importer Component
Source: https://docs.ivandt.com/getting-started
This code snippet shows how to use the `` custom element to create a full-page importer experience. This component is ideal for dedicated import pages, occupying the entire viewport.
```html
```
--------------------------------
### Create Session Token with Node.js
Source: https://docs.ivandt.com/getting-started
Demonstrates how to create a session token on the backend using the Ivandt Secret Key. This token is required for initializing the Ivandt importer on the frontend and is valid for a limited time.
```typescript
// backend/api/create-session.ts
const SECRET_KEY = process.env.IVANDT_SECRET_KEY; // sk_live_xxx...
const PUBLIC_KEY = process.env.IVANDT_PUBLIC_KEY; // pk_live_xxx...
async function createSessionToken(
templateId: string,
endUserId: string,
endUserEmail?: string,
) {
const response = await fetch('https://api.ivandt.com/api/sessions', {
method: 'POST',
headers: {
Authorization: `Bearer ${SECRET_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
templateId, // Optional: UUID of your import template, for tracking and audit trail
endUserId, // Your user's ID (for audit trail and tracking)
endUserEmail, // Optional: user's email for tracking
expiresIn: 900 // Optional: 15 minutes (default=1h), max 1d
}),
});
if (!response.ok) {
throw new Error(`Failed to create session: ${response.statusText}`);
}
const data = await response.json();
return {
sessionToken: data.sessionToken,
expiresAt: data.expiresAt,
};
}
// Express.js endpoint example
app.post('/api/get-import-session', async (req, res) => {
try {
const userId = req.user.id; // From your auth system
const userEmail = req.user.email;
const { templateId } = req.body;
const session = await createSessionToken(templateId, userId, userEmail);
res.json({
sessionToken: session.sessionToken,
publicKey: PUBLIC_KEY,
expiresAt: session.expiresAt,
});
} catch (error) {
console.error('Failed to create session:', error);
res.status(500).json({ error: 'Failed to create import session' });
}
});
```
--------------------------------
### Use Ivandt Button + Dialog Importer Component
Source: https://docs.ivandt.com/getting-started
The `` component provides a simplified, all-in-one solution for importing data. It includes a built-in button that, when clicked, opens the importer dialog. This is the recommended option for most use cases, as it handles button state and dialog visibility automatically.
```html
```
--------------------------------
### Get Account Overview Statistics (Go)
Source: https://docs.ivandt.com/api/stats/getOverview
Example of how to fetch account overview statistics using Go's net/http package. This code demonstrates making an HTTP GET request and handling the JSON response.
```go
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
func main() {
resp, err := http.Get("https://api.ivandt.com/v1/stats/overview")
if err != nil {
log.Fatalf("Error making request: %s", err)
}
defer resp.Body.Close()
var data map[string]interface{}
if err := json.NewDecoder(resp.Body).Decode(&data);
err != nil {
log.Fatalf("Error decoding response: %s", err)
}
fmt.Printf("%+v\n", data)
}
```
--------------------------------
### Define a Customer Import Schema with TypeScript
Source: https://docs.ivandt.com/getting-started
This TypeScript code defines a schema for importing customer data. It specifies fields like Full Name, Email, Age, and Country, along with validation rules for each field. It also includes optional configuration for upload steps.
```typescript
import type { IvtSchema } from '@ivandt/importer';
const schema: IvtSchema = {
title: 'Customer Import',
key:'customer_import',
publicKey: 'pk_live_xxx...',
sessionToken: 'eyJhbGc...', // From your backend
// Optional: Configure import behavior
stepsConfig: {
uploadFileStep: {
maxFileSize: 50 * 1024 * 1024 // 50MB
},
mapHeadersStep: {
intelligentImport: true // AI-powered column mapping
},
reviewStep: {
invalidDataBehaviour: 'block_submit' // block the submission if there's any unresolved errors
}
},
fields: [
{
type: 'text',
label: 'Full Name',
key: 'fullName',
order: 1,
validators: [
{ type: 'required' },
{ type: 'minLength', value: 2 }
]
},
{
type: 'text',
label: 'Email',
key: 'email',
order: 2,
validators: [
{ type: 'required' },
{ type: 'email' }
]
},
{
type: 'numeric',
label: 'Age',
key: 'age',
order: 3,
validators: [
{ type: 'range', min: 18, max: 120 }
]
},
{
type: 'dropdown',
label: 'Country',
key: 'country',
order: 4,
options: [
{ value: 'US', label: 'United States' },
{ value: 'UK', label: 'United Kingdom' },
{ value: 'AU', label: 'Australia' }
],
validators: [{ type: 'required' }]
}
]
};
```
--------------------------------
### Handle Import Submission with Event Handlers in TypeScript
Source: https://docs.ivandt.com/getting-started
This TypeScript code demonstrates how to handle the submission of validated data from the Ivandt importer. It includes event handlers for `onSubmit`, `onSubmitError`, and `onFileUpload`, allowing you to process data, log errors, and manage uploaded files.
```typescript
import type { IvtSchema } from '@ivandt/importer';
const schema: IvtSchema = {
title: 'Customer Import',
publicKey: 'pk_live_xxx...',
sessionToken: 'eyJhbGc...',
fields: [
// ... your fields
],
// Event handlers
eventHandlers: {
onSubmit: async (tableRows, meta, cellErrors, submitMeta) => {
// tableRows: Array of validated rows
console.log('Rows:', tableRows);
// [
// { fullName: 'John Doe', email: 'john@example.com', age: 30, country: 'US' },
// { fullName: 'Jane Smith', email: 'jane@example.com', age: 25, country: 'UK' }
// ]
// meta: Import metadata (file info, row counts, etc.)
console.log('Metadata:', meta);
// cellErrors: Any unresolved validation errors
console.log('Errors:', cellErrors);
// submitMeta: Server response with import ID and tracking info
console.log('Submit meta:', submitMeta);
// Send to your backend
await fetch('/api/customers/bulk', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ data: tableRows, meta })
});
},
onSubmitError: (error) => {
console.error('Import failed:', error);
// Handle submission errors
},
onFileUpload: (file, fileMeta) => {
console.log('File uploaded:', file.name, fileMeta);
// Optionally store the original file
}
}
};
```
--------------------------------
### Initialize Ivandt Importer in Vanilla JS
Source: https://docs.ivandt.com/getting-started
This snippet demonstrates how to embed and initialize the Ivandt importer component using Vanilla JavaScript. It includes fetching a session token from a backend, configuring the importer's schema with fields and validators, and setting up an onSubmit event handler to process imported data. Ensure your backend provides a session token and public key.
```html
```
--------------------------------
### Overview
Source: https://docs.ivandt.com/api
Endpoint to get an overview of the system.
```APIDOC
## GET /websites/ivandt/overview
### Description
Retrieves a general overview of the Ivandt platform's status and key metrics.
### Method
GET
### Endpoint
/websites/ivandt/overview
### Parameters
#### Query Parameters
- None
### Request Example
(No request body needed for this endpoint)
### Response
#### Success Response (200)
- **total_environments** (integer) - The total number of environments.
- **total_imports** (integer) - The total number of imports processed.
- **active_users** (integer) - The number of currently active users.
#### Response Example
```json
{
"total_environments": 5,
"total_imports": 150,
"active_users": 25
}
```
```
--------------------------------
### Get Account Overview Statistics (C#)
Source: https://docs.ivandt.com/api/stats/getOverview
Example of how to fetch account overview statistics using C#'s HttpClient. This code demonstrates making an HTTP GET request and processing the JSON response.
```csharp
using System;
using System.Net.Http;
using System.Threading.Tasks;
public class GetOverviewStats
{
public static async Task Main(string[] args)
{
using (HttpClient client = new HttpClient())
{
try
{
HttpResponseMessage response = await client.GetAsync("https://api.ivandt.com/v1/stats/overview");
response.EnsureSuccessStatusCode(); // Throw an exception if the status code is an error
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Request error: {e.Message}");
}
}
}
}
```
--------------------------------
### Get Account Overview Statistics (Java)
Source: https://docs.ivandt.com/api/stats/getOverview
Example of how to fetch account overview statistics using Java's HttpClient. This code demonstrates making an HTTP GET request and handling the JSON response.
```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class GetOverviewStats {
public static void main(String[] args) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ivandt.com/v1/stats/overview"))
.header("Accept", "application/json")
.GET()
.build();
try {
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Status Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
```
--------------------------------
### Get Account Overview Statistics (cURL)
Source: https://docs.ivandt.com/api/stats/getOverview
Example of how to fetch account overview statistics using cURL. This command sends a GET request to the specified API endpoint.
```bash
curl -X GET "https://api.ivandt.com/v1/stats/overview"
```
--------------------------------
### List Templates using Java
Source: https://docs.ivandt.com/api/templates/listTemplates
Retrieves all account templates in Java, typically using libraries like Apache HttpClient or OkHttp. This example outlines the process of making an HTTP GET request and handling the JSON response. You would need to add specific library imports and JSON parsing logic.
```java
// Example using Apache HttpClient (add dependency to pom.xml)
// import org.apache.http.client.methods.HttpGet;
// import org.apache.http.impl.client.CloseableHttpClient;
// import org.apache.http.impl.client.HttpClients;
// import org.apache.http.util.EntityUtils;
// String url = "https://api.ivandt.com/v1/templates";
// CloseableHttpClient client = HttpClients.createDefault();
// HttpGet request = new HttpGet(url);
// try {
// org.apache.http.HttpResponse response = client.execute(request);
// String jsonResponse = EntityUtils.toString(response.getEntity());
// // Parse jsonResponse using a library like Jackson or Gson
// System.out.println(jsonResponse);
// } catch (IOException e) {
// e.printStackTrace();
// } finally {
// client.close();
// }
```
--------------------------------
### Delete Environment API Request Examples (Multiple Languages)
Source: https://docs.ivandt.com/api/environments/deleteEnvironment
Demonstrates how to delete an environment using the API across various programming languages including JavaScript, Go, Python, Java, and C#. These examples showcase the client-side implementation for the DELETE operation.
```javascript
// JavaScript example for DELETE request
// Note: Actual implementation would involve fetch or a library like axios
console.log('DELETE https://api.ivandt.com/v1/environments/string');
```
```go
// Go example for DELETE request
// Note: Actual implementation would involve net/http package
fmt.Println("DELETE https://api.ivandt.com/v1/environments/string");
```
```python
# Python example for DELETE request
# Note: Actual implementation would use libraries like requests
print("DELETE https://api.ivandt.com/v1/environments/string")
```
```java
// Java example for DELETE request
// Note: Actual implementation would use HttpURLConnection or Apache HttpClient
System.out.println("DELETE https://api.ivandt.com/v1/environments/string");
```
```csharp
// C# example for DELETE request
// Note: Actual implementation would use HttpClient
Console.WriteLine("DELETE https://api.ivandt.com/v1/environments/string");
```
--------------------------------
### IvtSchema Optional Properties Examples (JSON)
Source: https://docs.ivandt.com/schema
Demonstrates how to utilize optional properties in IvtSchema, such as providing a schema ID, configuring data sources for dynamic fields, setting the environment, or pre-populating with initial data or a file.
```json
{
id: '550e8400-e29b-41d4-a716-446655440000'
}
```
```json
{
dataSources: {
countries: [
{ name: 'Australia', code: 'AU', states: [...] },
{ name: 'United States', code: 'US', states: [...] }
]
}
}
```
```json
{
environment: 'prod'
}
```
```json
{
initialData: [
{ name: 'Product 1', price: 100 },
{ name: 'Product 2', price: 200 }
]
}
```
```json
{
initialFile: downloadedFile
}
```
--------------------------------
### IvtSchema Configuration Example (TypeScript)
Source: https://docs.ivandt.com/fields/dropdown
Demonstrates the structure of an IvtSchema object, including fields for dropdowns with remote data sources and specific option configurations like labelField and minQueryLength.
```typescript
import type { IvtSchema } from '@ivandt/importer';
const schema: IvtSchema = {
title: 'Order Import',
publicKey: 'pk_live_xxx',
sessionToken: 'session_xxx',
fields: [
{
type: 'dropdown',
label: 'Customer',
key: 'customer',
order: 0,
options: {
url: '/api/customers/search',
method: 'GET',
labelField: 'name',
minQueryLength: 2
},
validators: [
{ type: 'required' }
]
},
{
type: 'dropdown',
label: 'Product',
key: 'product',
order: 1,
options: {
query: '.products | map({label:.name, value:.sku})'
}
}
]
};
```
--------------------------------
### Get Account Overview Statistics (Python)
Source: https://docs.ivandt.com/api/stats/getOverview
Example of how to fetch account overview statistics using Python's requests library. This code makes a GET request and parses the JSON response.
```python
import requests
url = "https://api.ivandt.com/v1/stats/overview"
try:
response = requests.get(url)
response.raise_for_status() # Raise an exception for bad status codes
data = response.json()
print(data)
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
--------------------------------
### Get Account Overview Statistics (JavaScript)
Source: https://docs.ivandt.com/api/stats/getOverview
Example of how to fetch account overview statistics using JavaScript's Fetch API. This asynchronous operation retrieves account usage data.
```javascript
fetch('https://api.ivandt.com/v1/stats/overview')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
```
--------------------------------
### Create Template using Go
Source: https://docs.ivandt.com/api/templates/createTemplate
Illustrates how to create a template in Go using an HTTP POST request. This example includes setting the request body with the schema and handling the JSON response. It utilizes Go's standard `net/http` package.
```go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
payload := map[string]map[string]interface{}{
"schema": {
"property1": nil,
"property2": nil
}
}
jsonPayload, _ := json.Marshal(payload)
resp, err := http.Post("https://api.ivandt.com/v1/templates", "application/json", bytes.NewBuffer(jsonPayload))
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
```
--------------------------------
### Create Environment - JavaScript
Source: https://docs.ivandt.com/api/environments/createEnvironment
Example of creating a new environment using JavaScript. This code snippet demonstrates how to make a POST request to the environments endpoint with the necessary payload.
--------------------------------
### IvtSchema Required Properties Examples (JSON)
Source: https://docs.ivandt.com/schema
Illustrates the usage of essential properties within an IvtSchema configuration, including title for tracking, a unique key for schema identification, public and session keys for authentication, and field definitions for data structure.
```json
{
title: 'Customer Import'
}
```
```json
{
key: 'product-import-v1'
}
```
```json
{
publicKey: 'pk_live_abc123...'
}
```
```json
{
sessionToken: 'eyJhbGc...'
}
```
```json
{
fields: [
{
type: 'text',
label: 'Product Name',
key: 'name',
order: 0
},
{
type: 'numeric',
label: 'Price',
key: 'price',
order: 1
}
]
}
```
--------------------------------
### GET /stats/overview
Source: https://docs.ivandt.com/api/stats/getOverview
Fetches summary statistics for your account, including total counts of templates and imports, and details of the 5 most recent imports.
```APIDOC
## GET /stats/overview
### Description
Returns summary statistics for your account including total counts and recent activity.
### Method
GET
### Endpoint
/stats/overview
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response (200)
- **counts** (object) - Contains total counts for templates and imports.
- **templates** (integer) - Total number of templates.
- **imports** (integer) - Total number of imports.
- **latestImports** (array) - An array of the 5 most recent imports with metadata.
- **id** (string) - The unique identifier for the import.
- **templateId** (string) - The identifier of the template used for the import.
- **createdAt** (string) - The timestamp when the import was created.
- **updatedAt** (string) - The timestamp when the import was last updated.
- **fileId** (object) - Information about the file associated with the import.
- **meta** (object) - Metadata associated with the import.
- **publicKey** (string)
- **sessionToken** (string)
- **schemaId** (string)
- **schemaKey** (string)
- **sdkVersion** (string)
- **source** (object)
- **kind** (string)
- **referer** (string)
- **file** (object)
- **name** (string)
- **fileId** (string)
- **extension** (string)
- **mime** (string)
- **sizeBytes** (integer)
- **formattedSize** (string)
- **lastModified** (string)
- **sheet** (object)
- **rowCount** (integer)
- **selectedSheetName** (string)
- **allSheetNames** (array of strings)
- **counts** (object)
- **totalRows** (integer)
- **validRows** (integer)
- **erroredRows** (integer)
- **discardedRows** (integer)
- **timings** (object)
- **startedAt** (string)
- **finishedAt** (string)
- **environment** (object)
- **userAgent** (string)
- **timezone** (string)
- **platform** (string)
- **runtime** (string)
#### Response Example
```json
{
"counts": {
"templates": 0,
"imports": 0
},
"latestImports": [
{
"id": "string",
"templateId": "string",
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z",
"fileId": {},
"meta": {
"publicKey": "string",
"sessionToken": "string",
"schemaId": "string",
"schemaKey": "string",
"sdkVersion": "string",
"source": {
"kind": "upload",
"referer": "string"
},
"file": {
"name": "string",
"fileId": "string",
"extension": "string",
"mime": "string",
"sizeBytes": 0,
"formattedSize": "string",
"lastModified": "string"
},
"sheet": {
"rowCount": 0,
"selectedSheetName": "string",
"allSheetNames": [
"string"
]
},
"counts": {
"totalRows": 0,
"validRows": 0,
"erroredRows": 0,
"discardedRows": 0
},
"timings": {
"startedAt": "string",
"finishedAt": "string"
},
"environment": {
"userAgent": "string",
"timezone": "string",
"platform": "web",
"runtime": "string"
}
}
}
]
}
```
```
--------------------------------
### Complete Theme Example for Ivandt Importer (CSS)
Source: https://docs.ivandt.com/theming
A complete custom theme example for the Ivandt Importer component, featuring a green color scheme and rounded corners. It defines CSS variables for base, primary, secondary, and accent colors, along with radius values for both light and dark modes, ensuring a consistent look and feel.
```css
ivt-importer[data-selected-mode='light'] {
/* Base colors */
--ivt-color-base: #ffffff;
--ivt-color-base-content: #064e3b;
/* Primary - main actions */
--ivt-color-primary: #059669;
--ivt-color-primary-content: #ffffff;
/* Secondary - supporting actions */
--ivt-color-secondary: #10b981;
--ivt-color-secondary-content: #ffffff;
/* Accent - highlights */
--ivt-color-accent: #34d399;
--ivt-color-accent-content: #064e3b;
/* Rounded corners */
--ivt-radius-box: 1rem;
--ivt-radius-field: 0.5rem;
--ivt-radius-selector: 0.5rem;
}
ivt-importer[data-selected-mode='dark'] {
/* Base colors */
--ivt-color-base: #064e3b;
--ivt-color-base-content: #d1fae5;
/* Primary - main actions */
--ivt-color-primary: #34d399;
--ivt-color-primary-content: #064e3b;
/* Secondary - supporting actions */
--ivt-color-secondary: #10b981;
--ivt-color-secondary-content: #064e3b;
/* Accent - highlights */
--ivt-color-accent: #6ee7b7;
--ivt-color-accent-content: #064e3b;
/* Rounded corners */
--ivt-radius-box: 1rem;
--ivt-radius-field: 0.5rem;
--ivt-radius-selector: 0.5rem;
}
```
--------------------------------
### Create Template using JavaScript
Source: https://docs.ivandt.com/api/templates/createTemplate
Provides a JavaScript example for creating a new template via a POST request. It shows how to structure the request body with the schema and handle the response. This requires an HTTP client library like `fetch` or `axios`.
```javascript
fetch("https://api.ivandt.com/v1/templates", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
schema: {
property1: null,
property2: null
}
})
})
.then(response => response.json())
.then(data => console.log(data));
```
--------------------------------
### Dropdown Field - Remote API Basic Configuration
Source: https://docs.ivandt.com/fields/dropdown
Shows the basic setup for a dropdown field that fetches suggestions from a remote API.
```APIDOC
## Dropdown Field - Remote API Basic Configuration
### Description
Configures a dropdown field to fetch suggestions from a specified remote API endpoint as the user types. Uses basic settings for URL and label field.
### Method
N/A (Configuration Object)
### Endpoint
N/A
### Parameters
#### Request Body
- **type** (string) - 'dropdown' - Specifies the field type.
- **label** (string) - The label displayed for the dropdown.
- **key** (string) - The unique identifier for the dropdown field.
- **order** (number) - The display order of the field.
- **options** (object) - Configuration object for remote data fetching.
- **url** (string) - Required. The API endpoint URL (absolute or relative).
- **labelField** (string) - Optional. The field in the API response to use for the option label. Default: `'label'`.
### Request Example
```json
{
"type": "dropdown",
"label": "Company",
"key": "company",
"order": 0,
"options": {
"url": "/api/companies/search",
"labelField": "name"
}
}
```
### Response
#### Success Response (200)
N/A
#### Response Example
N/A
```
--------------------------------
### Minimal Theme Example for Ivandt Importer (CSS)
Source: https://docs.ivandt.com/theming
Presents a minimal theme for the Ivandt Importer component, focusing on a clean look with subtle colors. This CSS defines base, primary, and secondary colors, along with small radius values for a modern, understated aesthetic.
```css
ivt-importer[data-selected-mode='light'] {
--ivt-color-base: #fafafa;
--ivt-color-base-content: #2a2a2a;
--ivt-color-primary: #2a2a2a;
--ivt-color-primary-content: #ffffff;
--ivt-color-secondary: #6b7280;
--ivt-color-secondary-content: #ffffff;
--ivt-radius-box: 0.25rem;
--ivt-radius-field: 0.25rem;
}
```
--------------------------------
### Create Template using Java
Source: https://docs.ivandt.com/api/templates/createTemplate
A Java example demonstrating how to create a template using an HTTP POST request. It involves setting up the request body with the schema and handling the JSON response. This typically requires an HTTP client library like Apache HttpClient or OkHttp.
```java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.HashMap;
import java.util.Map;
public class CreateTemplate {
public static void main(String[] args) throws IOException, InterruptedException {
HttpClient client = HttpClient.newHttpClient();
Map schema = new HashMap<>();
schema.put("property1", null);
schema.put("property2", null);
Map requestBody = new HashMap<>();
requestBody.put("schema", schema);
String jsonBody = new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(requestBody);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ivandt.com/v1/templates"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
```
--------------------------------
### Template Management
Source: https://docs.ivandt.com/api
Endpoints for managing templates, including listing, creating, getting, updating, and deleting them.
```APIDOC
## POST /websites/ivandt/templates
### Description
Creates a new template.
### Method
POST
### Endpoint
/websites/ivandt/templates
### Parameters
#### Query Parameters
- None
#### Request Body
- **name** (string) - Required - The name of the template.
- **content** (string) - Required - The content of the template.
### Request Example
```json
{
"name": "Welcome Email Template",
"content": "
Welcome!
Thank you for joining us.
"
}
```
### Response
#### Success Response (201)
- **template_id** (string) - The unique identifier of the created template.
- **name** (string) - The name of the template.
#### Response Example
```json
{
"template_id": "tmpl-xyz123",
"name": "Welcome Email Template"
}
```
```
```APIDOC
## GET /websites/ivandt/templates/{template_id}
### Description
Retrieves details for a specific template.
### Method
GET
### Endpoint
/websites/ivandt/templates/{template_id}
### Parameters
#### Path Parameters
- **template_id** (string) - Required - The ID of the template to retrieve.
### Request Example
(No request body needed for this endpoint)
### Response
#### Success Response (200)
- **template_id** (string) - The unique identifier of the template.
- **name** (string) - The name of the template.
- **content** (string) - The content of the template.
#### Response Example
```json
{
"template_id": "tmpl-xyz123",
"name": "Welcome Email Template",
"content": "
Welcome!
Thank you for joining us.
"
}
```
```
```APIDOC
## DELETE /websites/ivandt/templates/{template_id}
### Description
Deletes a specific template.
### Method
DELETE
### Endpoint
/websites/ivandt/templates/{template_id}
### Parameters
#### Path Parameters
- **template_id** (string) - Required - The ID of the template to delete.
### Request Example
(No request body needed for this endpoint)
### Response
#### Success Response (200)
- **message** (string) - A success message indicating the template was deleted.
#### Response Example
```json
{
"message": "Template deleted successfully."
}
```
```
```APIDOC
## PUT /websites/ivandt/templates/{template_id}
### Description
Updates an existing template.
### Method
PUT
### Endpoint
/websites/ivandt/templates/{template_id}
### Parameters
#### Path Parameters
- **template_id** (string) - Required - The ID of the template to update.
#### Request Body
- **name** (string) - Optional - The new name for the template.
- **content** (string) - Optional - The new content for the template.
### Request Example
```json
{
"content": "
Updated Welcome!
Thank you for joining us.
"
}
```
### Response
#### Success Response (200)
- **message** (string) - A success message indicating the template was updated.
#### Response Example
```json
{
"message": "Template updated successfully."
}
```
```
--------------------------------
### List Templates using Python
Source: https://docs.ivandt.com/api/templates/listTemplates
Fetches all templates for an account using Python's `requests` library. This function makes a GET request and returns a list of dictionaries representing the templates. It includes basic error handling for the request.
```python
import requests
url = "https://api.ivandt.com/v1/templates"
try:
response = requests.get(url)
response.raise_for_status() # Raise an exception for bad status codes
templates = response.json()
print(templates)
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
--------------------------------
### Auto Increment IDs Transformer Examples (JavaScript)
Source: https://docs.ivandt.com/transformers/advanced
The autoIncrementIds transformer generates sequential numeric IDs for cells that are null, undefined, or empty strings. It skips hidden rows and allows customization of the starting value and increment step. Default values for start and step are 1.
```javascript
{
key: 'id',
label: 'ID',
type: 'numeric',
transformers: [
{
action: 'autoIncrementIds',
payload: {
start: 1000,
step: 10
}
}
]
}
```
```javascript
{
key: 'row_number',
label: 'Row number',
type: 'numeric',
transformers: [
{
action: 'autoIncrementIds'
}
]
}
```
--------------------------------
### Dropdown Field - Basic Usage
Source: https://docs.ivandt.com/fields/dropdown
Demonstrates the basic configuration of a dropdown field with static label-value pairs.
```APIDOC
## Dropdown Field - Basic Usage
### Description
Configures a dropdown field with a predefined list of options, each having a label and a value.
### Method
N/A (Configuration Object)
### Endpoint
N/A
### Parameters
#### Request Body
- **type** (string) - 'dropdown' - Specifies the field type.
- **label** (string) - The label displayed for the dropdown.
- **key** (string) - The unique identifier for the dropdown field.
- **order** (number) - The display order of the field.
- **options** (array) - An array of objects, where each object has a `label` (string) and a `value` (string).
### Request Example
```json
{
"type": "dropdown",
"label": "Product",
"key": "product",
"order": 0,
"options": [
{ "label": "iPhone 15", "value": "iphone-15" },
{ "label": "Samsung Galaxy S24", "value": "galaxy-s24" }
]
}
```
### Response
#### Success Response (200)
N/A (This is a configuration object, not an API endpoint response)
#### Response Example
N/A
```
--------------------------------
### Presign Download URL Generation (Go)
Source: https://docs.ivandt.com/api/files/presignDownload
Generates a presigned URL for downloading the original file associated with an import using Go. The URL is valid for 5 minutes.
```go
// Go example would go here if provided in the text.
```
--------------------------------
### Monetary Field Schema Example
Source: https://docs.ivandt.com/fields/monetary
This example shows how to define a schema for importing data with multiple monetary fields, including currency symbols, positions, and validators.
```typescript
import type { IvtSchema } from '@ivandt/importer';
const schema: IvtSchema = {
title: 'Product Import',
publicKey: 'pk_live_xxx',
sessionToken: 'session_xxx',
fields: [
{
type: 'monetary',
label: 'Price',
key: 'price',
order: 0,
locale: 'English (United States)',
validators: [
{ type: 'required' },
{ type: 'min', value: 0 }
]
},
{
type: 'monetary',
label: 'Cost',
key: 'cost',
order: 1,
locale: 'English (United Kingdom)',
currencySymbol: '£',
currencyPosition: 'prefix'
},
{
type: 'monetary',
label: 'Revenue',
key: 'revenue',
order: 2,
locale: 'English (United States)',
average: true,
description: 'Annual revenue'
}
]
};
```
--------------------------------
### Checkbox Field Example with Schema
Source: https://docs.ivandt.com/fields/checkbox
This TypeScript example demonstrates how to integrate a checkbox field within a larger schema for data import. It includes 'isActive', 'emailVerified', and 'marketingConsent' fields, showcasing default values and validators.
```typescript
import type { IvtSchema } from '@ivandt/importer';
const schema: IvtSchema = {
title: 'User Import',
publicKey: 'pk_live_xxx',
sessionToken: 'session_xxx',
fields: [
{
type: 'checkbox',
label: 'Is Active',
key: 'isActive',
order: 0,
defaultValue: true
},
{
type: 'checkbox',
label: 'Email Verified',
key: 'emailVerified',
order: 1,
validators: [
{ type: 'required' }
]
},
{
type: 'checkbox',
label: 'Marketing Consent',
key: 'marketingConsent',
order: 2,
description: 'User has agreed to receive marketing emails'
}
]
};
```
--------------------------------
### Delete Template API Request Examples
Source: https://docs.ivandt.com/api/templates/deleteTemplateById
Examples of how to delete a template using the ivandt API. This includes cURL, JavaScript, Go, Python, Java, and C# code snippets. Ensure you replace 'string' with the actual template ID.
```cURL
curl -X DELETE "https://api.ivandt.com/v1/templates/string"
```
```JavaScript
// JavaScript example would go here if provided in the source
```
```Go
// Go example would go here if provided in the source
```
```Python
# Python example would go here if provided in the source
```
```Java
// Java example would go here if provided in the source
```
```C#
// C# example would go here if provided in the source
```
--------------------------------
### Dropdown Field - DataSource Query
Source: https://docs.ivandt.com/fields/dropdown
Demonstrates configuring a dropdown field to fetch options dynamically using a DataSource query.
```APIDOC
## Dropdown Field - DataSource Query
### Description
Configures a dropdown field to populate its options by executing a DataSource query. The query is expected to return an array of objects, typically mapped to `label` and `value` fields.
### Method
N/A (Configuration Object)
### Endpoint
N/A
### Parameters
#### Request Body
- **type** (string) - 'dropdown' - Specifies the field type.
- **label** (string) - The label displayed for the dropdown.
- **key** (string) - The unique identifier for the dropdown field.
- **order** (number) - The display order of the field.
- **options** (object) - An object containing a `query` property.
- **query** (string) - The DataSource query string. Often uses mapping functions like `map({label:.name, value:.id})`.
### Request Example
```json
{
"type": "dropdown",
"label": "Product",
"key": "product",
"order": 0,
"options": {
"query": ".products | map({label:.name, value:.id})"
}
}
```
### Response
#### Success Response (200)
N/A
#### Response Example
N/A
```
--------------------------------
### Full Date Field Schema Example
Source: https://docs.ivandt.com/fields/date
This example showcases a comprehensive schema definition for importing data, including two date fields. It demonstrates setting format patterns, multiple parsing patterns, strict parsing, validators, and year ranges for date fields within an `IvtSchema`.
```javascript
import type { IvtSchema } from '@ivandt/importer';
const schema: IvtSchema = {
title: 'Employee Import',
publicKey: 'pk_live_xxx',
sessionToken: 'session_xxx',
fields: [
{
type: 'date',
label: 'Hire Date',
key: 'hireDate',
order: 0,
formatPattern: 'YYYY-MM-DD',
parsePatterns: [
'YYYY-MM-DD',
'DD/MM/YYYY',
'MM/DD/YYYY',
'YYYY/MM/DD'
],
strictParsing: true,
validators: [
{ type: 'required' }
]
},
{
type: 'date',
label: 'Birth Date',
key: 'birthDate',
order: 1,
formatPattern: 'DD/MM/YYYY',
parsePatterns: ['DD/MM/YYYY', 'DD-MM-YYYY'],
yearRange: [new Date(1940, 0, 1), new Date(2010, 11, 31)]
}
]
};
```
--------------------------------
### Dropdown Field - Static String Options
Source: https://docs.ivandt.com/fields/dropdown
Illustrates configuring a dropdown field using an array of simple strings as options.
```APIDOC
## Dropdown Field - Static String Options
### Description
Configures a dropdown field where options are provided as a simple array of strings. Each string serves as both the label and the value.
### Method
N/A (Configuration Object)
### Endpoint
N/A
### Parameters
#### Request Body
- **type** (string) - 'dropdown' - Specifies the field type.
- **label** (string) - The label displayed for the dropdown.
- **key** (string) - The unique identifier for the dropdown field.
- **order** (number) - The display order of the field.
- **options** (array) - An array of strings, where each string is an option.
### Request Example
```json
{
"type": "dropdown",
"label": "City",
"key": "city",
"order": 0,
"options": [
"New York",
"Los Angeles",
"Chicago"
]
}
```
### Response
#### Success Response (200)
N/A
#### Response Example
N/A
```