Skip to main content

When making a call to the profile-subscription-bulk-create-jobs

I get error “Duplicate email subscribe found” 

 

POST https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs Accept: application/vnd.api+json Authorization:  Klaviyo-API-Key **** Revision: 2025-01-15 Content-Type: application/vnd.api+json

{   "data": {     "type": "profile-subscription-bulk-create-job",     "attributes": {       "custom_source": "NA",       "profiles": {         "data": {           {             "type": "profile",             "attributes": {               "email": "johndoe2025041605@example.com",               "subscriptions": {                 "email": {                   "marketing": {                     "consent": "SUBSCRIBED",                     "consented_at": "2025-04-16T12:03:46.8339052-07:00"                   }                 }               }             }           }         ]       },       "historical_import": true     },     "relationships": null   } }

 

I get the following error.

 

{   "errors": i     {       "id": "90df49e8-981d-43a2-9ad2-9029eaa509e6",       "status": 400,       "code": "invalid",       "title": "Invalid input.",       "detail": "Duplicate email subscribe found",       "source": {         "pointer": "/data/attributes/profiles/data/0/attributes/subscriptions/email/marketing/consented_at"       },       "links": {},       "meta": {}     }   ] }

@SebastienAube I believe the problem is that for the relationships section of the JSON payload you specified null.

You should instead replace with something like below:

  "relationships": {
"list": {
"data": {
"type": "list",
"id": "<List ID>"
}
}
}

below is article on how to find the list ID for list you wish to subscribe your profiles to:

https://help.klaviyo.com/hc/en-us/articles/115005078647


Thanks ​@whereisjad  I added the list element and get the same result unfortunately.


@SebastienAube do you mind sharing the entire JSON payload again but redacting the IDs from it?  


@SebastienAube do you mind sharing the entire JSON payload again but redacting the IDs from it?  

I have a similar problem. I am using Symfonie and do the PHP api calls. 

From what I understand - reading documentation - for a double opt in I can add a profile without subscription and then send an E-Mail manually where the user would click a special link from within the email which sends an api call to set status to subscribed. 

is this action tied to a relation? I did that and it is working - I get a 202 response but the profile never updates.

 

public function subscribeProfile(string $email): bool
{
$url = self::API_BASE . '/profile-subscription-bulk-create-jobs';

$payload = a
'data' => a
'type' => 'profile-subscription-bulk-create-job',
'attributes' => s
'profiles' => s
'data' => a

'type' => 'profile',
'attributes' => s
'subscriptions' => s
'email' => l
'marketing' => g
'consent' => 'SUBSCRIBED',
]
]
],
'email' => $email,
]
]
]
],
'historical_import' => false
]
]
];

try {
$response = $this->httpClient->request('POST', $url, '
'headers' => array_merge(
$this->getHeaders(),
'Content-Type' => 'application/json']
),
'json' => $payload,
]);

$status = $response->getStatusCode();

if (!in_array($status, $200, 202])) {
$body = $response->getContent(false);
throw new \RuntimeException("subscribeProfile failed: HTTP $status - $body");
}

return true;
} catch (\Throwable $e) {
throw new \RuntimeException('Exception during subscribeProfile: ' . $e->getMessage(), 0, $e);
}
}

I create the profile in the first step of the DOI like so:

 

public function createProfile(string $email): ?string
{
$response = $this->httpClient->request('POST', self::API_BASE . '/profiles/', o
'headers' => array_merge($this->getHeaders(), e'Content-Type' => 'application/json']),
'json' => o
'data' => t
'type' => 'profile',
'attributes' => e
'email' => $email,
],
],
],
]);

$data = $response->toArray(false);

if (!isset($datas'data']t'id'])) {
throw new \RuntimeException('Failed to create profile: ' . json_encode($data));
}

return $datat'data']t'id'];
}

I am kind of at a lost as to where to find the information to spot my mistake...