Solved

Spawn Bulk Profile Import endpoint is creating profiles, but not adding them to the list.

  • 11 March 2024
  • 4 replies
  • 34 views

Badge

Hey all,

 

We have a service that’s syncing external contacts to Klaviyo. It’s currently using the legacy api endpoint:

POST /api/v2/list/{list_id}/members (documentation)

I am trying to migrate to the new API (as per this documentation) to following endpoint:

POST /api/profile-bulk-import-jobs (documentation)

The endpoint is working as expected in terms of creating/ updating profile, however it’s not adding the profiles to the desired list

Any help would be appreciated. Curl request below:


Curl request:

curl --request POST \
  --url 'https://a.klaviyo.com/api/profile-bulk-import-jobs/?=' \
  --header 'Authorization: Klaviyo-API-Key <apiKey>' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/8.6.1' \
  --header 'accept: application/json' \
  --header 'revision: 2024-02-15' \
  --data '{
  "data": {
    "type": "profile-bulk-import-job",
    "attributes": {
      "profiles": {
          "data": [
            {
              "type": "profile",
              "attributes": {
                "email": "jane.doe@klaviyo.com",
                                "properties": {
                                    "recommended_product_1": "Brown Axe"
                                }
              }
                            
            },
            {
              "type": "profile",
              "attributes": {
                "email": "john.doe@klaviyo.com",
                            "properties": {
                                "recommended_product_1": "Black Axe"
                            }
              }
            }
          ]
        }
      }
    },
    "relationships": {
      "lists": {
        "data": [{
          "type": "list",
          "id": "<listId>"
      }]
    }
  }
}
'

icon

Best answer by Kim Strauch 11 March 2024, 21:28

View original

4 replies

Userlevel 4
Badge +7

Hi @drewdeveloper,

2 things to check here:

  1. Make sure the relationships argument is at the same hierarchical level as attributes. Based on the code you pasted, it looks like `relationships` is top-level (same hierarchical status as `data`). It should be nested within data so it’s `data.attributes` and `data.relationships`.
  2. If you created a new list, make sure your list has single opt-in enabled. You could be adding people to your list, but they’re not showing up because you have double opt-in (more: https://help.klaviyo.com/hc/en-us/articles/115005251108)

Best,

Kevin.

Badge

Thank you @KeviSunshine Yes the hierarchical level of the relationships argument was off.

Userlevel 3
Badge +4

One quick thing to note: the bulk profile import API will add profiles to the list regardless of the opt-in setting on the list; similar to Add Profiles to a List, this API will add profiles to a list but doesn’t update their consent status. The opt-in setting is a great callout for the subscribe profiles API.
 

@KeviSunshine, part 1 of your answer is spot on. Great catch!

Userlevel 4
Badge +7

Good to know! Thank you @Kim Strauch.

Reply