Use the Import API to move the records from the uploaded profile data file into the WMI database. You can also delete customer data records using the Import API in Delete mode. This clears the customer data from both history and current profile.

Before using the Import API, your customer data must be encrypted and uploaded. See Encrypting and uploading customer data for upload

The Import API manages data imports into WMI. The service will access data in remote location (initially WMI provisioned tenant Object Storage) and process using Spark to update the customer profile database.

For details on using the Import API, refer to the WMI Import API in API Explorer

Notes:

  • When WMI was implemented in your organization, you establish the period used to analyze your data (day, week, month, year). Whichever period you selected, WMI does not retain more than 104 periods. For example, if your period is “week”, and you import weekly, only 2 years (104 weeks) are maintained in the system.
  • Do not use future dates for Period Start Date in the Import POST.
  • Do not use “\\” or “#” as column separators in the input file and in the Import POST.
  • Analytics are not reprocessed when customer records are deleted. The next data import results in reprocessing the analytics.
  • API Endpoints

    These are the endpoints available with the Import API.

    Endpoint Action Description
    /import GET Get a list of all imports previously requested.
    POST Creates and executes a new import. (restricted)
    import/{id} GET Gets details for an import.

    Import Parameters

    Use these parameters to define the import.

    Parameter Description
    mode

    The method used to apply the input data to the database

    merge: inserts new records and updates existing records, based on matching keys in the input file.

    truncate: truncates existing data in the specified history profile table and its current profile.

    replace: truncates all existing data and then inserts input data.

    append: inserts data into the table with no attempt to update. The entire data set is rejected if it contains any conflicting keys.

    reset_append: Drops and recreates the profile schema and metadata, and then appends data in the same way as append mode.

    delete: Deletes specified records from the system based on the customer IDs that are listed in the input file.

    profile Name of the target profile for the import.
    fields A list of fields to be updated in WMI by the import. Fields must be listed in the order they occur in the source file. To ignore a field in the source file, leave an empty item in the list (e.g. “field1,,field3”). Any additional fields at the end of the record in the source file are ignored. When in Delete mode, the customer records identified by the input data are deleted from the system. When using the delete mode, provide all business key columns except the PERIOD_START_DATE in the input file. For deleting a customer profile, provide only CUSTOMER_NO.
    source

    Source location of the input data – inline, objectStoreFile, or wca. The inline type is enabled only for Delete mode. See Input Data Fields for a complete list of parameters for Input Data.

    Input Data Fields

    Parameter Description

    type

     Specifies source type – inline, objectStoreFile, or wca. Must be objectStoreFile for Object Store source files. The inline type is enabled only for Delete mode.

    container

     Container containing the file to import.

    object

     Name of file object to import from the specified input data container.

    key

     Key to decrypt the file in the input data.

    delimiter

     (optional) Field delimiter. By default columns are delimited using , (comma) but can be set to any character.

    header

     (optional) Indicates if the source file contains a header record that should not be processed as input data. If omitted, the import is processed using a value of "false". For processing the data, the value of the fields parameter is used as the header for the data in the input file.

    quote

     (optional) Delimiters occurring inside quotes are ignored. By default the quote character is " (double quote) but can be set to any character.

    escape

     (optional) Quote characters preceded by the specified escape character ignored. By default the escape character is \ (backward slash) but can be set to any character.

    comment

     (optional) Lines beginning with the specified character are skipped. Default is "#". Setting to empty or null indicates no lines should be treated as comments.

    charset

     (optional) The character set encoding of the input data. Defaults to 'UTF-8' but can be set to other valid character set names.

    dateFormat

     (optional) The string format used for date fields. Follows the formats for java.text.SimpleDateFormat. This applies to both DateType and TimestampType. By default, it is null which means trying to parse times and date by java.sql.Timestamp.valueOf() and java.sql.Date.valueOf().

    Delete example for inline type

    
    // inline example
    { 
        "mode": "delete", 
        "source": { 
            "type": "inline", 
            "values": [["1761531"],["1761571"],["1761612"],["1761680"],["508907"],["508946"],["509094"],["16862"],["16859"],["1761612"]] 
        }, 
        "profile": "CUSTOMER_PROFILE_H", 
        "fields": ["CUSTOMER_NO"] 
    }
    
    

    Delete example for objectStoreFile type

    
    // Object Store example
    { 
        "mode": "delete", 
        "source": { 
            "type": "objectStoreFile", 
            "container": "CPTDemo", 
            "object": "CustomersToDelete.enc", 
            "header": "true", 
            "key": "3npGdTTnLIfyp8t-vg8XIHEAUtm1b7usz2wVrtx3kIs=" 
        }, 
        "profile": "CUSTOMER_PROFILE_H", 
        "fields": ["CUSTOMER_NO"] 
    }
    
    

    Delete example for wca type

    
    // wca example
    {
        "mode":"merge",
        "profile":"CUSTOMER_PROFILE_H",
        "source":{
            "type":"wca",
            "startDate":"2017-07-10"
        }
    }
    
    

    Replace example for objectStoreFile type

    
    // Replace example with Object Store
    {
        "mode": "replace",
        "profile": "customer_profile",
        "fields": ["CUSTOMER_NO","ABANDONED_CART_COUNT"],
        "source": {
            "type": "objectStoreFile",
            "container": "import",
            "object": "customer_profile_sample_encrypted.csv",
            "key": "RXdVfMMde6RlEU1WAmbRp7UrHeEEhlWhFmr4ZzdMf=",
            "header": "true"
        }
    }
    

    API Endpoint Examples

    Endpoint Action Example
    /import GET
    curl -X GET --header 'Accept: application/json' --header 'Authorization: APIKey yourapikeyvalue' 'https://wmi-rest-api-r1.watsonmarketinginsights.ibm.com/api/v1/import'
    POST
    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: APIKey yourapikeyvalue' -d 
    '{
        "mode": "replace",
        "profile": "customer_profile",
        "fields": ["CUSTOMER_NO","ABANDONED_CART_COUNT"],
        "source": {
            "type": "objectStoreFile",
            "container": "import",
            "object": "customer_profile_sample_encrypted.csv",
            "key": "RXdVfMMde6RlEU1WAmbRp7UrHeEEhlWhFmr4ZzdMf=",
            "header": "true"
        }
    }' 'https://wmi-rest-api-r1.watsonmarketinginsights.ibm.com/api/v1/import'
    import/{id} GET
    curl -X GET --header 'Accept: application/json' --header 'Authorization: APIKey yourapikeyvalue' https://wmi-rest-api-r1.watsonmarketinginsights.ibm.com/api/v1/import/b99d51e4-ee29-4e54-8c74-8327f3561c39'

    2 comments on"Import API Parameters and Examples"

    1. Hi,

      How can I stop an import task?

      • Hello Jorge,
        It depends on how you set your task up. If you set your task up through your Watson Campaign Organization, you will have to login to the Organization, then go to Resources > Data Jobs > Recurring Jobs and deactivate the task.

        If you set the task up via API on your side, then you will have to remove the connection on your side.

        Thank you
        Jeri

    Join The Discussion

    Your email address will not be published. Required fields are marked *