# removing contact from a list

**URL:** <https://community.hubspot.com/t/removing-contact-from-a-list/107616>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [May 21, 2024, 9:40am UTC](https://community.hubspot.com/t/removing-contact-from-a-list/107616 "2024-05-21T09:40:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prakashreddy](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@Prakashreddy](https://community.hubspot.com/u/Prakashreddy)\
**Post date:** [May 21, 2024, 9:40am UTC](https://community.hubspot.com/t/removing-contact-from-a-list/107616/1 "2024-05-21T09:40:16Z")

</div>

Hi,

i have a list with name “Verdict - Membership and Subscription Data” with list id 17945.

i am trying to delist a contact from thelist using api.. below is the code.

$curl = curl\_init();  
curl\_setopt\_array($curl, array(  
CURLOPT\_URL =\> “[https://api.hubapi.com/crm/v3/lists/“.$list\_id.”/memberships/remove](https://api.hubapi.com/crm/v3/lists/%22.$list%5C_id.%22/memberships/remove)”,  
CURLOPT\_RETURNTRANSFER =\> true,  
CURLOPT\_ENCODING =\> “”,  
CURLOPT\_MAXREDIRS =\> 10,  
CURLOPT\_TIMEOUT =\> 30,  
CURLOPT\_HTTP\_VERSION =\> CURL\_HTTP\_VERSION\_1\_1,  
CURLOPT\_CUSTOMREQUEST =\> “PUT”,  
CURLOPT\_POSTFIELDS =\>“[”.$contact\_id.“]”,  
CURLOPT\_HTTPHEADER =\> array(  
"Authorization: Bearer ".$hubspot\_auth,  
“accept: application/json”,  
“content-type: application/json”  
),  
));

i m reciving the below error. do we need any permissions to perform this action pls helpme

`{"status":"error","message":"List does not exist with ID 17945.","correlationId":"fa79155b-974f-4c6b-9ae8-97af40ac9bb3","context":{"listId":["17945"]},"category":"OBJECT_NOT_FOUND","subCategory":"ListError.LIST_ID_DOES_NOT_EXIST"}`

---

<div class="post-metadata">

**Author:** ![james-portant](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/james-portant/32/104419_2.png) [@james-portant](https://community.hubspot.com/u/james-portant)\
**Post date:** [May 21, 2024, 1:41pm UTC](https://community.hubspot.com/t/removing-contact-from-a-list/107616/2 "2024-05-21T13:41:21Z")

</div>

Hi @Prakashreddy,

Hiow’s it going?

Here are a few steps to troubleshoot your current approach:

1. **Verify List ID:** Ensure that the list ID 17945 is correct. You can do this by checking the list in your HubSpot account.
2. **API Endpoint and Payload:** The API endpoint and the payload need to be correctly formatted. Specifically, the contact ID should be in a JSON array format.
3. **Permissions:** Ensure that your HubSpot API token has the necessary permissions to modify lists and contacts.

Here is an updated version of your code:

\<?php

$list\_id = “17945”; // Ensure this is the correct list ID  
$contact\_id = “CONTACT\_ID\_HERE”; // Replace with the actual contact ID  
$hubspot\_auth = “YOUR\_HUBSPOT\_AUTH\_TOKEN”; // Your HubSpot API token

$curl = curl\_init();

curl\_setopt\_array($curl, array(  
CURLOPT\_URL =\> “[https://api.hubapi.com/contacts/v1/lists/$list\_id/remove](https://api.hubapi.com/contacts/v1/lists/$list_id/remove)”,  
CURLOPT\_RETURNTRANSFER =\> true,  
CURLOPT\_ENCODING =\> “”,  
CURLOPT\_MAXREDIRS =\> 10,  
CURLOPT\_TIMEOUT =\> 30,  
CURLOPT\_HTTP\_VERSION =\> CURL\_HTTP\_VERSION\_1\_1,  
CURLOPT\_CUSTOMREQUEST =\> “POST”,  
CURLOPT\_POSTFIELDS =\> json\_encode(array(“vids” =\> array($contact\_id))),  
CURLOPT\_HTTPHEADER =\> array(  
“Authorization: Bearer $hubspot\_auth”,  
“accept: application/json”,  
“content-type: application/json”  
),  
));

$response = curl\_exec($curl);  
$err = curl\_error($curl);

curl\_close($curl);

if ($err) {  
echo “cURL Error #:” . $err;  
} else {  
echo $response;  
}  
?\>

- **Endpoint:** Use /contacts/v1/lists/:list\_id/remove for the removal action.
- **Payload:** The contact ID should be sent in a JSON format as an array under the key vids.
- **Method:** Use POST instead of PUT for this specific action.

Hopefully this helps track down the issue.  
Good luck,  
James - CEO @ [Portant  
 ](http://www.portant.co/)  
**Portant App for HubSpot:** [https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-in…](https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-integration)

---

<div class="post-metadata">

**Author:** ![Prakashreddy](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@Prakashreddy](https://community.hubspot.com/u/Prakashreddy)\
**Post date:** [May 21, 2024, 2:29pm UTC](https://community.hubspot.com/t/removing-contact-from-a-list/107616/3 "2024-05-21T14:29:43Z")

</div>

Thank you for your response.

i found 17945 list id type is dynamic..

can we remove contact from a dynamic list using api.

in one article i found we cann not remove contacts from a dynamic list..

pls confirm

Thank you

---

<div class="post-metadata">

**Author:** ![Prakashreddy](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@Prakashreddy](https://community.hubspot.com/u/Prakashreddy)\
**Post date:** [May 22, 2024, 12:22pm UTC](https://community.hubspot.com/t/removing-contact-from-a-list/107616/4 "2024-05-22T12:22:25Z")

</div>

i executed the code what u gave i got below response.

```auto
{"status":"error","message":"Api[name=inbounddb.listseg, httpMethod=POST, subPath=/inbounddb-lists/v1/static-lists/validated, correlationId=717ff9b3-e3df-4311-be95-5792b9292e03] Failed to process your request. Error code was '400'. Error message was:\n{\"status\":\"error\",\"message\":\"List 27808 has processing type DYNAMIC which is not allowed to be used in manual membership update processes.\",\"correlationId\":\"717ff9b3-e3df-4311-be95-5792b9292e03\"}","correlationId":"717ff9b3-e3df-4311-be95-5792b9292e03"}{"status":"error","message":"Api[name=inbounddb.listseg, httpMethod=POST, subPath=/inbounddb-lists/v1/static-lists/validated, correlationId=717ff9b3-e3df-4311-be95-5792b9292e03] Failed to process your request. Error code was '400'. Error message was:\n{\"status\":\"error\",\"message\":\"List 27808 has processing type DYNAMIC which is not allowed to be used in manual membership update processes.\",\"correlationId\":\"717ff9b3-e3df-4311-be95-5792b9292e03\"}","correlationId":"717ff9b3-e3df-4311-be95-5792b9292e03"}

```

my question is why in the response it mentioned List 27808

my list id is 17945 and i passed 17945 to the request.. is 27808 internal some reference number for that list id

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [May 21, 2024, 2:35pm UTC](https://community.hubspot.com/t/removing-contact-from-a-list/107616/5 "2024-05-21T14:35:31Z")

</div>

Hey, @Prakashreddy 👋 You are correct. Active (dynamic) lists use filters to include or exclude objects. You cannot delete contacts, for example, from an active list.

Best,

Jaycee
