`https://lumail.io/api/v1/subscribers/{subscriber}`

Updates an existing subscriber by ID or email address. You can modify their details, custom fields, and assigned tags.

## Response

- **Success (200 OK)** - Returns the updated subscriber object.
- **Error (404 Not Found)** - Returned if the subscriber does not exist.

## Response Fields

| Field                    | Type           | Description                                         |
| ------------------------ | -------------- | --------------------------------------------------- |
| `success`                | boolean        | Indicates if the operation was successful           |
| `subscriber`             | object         | The updated subscriber object                       |
| `subscriber.id`          | string         | Unique identifier for the subscriber                |
| `subscriber.email`       | string         | Email address of the subscriber                     |
| `subscriber.name`        | string or null | Name of the subscriber (if provided)                |
| `subscriber.phone`       | string or null | Phone number of the subscriber (if provided)        |
| `subscriber.status`      | string         | Current status of the subscriber                    |
| `subscriber.tags`        | array          | Array of tag objects associated with the subscriber |
| `subscriber.tags[].id`   | string         | Unique identifier for the tag                       |
| `subscriber.tags[].name` | string         | Name of the tag                                     |
| `subscriber.fields`      | object         | Custom field values associated with this subscriber |

## Request Schema

| Field              | Type     | Default  | Description                                                                                                                                                     |
| ------------------ | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `email`            | string   | required | Email address of the subscriber                                                                                                                                 |
| `name`             | string   | optional | Name of the subscriber                                                                                                                                          |
| `phone`            | string   | optional | Phone number of the subscriber                                                                                                                                  |
| `tags`             | string[] | `[]`     | Tag names to add to the subscriber                                                                                                                              |
| `fields`           | object   | optional | Custom field values (key-value pairs)                                                                                                                           |
| `replaceTags`      | boolean  | `false`  | If `true`, replaces all existing tags with the provided ones                                                                                                    |
| `resubscribe`      | boolean  | `false`  | If `true`, resubscribes the user if they were previously unsubscribed. By default, unsubscribed users stay unsubscribed                                         |
| `triggerWorkflows` | boolean  | `true`   | If `false`, skip triggering workflows even if subscriber's tags match workflow triggers. Useful for bulk updates or syncing data without triggering automations |
| `skipDoubleOptIn`  | boolean  | `false`  | If `true`, promote an existing `PENDING_CONFIRMATION` contact to `SUBSCRIBED` before tag events. Does not resubscribe `UNSUBSCRIBED` unless `resubscribe` is also true. |

## Usage Example

Use this API endpoint to update subscriber information such as:

- Update a subscriber's name or contact details
- Add or remove tags to change subscriber categorization
- Update custom field values for personalization or segmentation
- Modify subscriber information after form submissions or user profile updates
- Sync subscriber data between different systems

## Related Documentation

- [Add Tags to Subscriber](/docs/api-reference/api-subscriber-tags-post) - Add tags to subscribers
- [Remove Tags from Subscriber](/docs/api-reference/api-subscriber-tags-delete) - Remove tags from subscribers
- [Workflows](/docs/workflows) - Control workflow triggering with `triggerWorkflows`
- [Dynamic Promo Codes](/docs/tutorials/dynamic-promo-codes) - Update subscribers with webhook responses
- [Subscriber Events](/docs/features/subscriber-events) - View field update history


## API Reference
**Method:** PATCH
**Endpoint:** /api/v1/subscribers/{subscriber}

### SDK
```ts
import { Lumail } from "lumail";
const lumail = new Lumail({ apiKey: "YOUR_API_TOKEN" });

// Update by ID or email
const { subscriber } = await lumail.subscribers.update("subscriber@example.com", {
  name: "John Smith",
  tags: ["newsletter", "product-updates"],
  fields: { company: "New Company Inc" },
  replaceTags: true,
});
console.log(subscriber);
```

### cURL
```bash
curl -X PATCH https://lumail.io/api/v1/subscribers/sub_TTYPR5tWDh \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Smith",
    "tags": ["newsletter", "product-updates"],
    "fields": {
      "company": "New Company Inc"
    }
  }'

# Or using email
curl -X PATCH https://lumail.io/api/v1/subscribers/subscriber@example.com \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Smith",
    "tags": ["newsletter", "product-updates"],
    "replaceTags": true
  }'
```

### JavaScript
```javascript
// Using subscriber ID
const response = await fetch('https://lumail.io/api/v1/subscribers/sub_TTYPR5tWDh', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'John Smith',
    tags: ['newsletter', 'product-updates'],
    fields: {
      company: 'New Company Inc'
    }
  }),
});

const data = await response.json();
console.log(data);
```

### Python
```python
import requests

url = "https://lumail.io/api/v1/subscribers/subscriber@example.com"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
payload = {
    "name": "John Smith",
    "tags": ["newsletter", "product-updates"],
    "fields": {
        "company": "New Company Inc"
    },
    "replaceTags": True
}

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

### Success Response
```json
{
  "success": true,
  "subscriber": {
    "id": "sub_TTYPR5tWDh",
    "email": "subscriber@example.com",
    "name": "John Smith",
    "phone": "+1234567890",
    "status": "SUBSCRIBED",
    "tags": [
      {
        "id": "tag_JqaddtEx7z",
        "name": "newsletter"
      },
      {
        "id": "tag_kL9pqRs2tU",
        "name": "product-updates"
      }
    ],
    "fields": {
      "city": "New York",
      "company": "New Company Inc"
    }
  }
}
```

### Error Response
```json
{
  "message": "Subscriber not found"
}
```
