
## Enabling with single/double opt-in

Ensure that a [workflow for collecting newsletter agreements](/docs/settings/configuration/newsletter-sign-up) is running.  

Send a create/update API call with the `"newsletter_agreement_enabled": "enabled"` attribute.  
API reference is available [here](https://developers.synerise.com/ClientManagement/ClientManagement.html#operation/BatchAddOrUpdateClients).

<pre><code class="language-plaintext">curl --location --request POST 'https://{SYNERISE_API_BASE_PATH}/v4/clients/batch' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Api-Version: 4.4' \
--header 'Authorization: Bearer eyJ...G2DI' \
--data-raw '[
   {
      "clientId": 12345,
      "attributes": {
          "newsletter_agreement_enabled": "enabled"
      }
   }
]'</code></pre>


This information is processed in the following way:
1. The customer's profile is updated with the `'newsletter_agreement_enabled': 'enabled'` attribute.
2. An event with details of the profile update is created and triggers the [workflow that collects newsletter agreements](/docs/settings/configuration/newsletter-sign-up). 
3. One of the following happens:
   - If single opt-in is used, the agreement is enabled. Depending on the workflow configuration, the customer may receive an email with a notification.
   - If double opt-in is used, the customer receives an email and must click the link in that email to confirm the subscription.

## Enabling immediately

You can also immediately enable an agreement over the API, without asking for confirmation or notifying the customer.

If you use email address as a unique identifier, send a create/update API call with the `agreements.email` param set to `true`.

<pre><code class="language-plaintext">curl --location --request POST 'https://{SYNERISE_API_BASE_PATH}/v4/clients/batch' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Api-Version: 4.4' \
--header 'Authorization: Bearer eyJ...G2DI' \
--data-raw '[
   {
      "clientId": 12345,
      "agreements": {
         "email": true
         }
   }
]'</code></pre>


If you configured [non-unique emails](/docs/settings/configuration/non-unique-emails), send a create/update API call which changes the attribute you set as the agreement indicator to `enabled`

<pre><code class="language-plaintext">curl --location --request POST 'https://{SYNERISE_API_BASE_PATH}/v4/clients/batch' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Api-Version: 4.4' \
--header 'Authorization: Bearer eyJ...G2DI' \
--data-raw '[
   {
      "clientId": 12345,
      "attributes": {
         "the-newsletter-agreement-attribute-you-set-up": "enabled"
         }
   }
]'</code></pre>


The agreement is enabled immediately.


API reference is available [here](https://developers.synerise.com/ClientManagement/ClientManagement.html#operation/BatchAddOrUpdateClients).


## Disabling a newsletter agreement

If you use email address as a unique identifier, send a create/update API call with the `agreements.email` param set to `false`.
API reference is available [here](https://developers.synerise.com/ClientManagement/ClientManagement.html#operation/BatchAddOrUpdateClients).

<pre><code class="language-plaintext">curl --location --request POST 'https://{SYNERISE_API_BASE_PATH}/v4/clients/batch' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Api-Version: 4.4' \
--header 'Authorization: Bearer eyJ...G2DI' \
--data-raw '[
   {
      "clientId": 12345,
      "agreements": {
         "email": false
         }
   }
]'</code></pre>


If you configured [non-unique emails](/docs/settings/configuration/non-unique-emails), send a create/update API call which changes the attribute you set as the agreement indicator to `disabled`

<pre><code class="language-plaintext">curl --location --request POST 'https://{SYNERISE_API_BASE_PATH}/v4/clients/batch' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Api-Version: 4.4' \
--header 'Authorization: Bearer eyJ...G2DI' \
--data-raw '[
   {
      "clientId": 12345,
      "attributes": {
         "the-newsletter-agreement-attribute-you-set-up": "disabled"
         }
   }
]'</code></pre>


The agreement is disabled immediately.