# Import suppressions in bulk (/docs/api-reference/suppressions/import-suppressions)

Adds up to 1000 entries at once, with reason `import`. Each entry is validated on its own: invalid ones are skipped and listed in `invalid`, entries already on the list are left unchanged and counted in `existing`. Importing again is safe.

`POST https://api.coss.com/v1/suppressions/import`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Request body

- `subaccount` (string, 1-256 characters): Import into a sub-account's own list (its id or your uid) instead of the environment's.
- `suppressions` (object[], required, 1-1000 items): 1-1000 entries. Each one is validated on its own: invalid entries are skipped and reported in `invalid`, the rest are imported.
  - `address` (string, required): The address to suppress.
  - `scope` (string): `*` (the default) or a category.

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.email.suppressions.import({
  suppressions: [
    {
      address: "user@example.com",
    },
    {
      address: "other@example.com",
      scope: "marketing",
    },
  ],
});
```

HTTP:

```sh
curl -X POST "https://api.coss.com/v1/suppressions/import" \
  -H "Authorization: Bearer $COSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "suppressions": [
    {
      "address": "user@example.com"
    },
    {
      "address": "other@example.com",
      "scope": "marketing"
    }
  ]
}'
```

Python:

```python
from coss import Coss
from coss.email.suppressions import ImportSuppressionsRequestSuppressionsItem

client = Coss()  # api_key= or COSS_API_KEY

client.email.suppressions.import_(
    suppressions=[
        ImportSuppressionsRequestSuppressionsItem(
            address="user@example.com",
        ),
        ImportSuppressionsRequestSuppressionsItem(
            address="other@example.com",
            scope="marketing",
        )
    ],
)
```

Go:

```go
import (
	"context"

	coss "github.com/cosscom/coss-go"
	cossclient "github.com/cosscom/coss-go/client"
	email "github.com/cosscom/coss-go/email"
)

client := cossclient.NewClient() // option.WithAPIKey(…) or COSS_API_KEY

request := &email.ImportSuppressionsRequest{
    Suppressions: []*email.ImportSuppressionsRequestSuppressionsItem{
        &email.ImportSuppressionsRequestSuppressionsItem{
            Address: "user@example.com",
        },
        &email.ImportSuppressionsRequestSuppressionsItem{
            Address: "other@example.com",
            Scope: coss.String(
                "marketing",
            ),
        },
    },
}
client.Email.Suppressions.Import(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

client = Coss::Client.new # api_key: or COSS_API_KEY

client.email.suppressions.import(suppressions: [{
  address: "user@example.com"
}, {
  address: "other@example.com",
  scope: "marketing"
}])
```

PHP:

```php
<?php

use Coss\Coss;
use Coss\Email\Suppressions\Requests\ImportSuppressionsRequest;
use Coss\Email\Suppressions\Types\ImportSuppressionsRequestSuppressionsItem;

$client = new Coss(); // apiKey: or COSS_API_KEY

$client->email->suppressions->import(
    new ImportSuppressionsRequest([
        'suppressions' => [
            new ImportSuppressionsRequestSuppressionsItem([
                'address' => 'user@example.com',
            ]),
            new ImportSuppressionsRequestSuppressionsItem([
                'address' => 'other@example.com',
                'scope' => 'marketing',
            ]),
        ],
    ]),
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.email.suppressions.requests.ImportSuppressionsRequest;
import com.coss.resources.email.suppressions.types.ImportSuppressionsRequestSuppressionsItem;
import java.util.Arrays;

Coss client = Coss.builder().build(); // .apiKey(…) or COSS_API_KEY

client.email().suppressions().import_(
    ImportSuppressionsRequest
        .builder()
        .suppressions(
            Arrays.asList(
                ImportSuppressionsRequestSuppressionsItem
                    .builder()
                    .address("user@example.com")
                    .build(),
                ImportSuppressionsRequestSuppressionsItem
                    .builder()
                    .address("other@example.com")
                    .scope("marketing")
                    .build()
            )
        )
        .build()
);
```

.NET:

```csharp
using Coss;
using Coss.Email;

var client = new CossClient(); // apiKey: or COSS_API_KEY

await client.Email.Suppressions.ImportAsync(
    new ImportSuppressionsRequest
    {
        Suppressions = new List<ImportSuppressionsRequestSuppressionsItem>()
        {
            new ImportSuppressionsRequestSuppressionsItem { Address = "user@example.com" },
            new ImportSuppressionsRequestSuppressionsItem
            {
                Address = "other@example.com",
                Scope = "marketing",
            },
        },
    }
);
```

## Response 200

What the import did.

- `object` ("suppression_import", required)
- `created` (integer, required): Entries added by this import.
- `existing` (integer, required): Valid entries that were already on the list (or repeated within this import); unchanged.
- `invalid` (object[], required): Entries that were skipped, with the reason.
  - `index` (integer, required): Position of the entry in the request.
  - `address` (string, required)
  - `message` (string, required)

Example:

```json
{
  "object": "suppression_import",
  "created": 2,
  "existing": 0,
  "invalid": []
}
```

## Errors

- `400`: The body is not valid JSON (`invalid_json`). Also when the `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `404`: `subaccount` names no sub-account of the API key's environment (`subaccount_not_found`).
- `413`: The request body is larger than 5 MB (`payload_too_large`).
- `415`: The body is not sent as `application/json` (`unsupported_media_type`).
- `422`: The body is not a list of 1-1000 `{ address, scope? }` objects (`validation_error`).
- `429`: Too many requests with this API key (`rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds. Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the limit is fully restored).
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The API key could not be verified right now; retry (`service_unavailable`).