# Update the marketing settings (/docs/api-reference/topics/update-marketing-settings)

Changes the fields given (`null` clears one).

`PATCH https://api.coss.com/v1/marketing_settings`

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

## Request body

- `display_name` (string | null, 1-200 characters): The sender's name in the preference center. `null`: the organization's.
- `mailing_address` (string | null, 1-500 characters): The postal address every marketing email carries (CAN-SPAM). Marketing emails can't be sent without one.
- `double_opt_in_default` (boolean): Whether contacts upserted without `double_opt_in` must confirm first.
- `confirmation_from` (string | null): The sender of confirmation emails (a verified domain's address for live keys).
- `confirmation_subject` (string | null, 1-998 characters): `null`: coss.com's default.
- `confirmation_html` (string | null, at most 200000 characters): `null`: coss.com's default. Must contain `{{{confirmation_url}}}`.
- `confirmation_text` (string | null, at most 200000 characters): `null`: coss.com's default. Must contain `{{{confirmation_url}}}`.
- `confirmed_redirect_url` (string | null, uri, at most 2000 characters): Where a confirmed contact is sent, an https URL. `null`: coss.com's own page.

## 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.marketingSettings.update({
  mailing_address: "Acme Inc., 548 Market St, San Francisco, CA 94104, USA",
});
```

HTTP:

```sh
curl -X PATCH "https://api.coss.com/v1/marketing_settings" \
  -H "Authorization: Bearer $COSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "mailing_address": "Acme Inc., 548 Market St, San Francisco, CA 94104, USA"
}'
```

Python:

```python
from coss import Coss

client = Coss()  # api_key= or COSS_API_KEY

client.email.marketing_settings.update(
    mailing_address="Acme Inc., 548 Market St, San Francisco, CA 94104, USA",
)
```

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.UpdateMarketingSettingsRequest{
    MailingAddress: coss.String(
        "Acme Inc., 548 Market St, San Francisco, CA 94104, USA",
    ),
}
client.Email.MarketingSettings.Update(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

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

client.email.marketing_settings.update(mailing_address: "Acme Inc., 548 Market St, San Francisco, CA 94104, USA")
```

PHP:

```php
<?php

use Coss\Coss;
use Coss\Email\MarketingSettings\Requests\UpdateMarketingSettingsRequest;

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

$client->email->marketingSettings->update(
    new UpdateMarketingSettingsRequest([
        'mailingAddress' => 'Acme Inc., 548 Market St, San Francisco, CA 94104, USA',
    ]),
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.email.marketingsettings.requests.UpdateMarketingSettingsRequest;

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

client.email().marketingSettings().update(
    UpdateMarketingSettingsRequest
        .builder()
        .mailingAddress(
            OptionalNullable.of("Acme Inc., 548 Market St, San Francisco, CA 94104, USA")
        )
        .build()
);
```

.NET:

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

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

await client.Email.MarketingSettings.UpdateAsync(
    new UpdateMarketingSettingsRequest
    {
        MailingAddress = "Acme Inc., 548 Market St, San Francisco, CA 94104, USA",
    }
);
```

## Response 200

The settings.

- `object` ("marketing_settings", required)
- `display_name` (string | null, required): The sender's name in the preference center (default: the organization's).
- `mailing_address` (string | null, required): The postal address every marketing email carries (CAN-SPAM). Marketing emails can't be sent without one.
- `double_opt_in_default` (boolean, required): Whether contacts upserted without `double_opt_in` must confirm first.
- `confirmation_from` (string | null, required): The sender of confirmation emails (a verified domain's address for live keys).
- `confirmation_subject` (string | null, required): `null`: coss.com's default.
- `confirmation_html` (string | null, required): `null`: coss.com's default. Must contain `{{{confirmation_url}}}`.
- `confirmation_text` (string | null, required): `null`: coss.com's default. Must contain `{{{confirmation_url}}}`.
- `confirmed_redirect_url` (string | null, required): Where confirming sends the contact (https); `null`: a coss.com confirmation page.

Example:

```json
{
  "object": "marketing_settings",
  "display_name": "Acme",
  "mailing_address": "Acme Inc., 548 Market St, San Francisco, CA 94104, USA",
  "double_opt_in_default": true,
  "confirmation_from": "Acme <news@acme.com>",
  "confirmation_subject": null,
  "confirmation_html": null,
  "confirmation_text": null,
  "confirmed_redirect_url": "https://acme.com/welcome"
}
```

## 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 body failed validation (`validation_error`).
- `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`).