Локалізовано за допомогою ШІ

Додати підписника

const response = await fetch('https://api.emailit.com/v2/audiences/aud_1234567890/subscribers', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    email: 'john.doe@example.com',
    first_name: 'Іван',
    last_name: 'Петренко',
    custom_fields: {
      company: 'ТОВ "Прогрес"',
      role: 'Розробник'
    }
  })
});

const result = await response.json();

Відповіді

{
  "object": "subscriber",
  "id": 1234567890,
  "audience_id": 1234567890,
  "contact_id": 1234567890,
  "email": "john.doe@example.com",
  "first_name": "Іван",
  "last_name": "Петренко",
  "custom_fields": {
    "company": "ТОВ \"Прогрес\"",
    "role": "Розробник"
  },
  "subscribed": true,
  "subscribed_at": "2021-01-01T00:00:00Z",
  "unsubscribed_at": null,
  "created_at": "2021-01-01T00:00:00Z",
  "updated_at": "2021-01-01T00:00:00Z"
}