> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mercoa.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mercoa.com/_mcp/server.

Notifications are sent to [users](/common-concepts/entity-users) when an event occurs in the system related to them. Notifications are sent to users via email.

## Notification Types

Notifications are sent for the following events:

| Event                     | Description                                                 | Default Recipient                         |
| ------------------------- | ----------------------------------------------------------- | ----------------------------------------- |
| INVOICE\_APPROVAL\_NEEDED | An invoice is created and needs approval                    | The designated approver(s) of the invoice |
| INVOICE\_APPROVED         | An invoice is approved                                      | Invoice Creator                           |
| INVOICE\_REJECTED         | An invoice is rejected                                      | Invoice Creator                           |
| INVOICE\_SCHEDULED        | An invoice is scheduled for payment                         | None                                      |
| INVOICE\_PENDING          | An invoice payment has initiated                            | None                                      |
| INVOICE\_PAID             | An invoice is marked as paid                                | Invoice Creator                           |
| INVOICE\_CANCELED         | An invoice is marked as canceled                            | None                                      |
| INVOICE\_CREATED          | A new invoice is created by any means (email, upload, etc.) | None                                      |
| INVOICE\_EMAILED          | A new invoice is emailed to the email inbox                 | None                                      |
| INVOICE\_FAILED           | An invoice payment failed                                   | Invoice Creator                           |

## Changing Notification Recipients

The default recipients for each notification type can be changed by [updating](/api-reference/entity/notification-policy/update) the policy for that notification type. You can also do this using the [Admin Dashboard](https://mercoa.com/dashboard/payers)

For example, to change the recipients of the `INVOICE_APPROVED` notification type to always notify any user with the role `admin` or `bookkeeper`

### Request

POST [https://api.mercoa.com/entity/\{entityId}/notification-policy/\{notificationType}](https://api.mercoa.com/entity/\{entityId}/notification-policy/\{notificationType})

**`INVOICE_APPROVED`**

```curl INVOICE_APPROVED
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "disabled": false,
  "additionalRoles": [
    "admin",
    "bookkeeper"
  ]
}'
```

**`INVOICE_APPROVED`**

```python INVOICE_APPROVED
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED"

payload = {
    "disabled": False,
    "additionalRoles": ["admin", "bookkeeper"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`INVOICE_APPROVED`**

```typescript INVOICE_APPROVED
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.notificationPolicy.update("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "INVOICE_APPROVED", {
    disabled: false,
    additionalRoles: ["admin", "bookkeeper"]
});

```

**`INVOICE_APPROVED`**

```go INVOICE_APPROVED
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED"

	payload := strings.NewReader("{\n  \"disabled\": false,\n  \"additionalRoles\": [\n    \"admin\",\n    \"bookkeeper\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`INVOICE_APPROVED`**

```ruby INVOICE_APPROVED
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"disabled\": false,\n  \"additionalRoles\": [\n    \"admin\",\n    \"bookkeeper\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

**`INVOICE_APPROVED`**

```java INVOICE_APPROVED
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"disabled\": false,\n  \"additionalRoles\": [\n    \"admin\",\n    \"bookkeeper\"\n  ]\n}")
  .asString();
```

**`INVOICE_APPROVED`**

```php INVOICE_APPROVED
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED', [
  'body' => '{
  "disabled": false,
  "additionalRoles": [
    "admin",
    "bookkeeper"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`INVOICE_APPROVED`**

```csharp INVOICE_APPROVED
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"disabled\": false,\n  \"additionalRoles\": [\n    \"admin\",\n    \"bookkeeper\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`INVOICE_APPROVED`**

```swift INVOICE_APPROVED
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "disabled": false,
  "additionalRoles": ["admin", "bookkeeper"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## Disabling Notifications

To disable notifications for a notification type, set `disabled` to `true` in the request body. You can also do this using the [Admin Dashboard](https://mercoa.com/dashboard/payers)

### Request

POST [https://api.mercoa.com/entity/\{entityId}/notification-policy/\{notificationType}](https://api.mercoa.com/entity/\{entityId}/notification-policy/\{notificationType})

**`DISABLED`**

```curl DISABLED
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "disabled": true,
  "additionalRoles": []
}'
```

**`DISABLED`**

```python DISABLED
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED"

payload = {
    "disabled": True,
    "additionalRoles": []
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`DISABLED`**

```typescript DISABLED
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.notificationPolicy.update("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "INVOICE_APPROVED", {
    disabled: true,
    additionalRoles: []
});

```

**`DISABLED`**

```go DISABLED
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED"

	payload := strings.NewReader("{\n  \"disabled\": true,\n  \"additionalRoles\": []\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`DISABLED`**

```ruby DISABLED
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"disabled\": true,\n  \"additionalRoles\": []\n}"

response = http.request(request)
puts response.read_body
```

**`DISABLED`**

```java DISABLED
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"disabled\": true,\n  \"additionalRoles\": []\n}")
  .asString();
```

**`DISABLED`**

```php DISABLED
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED', [
  'body' => '{
  "disabled": true,
  "additionalRoles": []
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`DISABLED`**

```csharp DISABLED
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"disabled\": true,\n  \"additionalRoles\": []\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`DISABLED`**

```swift DISABLED
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "disabled": true,
  "additionalRoles": []
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/notification-policy/INVOICE_APPROVED")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

# Per-User Notification Customizations

## Disabling Notifications for a Specific User

To disable notifications for a specific user, set `disabled` to `true` in the request body. You can also do this using the [Admin Dashboard](https://mercoa.com/dashboard/payers)

### Request

POST [https://api.mercoa.com/entity/\{entityId}/user/\{userId}/notification-policy/\{notificationType}](https://api.mercoa.com/entity/\{entityId}/user/\{userId}/notification-policy/\{notificationType})

**`DISABLED`**

```curl DISABLED
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "disabled": true
}'
```

**`DISABLED`**

```python DISABLED
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED"

payload = { "disabled": True }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`DISABLED`**

```typescript DISABLED
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.user.notificationPolicy.update("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "INVOICE_APPROVED", {
    disabled: true
});

```

**`DISABLED`**

```go DISABLED
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED"

	payload := strings.NewReader("{\n  \"disabled\": true\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`DISABLED`**

```ruby DISABLED
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"disabled\": true\n}"

response = http.request(request)
puts response.read_body
```

**`DISABLED`**

```java DISABLED
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"disabled\": true\n}")
  .asString();
```

**`DISABLED`**

```php DISABLED
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED', [
  'body' => '{
  "disabled": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`DISABLED`**

```csharp DISABLED
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"disabled\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`DISABLED`**

```swift DISABLED
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["disabled": true] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## Enable Daily Digest Email

If you want to send a dialy email with all the notifications grouped into a single email, you can enable `digest` for the user

### Request

POST [https://api.mercoa.com/entity/\{entityId}/user/\{userId}/notification-policy/\{notificationType}](https://api.mercoa.com/entity/\{entityId}/user/\{userId}/notification-policy/\{notificationType})

**`DIGEST`**

```curl DIGEST
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVAL_NEEDED \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "digest": true
}'
```

**`DIGEST`**

```python DIGEST
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVAL_NEEDED"

payload = { "digest": True }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`DIGEST`**

```typescript DIGEST
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.user.notificationPolicy.update("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "INVOICE_APPROVAL_NEEDED", {
    digest: true
});

```

**`DIGEST`**

```go DIGEST
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVAL_NEEDED"

	payload := strings.NewReader("{\n  \"digest\": true\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`DIGEST`**

```ruby DIGEST
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVAL_NEEDED")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"digest\": true\n}"

response = http.request(request)
puts response.read_body
```

**`DIGEST`**

```java DIGEST
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVAL_NEEDED")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"digest\": true\n}")
  .asString();
```

**`DIGEST`**

```php DIGEST
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVAL_NEEDED', [
  'body' => '{
  "digest": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`DIGEST`**

```csharp DIGEST
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVAL_NEEDED");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"digest\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`DIGEST`**

```swift DIGEST
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["digest": true] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVAL_NEEDED")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## Enable Individual Notification Emails

If you want to send an email for each notification, you can enable `immediate` for the user

### Request

POST [https://api.mercoa.com/entity/\{entityId}/user/\{userId}/notification-policy/\{notificationType}](https://api.mercoa.com/entity/\{entityId}/user/\{userId}/notification-policy/\{notificationType})

**`DISABLED`**

```curl DISABLED
curl -X POST https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "disabled": true
}'
```

**`DISABLED`**

```python DISABLED
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED"

payload = { "disabled": True }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`DISABLED`**

```typescript DISABLED
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.user.notificationPolicy.update("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "user_e24fc81c-c5ee-47e8-af42-4fe29d895506", "INVOICE_APPROVED", {
    disabled: true
});

```

**`DISABLED`**

```go DISABLED
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED"

	payload := strings.NewReader("{\n  \"disabled\": true\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`DISABLED`**

```ruby DISABLED
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"disabled\": true\n}"

response = http.request(request)
puts response.read_body
```

**`DISABLED`**

```java DISABLED
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"disabled\": true\n}")
  .asString();
```

**`DISABLED`**

```php DISABLED
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED', [
  'body' => '{
  "disabled": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

**`DISABLED`**

```csharp DISABLED
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"disabled\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`DISABLED`**

```swift DISABLED
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["disabled": true] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notification-policy/INVOICE_APPROVED")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

> **Warning**
>
> You can enable both digest and immediate notifications at the same time!

## Viewing Notifications for a User

To view notifications for a user, use the [get all notifications](/api-reference/entity/user/notifications/find) endpoint.

### Request

GET [https://api.mercoa.com/entity/\{entityId}/user/\{userId}/notifications](https://api.mercoa.com/entity/\{entityId}/user/\{userId}/notifications)

**`Default`**

```curl Default
curl https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notifications \
     -H "Authorization: Bearer <token>"
```

**`Default`**

```python Default
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notifications"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

**`Default`**

```typescript Default
import { MercoaClient } from "@mercoa/javascript";

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.user.notifications.find("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "user_e24fc81c-c5ee-47e8-af42-4fe29d895506");

```

**`Default`**

```go Default
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notifications"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`Default`**

```ruby Default
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notifications")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

**`Default`**

```java Default
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notifications")
  .header("Authorization", "Bearer <token>")
  .asString();
```

**`Default`**

```php Default
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notifications', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

**`Default`**

```csharp Default
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notifications");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

**`Default`**

```swift Default
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/user/user_e24fc81c-c5ee-47e8-af42-4fe29d895506/notifications")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

# Customizing Notifications

You can customize the link that is included in the notification email. The default link will open up an standalone web page that displays the Mercoa inbox and invoice. You can customize this link to point to your own website or application.

You can use the [Admin Dashboard](https://mercoa.com/dashboard/developers#notifications) to customize the link, or you can use the [update notification configuration](/api-reference/organization/notification-configuration/update) endpoint to customize the link for a specific notification type.

> **Info**
>
> If you want to customize the email template, please reach out to the Mercoa team!