How to Import Profiles

This article will guide you through performing a Profile Import in your APSIS One Account with the APSIS One API.

Profile Imports are performed by first creating an import specification, and then uploading a file matching the specification.

We allow three simultaneous imports per account

Profile Imports can be configured to handle Profile Attribute, Tag, Level of Consent, Consent List, Topic, Channel, and Keyspace mappings.

There are three essential parts to this guide:


Initialize Profile Import

Start by requesting a Profile Import.

When requesting an import, we need to define the import's mappings. These are the following parameters we need to know:

  • Section

  • Keyspace(s)

  • Merge Profiles (When true, Profiles belonging to the Keyspace will be merged with Profiles in other Keyspaces that are also set to true)

  • Consent(s)

  • Address

  • Channel(s)

  • Consent List

  • Topic(s)

  • Level of Consent

  • Tags

  • Attributes

  • Options:

  • Update existing Profiles. (If your file contains Attributes, Tags or any other data that differs from what is currently in a Profile, replace existing Profile data to match your file.)

  • Clear existing Attributes. (If your file contains an empty field that matches current Profile data, erase existing Profile data to match your file.)

  • Type of file (text/csv)

  • Field selector. (The value of this property is strictly connected to the column name in the CSV file.)

Not all parameters are required. Check the API Reference for more details

Per region host names

APSIS One API is provided under different hostnames depending on your region. For EU use https://api.apsis.one/, for APAC call https://api-apac.apsis.one/.

Let's initialize a Profile Import. In this case we'll import Profiles to the Email Keyspace:

curl --request POST\
  --url https://api.apsis.one/audience/sections/{section_discriminator}/imports \
  --header 'authorization: Bearer ' \
  --data '{
  {
  "keyspace_mappings": [
    {
      "keyspace_discriminator": "com.apsis1.keyspaces.email",
      "field_selector": "email-address",
      "merge_profiles": false
    }
  ],
  "options": {
    "update_existing_profiles": true,
    "clear_existing_attributes": true
  },
  "consent_mappings": [
    {
      "address_field_selector": "email-address",
      "consents": [
        {
          "resubscribe_if_opted_out": true,
          "field_selector": "mens-clothing-shoes",
          "channel_discriminator": "com.apsis1.channels.email",
          "consent_list_discriminator": "usercreated.targets.fashion-ufk6unuwec",
          "topic_discriminator": "usercreated.topics.menclothing-bcjvwfknxd",
          "type": "opt-in"
        },
        {
          "resubscribe_if_opted_out": true,
          "field_selector": "womans-clothing-shoes",
          "channel_discriminator": "com.apsis1.channels.email",
          "consent_list_discriminator": "usercreated.targets.fashion-ufk6unuwec",
          "topic_discriminator": "usercreated.topics.womanclothing-bcjvwefwfw",
          "type": "opt-in"
        }
      ]
    }
      ]
    }
  ],
  "tag_mappings": [
    {
      "tag_discriminator": "usercreated.attributes.vip-npqjeo3mbb"
    }
  ],
  "attribute_mappings": [
    {
      "field_selector": "address",
      "attribute_version_id": "1234"
    },
    {
      "field_selector": "email-address",
      "attribute_version_id": "4567"
    }
  ]
}

A successful call will return the following JSON object.

{
  "import_id": "234345345-c862-4a48-45455-7da1ac0e31ew",
  "file_upload_url": "https://s3.eu-west-1.amazonaws.com/file-import-uploads",
  "file_upload_body": {
    "key": "string",
    "success_action_status": "string",
    "policy": "string",
    "content-type": "string",
    "x-amz-meta-id": "string",
    "x-amz-algorithm": "string",
    "x-amz-credential": "string",
    "x-amz-date": "string",
    "x-amz-signature": "string"
  },
  "file_upload_url_expires_at": "2017-07-21T17:32:28Z"
}

Upload Import File

Let's continue with the second part of the guide, where we upload a file for the Profile Import to process.

Let's take a look at our example CSV file.

email-address

mens-clothing-shoes

address

stave@apsis.com

1

Malmo

oden@apsis.com

0

Copenhagen

freja@apsis.com

0

Stockholm

When the Profile Import was initialized, we were given a URL to upload the file. This parameter can be found in the response data named file_upload_url.

A successful call will return a HTTP 200 OK status code.

Let's upload our CSV file with a simple script.

Python

import requests
fileToImport = open('profiles.csv', 'rb')
files = {
  'file': fileToImport
}
try:
    response = requests.post('https://s3.eu-west-1.amazonaws.com/file-import-uploads-038131127654-stage',
        data = {
        "key": "48916/9d192ca9-bd91-4962-a53e-0f9c055666cc.csv",
        "success_action_status": "200",
        "content-type": "text/csv",
        "policy": "eyJleHBpcmF0aW9uIjoiMjAyMC0wMi0xNFQxMDo0MzozMloiLCJjb25kaXRpb25zIjpbeyJrZXkiOiI0ODkxNi85ZDE5MmNhOS1iZDkxLTQ5NjItYTUzZS0wZjljMDU1NjY2Y2MuY3N2In0seyJzdWNjZXNzX2FjdGlvbl9zdGF0dXMiOiIyMDAifSx7IkNvbnRlbnQtVHlwZSI6InRleHQvY3N2In0seyJYLUFtei1NZXRhLUlkIjoiNGEraDRLR0I1SWFzNFlTVzFwRGh0cURpdUtUa29LVG1pS0hqb2Fqa2hhem1nWTNrZ2JyRWp1T0dyT0d1b09hZHBPS0FvK0tFb09LWG11S3dwT2VMZ09HR3BlU0JyT0Nqb2VPaG9PR0hpdUN1bHVTSW9PS3hqTU80NWJTcDVJQ2w0NENtNDRTRTRZQ2c1b0NtNDRhQnk0N2l1b1p1YUFnIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMSw1MjQyODgwMDBdLHsiaWiJ9XX0=",
        "x-amz-algorithm": "AWS4-HMAC-SHA256",
        "x-amz-credential": "AKIAQRYGK2VTEOFC6HRW/20200214/eu-west-1/s3/aws4_request",
        "x-amz-date": "20200214T094332Z",
        "x-amz-meta-id": "4a+h4KGB5Ias4YSW1pDhtqDiuKTkoKTmiKHjoajkhazmgY3kgbrEjuOGrOGuoOadpOKAo+KEoOKXmuKwpOeLgOGGpeSBrOCjoeOhoOGHiuCuluSIoOKxjMO45bSp5ICl44Cm44SE4YCg5oCm44aBy47iuoTlu4jhgKHjuaAg",
        "x-amz-signature": "d46767995586e37ffed0d1a0f0a65cfb928ee2d99ab9e32995c2a80c7e7d7363"
  },
  files = files)
    print(response.status_code)
    print(response.text)
finally:
    fileToImport.close()

cURL

curl --location --request POST 'https://s3.eu-west-1.amazonaws.com/file-import-uploads-038131127654-stage' \
--header 'Content-Type: multipart/form-data' \
--form 'key=48916/9d192ca9-bd91-4962-a53e-0f9c055666cc.csv' \
--form 'success_action_status=200' \
--form 'content-type=text/csv' \
--form 'policy=eyJleHBpcmF0aW9uIjoiMjAyMC0wMi0xNFQxMDo0MzozMloiLCJjb25kaXRpb25zIjpbeyJrZXkiOiI0ODkxNi85ZDE5MmNhOS1iZDkxLTQ5NjItYTUzZS0wZjljMDU1NjY2Y2MuY3N2In0seyJzdWNjZXNzX2FjdGlvbl9zdGF0dXMiOiIyMDAifSx7IkNvbnRlbnQtVHlwZSI6InRleHQvY3N2In0seyJYLUFtei1NZXRhLUlkIjoiNGEraDRLR0I1SWFzNFlTVzFwRGh0cURpdUtUa29LVG1pS0hqb2Fqa2hhem1nWTNrZ2JyRWp1T0dyT0d1b09hZHBPS0FvK0tFb09LWG11S3dwT2VMZ09HR3BlU0JyT0Nqb2VPaG9PR0hpdUN1bHVTSW9PS3hqTU80NWJTcDVJQ2w0NENtNDRTRTRZQ2c1b0NtNDRhQnk0N2l1b1p1YUFnIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMSw1MjQyODgwMDBdLHsiaWiJ9XX0=' \
--form 'x-amz-algorithm=AWS4-HMAC-SHA256' \
--form 'x-amz-credential=AKIAQRYGK2VTEOFC6HRW/20200214/eu-west-1/s3/aws4_request' \
--form 'x-amz-date=20200214T094332Z' \
--form 'x-amz-meta-id=4a+h4KGB5Ias4YSW1pDhtqDiuKTkoKTmiKHjoajkhazmgY3kgbrEjuOGrOGuoOadpOKAo+KEoOKXmuKwpOeLgOGGpeSBrOCjoeOhoOGHiuCuluSIoOKxjMO45bSp5ICl44Cm44SE4YCg5oCm44aBy47iuoTlu4jhgKHjuaAg' \
--form 'x-amz-signature=d46767995586e37ffed0d1a0f0a65cfb928ee2d99ab9e32995c2a80c7e7d7363' \
--form 'file=@/Users/username/Desktop/profiles.csv'

Fetch Import Status

When we initialised the Profile Import, we were given an Import ID that will allow us to get the status of an Import.

The status of an Import can give valuable information, like whether the job is completed, in progress, waiting for a file, or queued. When the Import is completed, we can see how many Profiles were found, processed, and how many failed.

curl --request GET \
  --url https://api.apsis.one/audience/sections/{section_discriminator}/imports/{import_id} \
  --header 'authorization: Bearer '

A successful call will return the following JSON object.

{
  "import_id": "234345345-c862-4a48-45455-7da1ac0e31ew",
  "result": {
    "status": "completed",
    "profiles_found": 3,
    "profiles_processed": 3,
    "profiles_failed": 0
  }
}
Did this answer your question?