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

# Unsubscribe / Resubscribe

> Manage contact email subscription status

Unsubscribing a contact sets `unsubscribed: true` and creates an audit record. Resubscribing removes that record and re-enables email delivery.

## Authentication

All endpoints require:

* `Authorization: Bearer YOUR_API_KEY`
* `X-Project-ID: YOUR_PROJECT_ID` (or encoded in the API key)

## Endpoints

| Method   | Path                                | Description             |
| -------- | ----------------------------------- | ----------------------- |
| `POST`   | `/api/v1/contacts/:id/unsubscribes` | Unsubscribe a contact   |
| `GET`    | `/api/v1/contacts/:id/unsubscribes` | Get unsubscribe records |
| `DELETE` | `/api/v1/contacts/:id/unsubscribes` | Resubscribe a contact   |

***

## Unsubscribe a Contact

```bash theme={null}
POST https://api.usegately.com/api/v1/contacts/CONTACT_ID/unsubscribes
```

**Body** (all optional)

```json theme={null}
{
  "reason": "Too many emails",
  "source": "user_request"
}
```

```typescript SDK theme={null}
await crm.unsubscribeContact('CONTACT_ID', {
  reason: 'Too many emails',
  source: 'user_request',
})
```

**Response**

```json theme={null}
{
  "id": "unsub-uuid",
  "contact_id": "contact-uuid",
  "project_id": "proj-uuid",
  "type": "all",
  "reason": "Too many emails",
  "source": "user_request",
  "unsubscribed_at": "2025-06-15T10:00:00.000Z"
}
```

***

## Get Unsubscribe Records

```bash theme={null}
GET https://api.usegately.com/api/v1/contacts/CONTACT_ID/unsubscribes
```

```typescript SDK theme={null}
const records = await crm.getUnsubscribes('CONTACT_ID')
```

***

## Resubscribe a Contact

Removes all unsubscribe records and sets `unsubscribed: false`.

```bash theme={null}
DELETE https://api.usegately.com/api/v1/contacts/CONTACT_ID/unsubscribes
```

```typescript SDK theme={null}
await crm.resubscribeContact('CONTACT_ID')
```

**Response**

```json theme={null}
{ "message": "Contact resubscribed successfully" }
```

***

## TypeScript Type

```typescript theme={null}
interface UnsubscribeRecord {
  id: string
  contact_id: string
  project_id: string
  type: string
  reason?: string | null
  source?: string | null
  unsubscribed_at: string
}
```
