> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autosend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Remove Contacts from List

> Remove one or more contacts from a specific contact list using the AutoSend API.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.autosend.com/v1/contact-lists/60d5ec49f1b2c72d9c8b4567/contacts/remove \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "emails": [
      "jane@example.com",
      "john@example.com"
    ]
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.autosend.com/v1/contact-lists/60d5ec49f1b2c72d9c8b4567/contacts/remove"

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  payload = {
      "emails": [
          "jane@example.com",
          "john@example.com"
      ]
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  fetch('https://api.autosend.com/v1/contact-lists/60d5ec49f1b2c72d9c8b4567/contacts/remove', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <token>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      emails: [
        'jane@example.com',
        'john@example.com'
      ]
    })
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```

  ```php PHP theme={null}
  <?php

  $contactListId = '60d5ec49f1b2c72d9c8b4567';
  $url = "https://api.autosend.com/v1/contact-lists/{$contactListId}/contacts/remove";

  $data = [
      'emails' => [
          'jane@example.com',
          'john@example.com'
      ]
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Authorization: Bearer <token>',
      'Content-Type: application/json'
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      url := "https://api.autosend.com/v1/contact-lists/60d5ec49f1b2c72d9c8b4567/contacts/remove"

      payload := map[string]interface{}{
          "emails": []string{
              "jane@example.com",
              "john@example.com",
          },
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          fmt.Println("Error:", err)
          return
      }
      defer resp.Body.Close()

      fmt.Println("Response Status:", resp.Status)
  }
  ```

  ```java Java theme={null}
  import java.io.OutputStream;
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.nio.charset.StandardCharsets;

  public class RemoveContacts {
      public static void main(String[] args) {
          try {
              URL url = new URL("https://api.autosend.com/v1/contact-lists/60d5ec49f1b2c72d9c8b4567/contacts/remove");
              HttpURLConnection con = (HttpURLConnection) url.openConnection();

              con.setRequestMethod("POST");
              con.setRequestProperty("Authorization", "Bearer <token>");
              con.setRequestProperty("Content-Type", "application/json");
              con.setDoOutput(true);

              String jsonInputString = "{\n" +
                  "  \"emails\": [\n" +
                  "    \"jane@example.com\",\n" +
                  "    \"john@example.com\"\n" +
                  "  ]\n" +
                  "}";

              try (OutputStream os = con.getOutputStream()) {
                  byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                  os.write(input, 0, input.length);
              }

              int status = con.getResponseCode();
              System.out.println("Response Status: " + status);

          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  uri = URI('https://api.autosend.com/v1/contact-lists/60d5ec49f1b2c72d9c8b4567/contacts/remove')

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri.path)
  request['Authorization'] = 'Bearer <token>'
  request['Content-Type'] = 'application/json'

  request.body = {
    emails: [
      'jane@example.com',
      'john@example.com'
    ]
  }.to_json

  response = http.request(request)
  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "removed": 2,
      "notInList": 0,
      "errors": []
    }
  }
  ```
</ResponseExample>

***

### Authorizations

<ParamField path="Authorizations" type="string | header" required>
  Bearer authentication header of the form Bearer `<token>`, where `<token>` is your auth token.
</ParamField>

### Path Parameters

<ParamField path="contactListId" type="string" required>
  The unique identifier of the contact list to remove contacts from.

  <Note>
    You cannot remove contacts from the global `GLOBAL_CONTACT_LIST`. Use the Delete Contact API instead.
  </Note>

  Example: `"60d5ec49f1b2c72d9c8b4567"`
</ParamField>

### Body

Remove contacts from a list by email addresses or contact IDs. Provide either `emails` or `contactIds`, not both.

<ParamField path="emails" type="string[]">
  Array of email addresses to remove from the list.

  Example:

  ```json theme={null}
  ["jane@example.com", "john@example.com"]
  ```
</ParamField>

<ParamField path="contactIds" type="string[]">
  Array of contact IDs to remove from the list.

  Example:

  ```json theme={null}
  ["60d5ec49f1b2c72d9c8b1111", "60d5ec49f1b2c72d9c8b2222"]
  ```
</ParamField>

### Response

<span className="text-sm">Contacts removed from list</span>

<ResponseField name="success" type="boolean">
  Indicates if the request was successful

  Example: `true`
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="child attributes">
    <ResponseField name="data.removed" type="integer">
      Number of contacts successfully removed from the list

      Example: `2`
    </ResponseField>

    <ResponseField name="data.notInList" type="integer">
      Number of contacts that were not in the list

      Example: `0`
    </ResponseField>

    <ResponseField name="data.errors" type="object[]">
      Array of errors for contacts that failed to be removed
    </ResponseField>
  </Expandable>
</ResponseField>


## OpenAPI

````yaml POST /contact-lists/{contactListId}/contacts/remove
openapi: 3.1.0
info:
  title: AutoSend API
  description: AutoSend REST API for managing contact lists and segments
  version: 1.0.0
servers:
  - url: https://api.autosend.com/v1
security:
  - bearerAuth: []
paths:
  /contact-lists/{contactListId}/contacts/remove:
    post:
      summary: Remove Contacts from List
      description: Remove contacts from a contact list by email addresses or contact IDs.
components: {}

````