APIs & Integrations

landland
Member

Cannot unsubscribe contact from contact list

When trying to unsubscribe a contact from a contact list following http://developers.hubspot.com/docs/methods/lists/remove_contact_from_list, I’m getting an error message:

Add/remove must contain at least one vid or email

I’ve tried both vid and email and both at the same time without any luck trying as a query parameter and in the request body. I’m not sure what I’m doing wrong so any help is appreciated. Here’s how I’m doing it:

                try {
                    response = HTTP.post("https://api.hubapi.com/contacts/v1/lists/" + membership['static-list-id'] + "/remove?vid=" + contactId + "&email=fake@test.com&hapikey=" + list.hubspot_key, {

                        headers: {
                            'content-type': 'application/json'
                        },
                        data: {
                            vid: contactId,
                            email: "fake@test.com"
                        }
                    });
                } catch (err) {
                    throw new Error("Failed to unsubscribe contact from list with HubSpot. " + err.message);
                }

Here’s the raw request and response:

I20160714-20:13:43.383(-4)? Request { port: 443,
I20160714-20:13:43.383(-4)? path: ‘/contacts/v1/lists/5/remove?vid=60&email=test@fake.com&hapikey=XXXXXX-0b03-4fa7-b469-XXXXXXXXX’,
I20160714-20:13:43.383(-4)? host: ‘api.hubapi.com’,
I20160714-20:13:43.383(-4)? href: ‘https://api.hubapi.com/contacts/v1/lists/5/remove?vid=60&email=test@fake.com&hapikey=XXXXXX-0b03-4fa...’,
I20160714-20:13:43.383(-4)? method: ‘POST’,
I20160714-20:13:43.383(-4)? headers:
I20160714-20:13:43.383(-4)? { ‘content-type’: ‘application/json’,
I20160714-20:13:43.384(-4)? host: ‘api.hubapi.com’,
I20160714-20:13:43.384(-4)? ‘content-length’: 38 },
I20160714-20:13:43.384(-4)? body: ‘{“vid”:60,“email”:“test@fake.com”}’ }
I20160714-20:13:43.387(-4)? Response { statusCode: 400,
I20160714-20:13:43.387(-4)? headers:
I20160714-20:13:43.387(-4)? { ‘access-control-allow-credentials’: ‘false’,
I20160714-20:13:43.387(-4)? ‘content-type’: ‘application/json; charset=UTF-8’,
I20160714-20:13:43.387(-4)? vary: ‘Accept-Encoding’,
I20160714-20:13:43.387(-4)? ‘content-length’: ‘186’,
I20160714-20:13:43.387(-4)? date: ‘Fri, 15 Jul 2016 00:13:43 GMT’,
I20160714-20:13:43.387(-4)? connection: ‘close’ },
I20160714-20:13:43.387(-4)? trailers: {},
I20160714-20:13:43.388(-4)? httpVersion: ‘1.1’,
I20160714-20:13:43.388(-4)? url: ‘’,
I20160714-20:13:43.388(-4)? method: null,
I20160714-20:13:43.388(-4)? body: ‘{“status”:“error”,“message”:“Add/remove must contain at least one vid or email”,“correlationId”:“b708bfa4-fe41-4669-a4d1-633c176e1dda”,“requestId”:“7b2e9c16-a4f4-4790-9de8-47d3857c16cb”}’ }

0 Upvotes
2 Replies 2
landland
Member

Cannot unsubscribe contact from contact list

Ok, thank you that worked!

0 Upvotes
jwebgordon
HubSpot Employee
HubSpot Employee

Cannot unsubscribe contact from contact list

Hi there, the format for the data payload should actually be a list of vids in a parameter called “vids” (you have that in there as the singular currently).

Try creating the data as:

data: {
   vids: [contactId]
}
0 Upvotes