> ## 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.

# Bulk Suppress Emails

> Add multiple email addresses to a suppression group in bulk using the AutoSend API.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.autosend.com/v1/suppression-groups/emails/suppress' \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "emails": ["user@example.com", "another@example.com"],
      "groupId": "AB12C3",
      "reason": "unsubscribed",
      "isGlobal": false
    }'
  ```

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

  response = requests.post(
      "https://api.autosend.com/v1/suppression-groups/emails/suppress",
      headers={
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
      },
      json={
          "emails": ["user@example.com", "another@example.com"],
          "groupId": "AB12C3",
          "reason": "unsubscribed",
          "isGlobal": False,
      },
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.autosend.com/v1/suppression-groups/emails/suppress",
    {
      method: "POST",
      headers: {
        Authorization: "Bearer <token>",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        emails: ["user@example.com", "another@example.com"],
        groupId: "AB12C3",
        reason: "unsubscribed",
        isGlobal: false,
      }),
    }
  );
  const data = await response.json();
  console.log(data);
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://api.autosend.com/v1/suppression-groups/emails/suppress");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
      "emails"   => ["user@example.com", "another@example.com"],
      "groupId"  => "AB12C3",
      "reason"   => "unsubscribed",
      "isGlobal" => false,
  ]));
  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"
      "io"
      "net/http"
  )

  func main() {
      payload, _ := json.Marshal(map[string]interface{}{
          "emails":   []string{"user@example.com", "another@example.com"},
          "groupId":  "AB12C3",
          "reason":   "unsubscribed",
          "isGlobal": false,
      })

      req, _ := http.NewRequest("POST", "https://api.autosend.com/v1/suppression-groups/emails/suppress", bytes.NewBuffer(payload))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      body, _ := io.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.*;

  public class Main {
      public static void main(String[] args) throws Exception {
          String body = """
              {
                "emails": ["user@example.com", "another@example.com"],
                "groupId": "AB12C3",
                "reason": "unsubscribed",
                "isGlobal": false
              }
              """;

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://api.autosend.com/v1/suppression-groups/emails/suppress"))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(body))
              .build();

          HttpResponse<String> response = HttpClient.newHttpClient()
              .send(request, HttpResponse.BodyHandlers.ofString());
          System.out.println(response.body());
      }
  }
  ```

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

  uri = URI("https://api.autosend.com/v1/suppression-groups/emails/suppress")
  req = Net::HTTP::Post.new(uri)
  req["Authorization"] = "Bearer <token>"
  req["Content-Type"] = "application/json"
  req.body = {
    emails:   ["user@example.com", "another@example.com"],
    groupId:  "AB12C3",
    reason:   "unsubscribed",
    isGlobal: false,
  }.to_json

  response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "suppressed": 2
    }
  }
  ```
</ResponseExample>

### Authorizations

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

#### Body

<ParamField body="emails" type="string[]" required>
  An array of valid email addresses to suppress. Must contain at least one address.
</ParamField>

<ParamField body="groupId" type="string">
  The ID of the suppression group to add the addresses to. Omit to add to the default group.
</ParamField>

<ParamField body="reason" type="string">
  The reason for suppression (e.g. `unsubscribed`, `bounced`, `spam_complaint`). Stored on each entry for reporting.
</ParamField>

<ParamField body="isGlobal" type="boolean">
  When `true`, adds the entries to the global suppression list rather than a project-specific group.
</ParamField>


## OpenAPI

````yaml POST /suppression-groups/emails/suppress
openapi: 3.1.0
info:
  title: Suppression Groups API
  version: 1.0.0
  description: >-
    Manage suppression groups and suppression entries. Suppression groups let
    you categorize unsubscribes, bounces, and spam complaints so that you can
    control which emails are sent to which contacts.
servers:
  - url: https://api.autosend.com/v1
    description: Production
security:
  - bearerAuth: []
paths:
  /suppression-groups/emails/suppress:
    post:
      summary: Bulk Suppress Emails
      description: Adds one or more email addresses to a suppression group.
      operationId: bulkSuppressEmails
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - emails
              properties:
                emails:
                  type: array
                  minItems: 1
                  items:
                    type: string
                    format: email
                  example:
                    - user@example.com
                    - another@example.com
                groupId:
                  type: string
                  example: AB12C3
                reason:
                  type: string
                  example: unsubscribed
                isGlobal:
                  type: boolean
                  example: false
      responses:
        '200':
          description: Emails suppressed successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      suppressed:
                        type: integer
                        example: 2
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your auth token.

````