# Change an email provider

Canonical page: https://docs.ovok.com/api/email/change-an-email-provider

`PATCH /v1/email/templates/provider`

Changes an email provider your current project has set up: replaces its secret, the sender address, or both. Each value is stored encrypted and is never returned.

**Auth:** bearer token of a project admin. The caller must also be a Practitioner, an admin or hold the System Owner access policy.
**Scope:** the caller's project (from the token).

## Behaviour

- `provider` names the provider to change. One that is not set up returns 404 `PROVIDER_NOT_CONFIGURED`: set it up with `POST /v1/email/templates/provider`.
- Send `secret`, `from`, or both. The rules are those of `POST`; a secret the provider does not take returns 422 `INVALID_SECRET`.
- `from` is one sender address for the whole project, so changing it changes it for every provider. It cannot be cleared, only replaced.
- When the server has no encryption key, nothing is stored and the answer is 503 `ENCRYPTION_UNAVAILABLE`.
- A 409 means the project changed while the server wrote. Read it again and retry.
- The answer has the project's providers as `GET /v1/email/templates/provider` returns them.

## Example

```bash
curl -X PATCH 'https://api.sandbox.ovok.com/v1/email/templates/provider' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{ "provider": "brevo", "secret": "xkeysib-…" }'
```
