Skip to main content
Import Profiles with Apsis One API
Rikke Søndergaard avatar
Written by Rikke Søndergaard
Updated over a week ago

Using Apsis One API

Apart from importing Profiles with the file import wizard in Audience, you can use Apsis One API for Profile imports. Using the API, you first create an import specification, and then upload 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, Folder, Subscription, Channel, and Keyspace mappings.


In this Article


Request Profile Import

Start by requesting a Profile Import. You need to define the import mapping, for the following parameters:

  • 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)

  • Folder(s)

  • Subscription(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/.

Initiate an import of Profiles to the Email Keyspace:

curl --request POST \
--url https://api.apsis.one/v2/audience/sections/section_discriminator/imports \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"keyspace_mapping": {
"keyspace_discriminator": "com.apsis1.keyspaces.email",
"field_selector": "email-address"
},
"options": {
"update_existing_profiles": true,
"clear_existing_attributes": true
},
"consent_mappings": [
{
"consents": [
{
"resubscribe_if_opted_out": false,
"field_selector": "mens-clothing-shoes",
"channel_discriminator": "com.apsis1.channels.email",
"topic_discriminator": "usercreated.topics.shoes-bcjvwfknxd",
"type": "opt-in"
}
]
}
],
"tag_mappings": [
{
"tag_discriminator": "usercreated.attributes.vip-npqjeo3mbb"
}
],
"attribute_mappings": [
{
"field_selector": "address",
"attribute_version_id": "1234"
}
]
}

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:28.761Z"
}

Upload File

In the second part of the guide, you upload a file.

Example of CSV file.

email-address

mens-clothing-shoes

address

1

Malmo

0

Copenhagen

0

Stockholm

When the Profile import was initialised, you were provided 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.

Upload your 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, you were provided an import ID that will allow you to get the status.

The status can give valuable information, like whether the job is completed, in progress, waiting for a file, or queued. When completed, you 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
  }
}

What's Next?

Did this answer your question?