# Update a category's tracking rule (/docs/api-reference/tracking/update-tracking-category)

Sets the rule for emails sent with this `category`, which wins over the environment default, e.g. to track `marketing` but never `password-reset`. Fields left out keep their value; a new rule is created with them off. Settings belong to the API key's own environment: a `coss_test_…` key only ever changes sandbox settings. Emails keep the settings that applied when they were sent.

`PATCH https://api.coss.com/v1/tracking_settings/categories/{category}`

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

## Path parameters

- `category` (string, required): The category, as sent in `category`.

## Request body

- `opens` (boolean): Track opens.
- `clicks` (boolean): Track clicks.
- `unsubscribe` (boolean): Add one-click unsubscribe headers to emails with a category and a single recipient.

## 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.tracking.updateCategory("password-reset", {
  opens: false,
  clicks: false,
});
```

HTTP:

```sh
curl -X PATCH "https://api.coss.com/v1/tracking_settings/categories/password-reset" \
  -H "Authorization: Bearer $COSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "opens": false,
  "clicks": false
}'
```

Python:

```python
from coss import Coss

client = Coss()  # api_key= or COSS_API_KEY

client.email.tracking.update_category(
    category="password-reset",
    opens=False,
    clicks=False,
)
```

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.UpdateCategoryTrackingRequest{
    Category: "password-reset",
    Body: &coss.UpdateTrackingRuleRequest{
        Opens: coss.Bool(
            false,
        ),
        Clicks: coss.Bool(
            false,
        ),
    },
}
client.Email.Tracking.UpdateCategory(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

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

client.email.tracking.update_category(
  category: "password-reset",
  opens: false,
  clicks: false
)
```

PHP:

```php
<?php

use Coss\Coss;
use Coss\Email\Tracking\Requests\UpdateCategoryTrackingRequest;
use Coss\Types\UpdateTrackingRuleRequest;

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

$client->email->tracking->updateCategory(
    'password-reset',
    new UpdateCategoryTrackingRequest([
        'body' => new UpdateTrackingRuleRequest([
            'opens' => false,
            'clicks' => false,
        ]),
    ]),
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.email.tracking.requests.UpdateCategoryTrackingRequest;
import com.coss.types.UpdateTrackingRuleRequest;

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

client.email().tracking().updateCategory(
    "password-reset",
    UpdateCategoryTrackingRequest
        .builder()
        .body(
            UpdateTrackingRuleRequest
                .builder()
                .opens(false)
                .clicks(false)
                .build()
        )
        .build()
);
```

.NET:

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

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

await client.Email.Tracking.UpdateCategoryAsync(
    new UpdateCategoryTrackingRequest
    {
        Category = "password-reset",
        Body = new UpdateTrackingRuleRequest { Opens = false, Clicks = false },
    }
);
```

## Response 200

The category's rule.

- `object` ("tracking_rule", required)
- `id` (string, required)
- `category` (string | null, required): The category the rule applies to; `null` for the environment default.
- `opens` (boolean, required): Whether opens are tracked.
- `clicks` (boolean, required): Whether clicks are tracked.
- `unsubscribe` (boolean, required): Whether emails get one-click unsubscribe headers (only emails with a category and a single recipient).
- `created_at` (string, required, date-time)
- `updated_at` (string, required, date-time)

Example:

```json
{
  "object": "tracking_rule",
  "id": "etr_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "category": "password-reset",
  "opens": false,
  "clicks": false,
  "unsubscribe": false,
  "created_at": "2026-01-16T10:00:00.000Z",
  "updated_at": "2026-01-16T10:00:00.000Z"
}
```

## 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`).
- `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 category or the body failed validation (`validation_error`, see `issues`).
- `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`).