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

# Update

POST https://api.mercoa.com/entity/{entityId}/approval-policy/{policyId}
Content-Type: application/json

Update an invoice approval policy associated with an entity

Reference: https://docs.mercoa.com/embedded-ap-ar/api-reference/entity/approval-policy/update

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `entityId` (string, required) — Entity ID or Entity ForeignID
- `policyId` (string, required)

### Body (application/json)

This endpoint expects an object.

- `trigger` (list of object, optional)
  - `type`: `amount`
    - `amount` (double, required)
    - `currency` (enum, required)
      - Allowed values: `AED`, `AFN`, `ALL`, `AMD`, `ANG`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BGN`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `COP`, `COU`, `CRC`, `CUC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `CNY`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SLL`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAF`, `XAG`, `XAU`, `XBA`, `XBB`, `XBC`, `XBD`, `XCD`, `XDR`, `XOF`, `XPD`, `XPF`, `XPT`, `XSU`, `XTS`, `XUA`, `XXX`, `YER`, `ZAR`, `ZMW`, `ZWL`
    - `comparison` (enum, optional) — The comparison operator to use when comparing the amount to the trigger amount. Defaults to gte.
      - Allowed values: `eq`, `gt`, `gte`, `lt`, `lte`
  - `type`: `vendor`
    - `vendorIds` (list of string, required)
  - `type`: `metadata`
    - `key` (string, required) — The metadata key to match
    - `value` (list of string, required) — The metadata value the invoice must have to trigger this policy
  - `type`: `catchall`
- `rule` (object, optional)
  - `type`: `approver`
    - `identifierList` (object, required) — List of users or roles that should be used to determine eligible approvers
      - `type`: `rolesList`
        - `value` (list of string, required)
      - `type`: `userList`
        - `value` (list of string, required)
    - `numApprovers` (integer, required) — Number of approvals required to approve an invoice
    - `autoAssign` (boolean, optional) — If true, the policy will automatically assign approvers to the invoice. If more than one approver is eligible, the policy will assign all eligible approvers to the invoice.
  - `type`: `automatic`
- `upstreamPolicyId` (string, optional)

## Response

### 200

- `id` (string, required)
- `trigger` (list of object, required)
  - `type`: `amount`
    - `amount` (double, required)
    - `currency` (enum, required)
      - Allowed values: `AED`, `AFN`, `ALL`, `AMD`, `ANG`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BGN`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `COP`, `COU`, `CRC`, `CUC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `CNY`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SLL`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAF`, `XAG`, `XAU`, `XBA`, `XBB`, `XBC`, `XBD`, `XCD`, `XDR`, `XOF`, `XPD`, `XPF`, `XPT`, `XSU`, `XTS`, `XUA`, `XXX`, `YER`, `ZAR`, `ZMW`, `ZWL`
    - `comparison` (enum, optional) — The comparison operator to use when comparing the amount to the trigger amount. Defaults to gte.
      - Allowed values: `eq`, `gt`, `gte`, `lt`, `lte`
  - `type`: `vendor`
    - `vendorIds` (list of string, required)
  - `type`: `metadata`
    - `key` (string, required) — The metadata key to match
    - `value` (list of string, required) — The metadata value the invoice must have to trigger this policy
  - `type`: `catchall`
- `rule` (object, required)
  - `type`: `approver`
    - `identifierList` (object, required) — List of users or roles that should be used to determine eligible approvers
      - `type`: `rolesList`
        - `value` (list of string, required)
      - `type`: `userList`
        - `value` (list of string, required)
    - `numApprovers` (integer, required) — Number of approvals required to approve an invoice
    - `autoAssign` (boolean, optional) — If true, the policy will automatically assign approvers to the invoice. If more than one approver is eligible, the policy will assign all eligible approvers to the invoice.
  - `type`: `automatic`
- `upstreamPolicyId` (string, required)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)

## Errors

### 400 Bad Request

- `errorName` ("BadRequest", required)
- `content` (string, required)

### 401 Unauthorized

- `errorName` ("Unauthorized", required)
- `content` (string, required)

### 403 Forbidden

- `errorName` ("Forbidden", required)
- `content` (string, required)

### 404 Not Found

- `errorName` ("NotFound", required)
- `content` (string, required)

### 409 Conflict

- `errorName` ("Conflict", required)
- `content` (string, required)

### 500 Internal Server Error

- `errorName` ("InternalServerError", required)
- `content` (string, required)

### 501 Unimplemented

- `errorName` ("Unimplemented", required)
- `content` (string, required)

## Examples

### AlwaysTrigger

**Request**

```json
{
  "trigger": [],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "userList",
      "value": [
        "usr_8545a84e-a45f-41bf-bdf1-33b42a55812c",
        "usr_21661ac1-a2a8-4465-a6c0-64474ba8181d"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root"
}
```

**Response**

```json
{
  "id": "apvl_21661ac1-a2a8-4465-a6c0-64474ba8181d",
  "trigger": [],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "userList",
      "value": [
        "usr_8545a84e-a45f-41bf-bdf1-33b42a55812c",
        "usr_21661ac1-a2a8-4465-a6c0-64474ba8181d"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root",
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-02T00:00:00Z"
}
```

**SDK Code**

```python AlwaysTrigger
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c"

payload = {
    "trigger": [],
    "rule": {
        "type": "approver",
        "identifierList": {
            "type": "userList",
            "value": ["usr_8545a84e-a45f-41bf-bdf1-33b42a55812c", "usr_21661ac1-a2a8-4465-a6c0-64474ba8181d"]
        },
        "numApprovers": 2
    },
    "upstreamPolicyId": "root"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.approvalPolicy.update("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", {
    trigger: [],
    rule: {
        type: "approver",
        numApprovers: 2,
        identifierList: {
            type: "userList",
            value: ["usr_8545a84e-a45f-41bf-bdf1-33b42a55812c", "usr_21661ac1-a2a8-4465-a6c0-64474ba8181d"]
        }
    },
    upstreamPolicyId: "root"
});

```

```go AlwaysTrigger
package main

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

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c"

	payload := strings.NewReader("{\n  \"trigger\": [],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"userList\",\n      \"value\": [\n        \"usr_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n        \"usr_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\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))

}
```

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

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")

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  \"trigger\": [],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"userList\",\n      \"value\": [\n        \"usr_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n        \"usr_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}"

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

```java AlwaysTrigger
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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"trigger\": [],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"userList\",\n      \"value\": [\n        \"usr_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n        \"usr_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}")
  .asString();
```

```php AlwaysTrigger
<?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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c', [
  'body' => '{
  "trigger": [],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "userList",
      "value": [
        "usr_8545a84e-a45f-41bf-bdf1-33b42a55812c",
        "usr_21661ac1-a2a8-4465-a6c0-64474ba8181d"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp AlwaysTrigger
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"trigger\": [],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"userList\",\n      \"value\": [\n        \"usr_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n        \"usr_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift AlwaysTrigger
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "trigger": [],
  "rule": [
    "type": "approver",
    "identifierList": [
      "type": "userList",
      "value": ["usr_8545a84e-a45f-41bf-bdf1-33b42a55812c", "usr_21661ac1-a2a8-4465-a6c0-64474ba8181d"]
    ],
    "numApprovers": 2
  ],
  "upstreamPolicyId": "root"
] 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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")! 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()
```

### SingleTrigger

**Request**

```json
{
  "trigger": [
    {
      "type": "amount",
      "amount": 100,
      "currency": "USD"
    }
  ],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "rolesList",
      "value": [
        "Admin",
        "Controller"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root"
}
```

**Response**

```json
{
  "id": "apvl_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "trigger": [
    {
      "type": "amount",
      "amount": 100,
      "currency": "USD"
    }
  ],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "rolesList",
      "value": [
        "Admin",
        "Controller"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root",
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-02T00:00:00Z"
}
```

**SDK Code**

```python SingleTrigger
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c"

payload = {
    "trigger": [
        {
            "type": "amount",
            "amount": 100,
            "currency": "USD"
        }
    ],
    "rule": {
        "type": "approver",
        "identifierList": {
            "type": "rolesList",
            "value": ["Admin", "Controller"]
        },
        "numApprovers": 2
    },
    "upstreamPolicyId": "root"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.approvalPolicy.update("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", {
    trigger: [{
            type: "amount",
            amount: 100,
            currency: "USD"
        }],
    rule: {
        type: "approver",
        numApprovers: 2,
        identifierList: {
            type: "rolesList",
            value: ["Admin", "Controller"]
        }
    },
    upstreamPolicyId: "root"
});

```

```go SingleTrigger
package main

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

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c"

	payload := strings.NewReader("{\n  \"trigger\": [\n    {\n      \"type\": \"amount\",\n      \"amount\": 100,\n      \"currency\": \"USD\"\n    }\n  ],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"rolesList\",\n      \"value\": [\n        \"Admin\",\n        \"Controller\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\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))

}
```

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

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")

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  \"trigger\": [\n    {\n      \"type\": \"amount\",\n      \"amount\": 100,\n      \"currency\": \"USD\"\n    }\n  ],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"rolesList\",\n      \"value\": [\n        \"Admin\",\n        \"Controller\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}"

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

```java SingleTrigger
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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"trigger\": [\n    {\n      \"type\": \"amount\",\n      \"amount\": 100,\n      \"currency\": \"USD\"\n    }\n  ],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"rolesList\",\n      \"value\": [\n        \"Admin\",\n        \"Controller\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}")
  .asString();
```

```php SingleTrigger
<?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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c', [
  'body' => '{
  "trigger": [
    {
      "type": "amount",
      "amount": 100,
      "currency": "USD"
    }
  ],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "rolesList",
      "value": [
        "Admin",
        "Controller"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp SingleTrigger
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"trigger\": [\n    {\n      \"type\": \"amount\",\n      \"amount\": 100,\n      \"currency\": \"USD\"\n    }\n  ],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"rolesList\",\n      \"value\": [\n        \"Admin\",\n        \"Controller\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift SingleTrigger
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "trigger": [
    [
      "type": "amount",
      "amount": 100,
      "currency": "USD"
    ]
  ],
  "rule": [
    "type": "approver",
    "identifierList": [
      "type": "rolesList",
      "value": ["Admin", "Controller"]
    ],
    "numApprovers": 2
  ],
  "upstreamPolicyId": "root"
] 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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")! 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()
```

### MultipleTriggers

**Request**

```json
{
  "trigger": [
    {
      "type": "amount",
      "amount": 100,
      "currency": "USD"
    },
    {
      "type": "vendor",
      "vendorIds": [
        "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"
      ]
    },
    {
      "type": "metadata",
      "key": "property_id",
      "value": [
        "123456",
        "789012"
      ]
    },
    {
      "type": "catchall"
    }
  ],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "rolesList",
      "value": [
        "Admin",
        "Controller"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root"
}
```

**Response**

```json
{
  "id": "apvl_8545a84e-a45f-41bf-bdf1-33b42a55812c",
  "trigger": [
    {
      "type": "amount",
      "amount": 100,
      "currency": "USD"
    },
    {
      "type": "vendor",
      "vendorIds": [
        "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"
      ]
    },
    {
      "type": "metadata",
      "key": "property_id",
      "value": [
        "123456",
        "789012"
      ]
    },
    {
      "type": "catchall"
    }
  ],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "rolesList",
      "value": [
        "Admin",
        "Controller"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root",
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-02T00:00:00Z"
}
```

**SDK Code**

```python MultipleTriggers
import requests

url = "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c"

payload = {
    "trigger": [{
            "type": "amount",
            "amount": 100,
            "currency": "USD"
        }, {
            "type": "vendor",
            "vendorIds": ["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"]
        }, {
            "type": "metadata",
            "key": "property_id",
            "value": ["123456", "789012"]
        }, { "type": "catchall" }],
    "rule": {
        "type": "approver",
        "identifierList": {
            "type": "rolesList",
            "value": ["Admin", "Controller"]
        },
        "numApprovers": 2
    },
    "upstreamPolicyId": "root"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entity.approvalPolicy.update("ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c", {
    trigger: [{
            type: "amount",
            amount: 100,
            currency: "USD"
        }, {
            type: "vendor",
            vendorIds: ["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"]
        }, {
            type: "metadata",
            key: "property_id",
            value: ["123456", "789012"]
        }, {
            type: "catchall"
        }],
    rule: {
        type: "approver",
        numApprovers: 2,
        identifierList: {
            type: "rolesList",
            value: ["Admin", "Controller"]
        }
    },
    upstreamPolicyId: "root"
});

```

```go MultipleTriggers
package main

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

func main() {

	url := "https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c"

	payload := strings.NewReader("{\n  \"trigger\": [\n    {\n      \"type\": \"amount\",\n      \"amount\": 100,\n      \"currency\": \"USD\"\n    },\n    {\n      \"type\": \"vendor\",\n      \"vendorIds\": [\n        \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n      ]\n    },\n    {\n      \"type\": \"metadata\",\n      \"key\": \"property_id\",\n      \"value\": [\n        \"123456\",\n        \"789012\"\n      ]\n    },\n    {\n      \"type\": \"catchall\"\n    }\n  ],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"rolesList\",\n      \"value\": [\n        \"Admin\",\n        \"Controller\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\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))

}
```

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

url = URI("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")

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  \"trigger\": [\n    {\n      \"type\": \"amount\",\n      \"amount\": 100,\n      \"currency\": \"USD\"\n    },\n    {\n      \"type\": \"vendor\",\n      \"vendorIds\": [\n        \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n      ]\n    },\n    {\n      \"type\": \"metadata\",\n      \"key\": \"property_id\",\n      \"value\": [\n        \"123456\",\n        \"789012\"\n      ]\n    },\n    {\n      \"type\": \"catchall\"\n    }\n  ],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"rolesList\",\n      \"value\": [\n        \"Admin\",\n        \"Controller\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}"

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

```java MultipleTriggers
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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"trigger\": [\n    {\n      \"type\": \"amount\",\n      \"amount\": 100,\n      \"currency\": \"USD\"\n    },\n    {\n      \"type\": \"vendor\",\n      \"vendorIds\": [\n        \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n      ]\n    },\n    {\n      \"type\": \"metadata\",\n      \"key\": \"property_id\",\n      \"value\": [\n        \"123456\",\n        \"789012\"\n      ]\n    },\n    {\n      \"type\": \"catchall\"\n    }\n  ],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"rolesList\",\n      \"value\": [\n        \"Admin\",\n        \"Controller\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}")
  .asString();
```

```php MultipleTriggers
<?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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c', [
  'body' => '{
  "trigger": [
    {
      "type": "amount",
      "amount": 100,
      "currency": "USD"
    },
    {
      "type": "vendor",
      "vendorIds": [
        "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"
      ]
    },
    {
      "type": "metadata",
      "key": "property_id",
      "value": [
        "123456",
        "789012"
      ]
    },
    {
      "type": "catchall"
    }
  ],
  "rule": {
    "type": "approver",
    "identifierList": {
      "type": "rolesList",
      "value": [
        "Admin",
        "Controller"
      ]
    },
    "numApprovers": 2
  },
  "upstreamPolicyId": "root"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp MultipleTriggers
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entity/ent_8545a84e-a45f-41bf-bdf1-33b42a55812c/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"trigger\": [\n    {\n      \"type\": \"amount\",\n      \"amount\": 100,\n      \"currency\": \"USD\"\n    },\n    {\n      \"type\": \"vendor\",\n      \"vendorIds\": [\n        \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n      ]\n    },\n    {\n      \"type\": \"metadata\",\n      \"key\": \"property_id\",\n      \"value\": [\n        \"123456\",\n        \"789012\"\n      ]\n    },\n    {\n      \"type\": \"catchall\"\n    }\n  ],\n  \"rule\": {\n    \"type\": \"approver\",\n    \"identifierList\": {\n      \"type\": \"rolesList\",\n      \"value\": [\n        \"Admin\",\n        \"Controller\"\n      ]\n    },\n    \"numApprovers\": 2\n  },\n  \"upstreamPolicyId\": \"root\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift MultipleTriggers
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "trigger": [[
      "type": "amount",
      "amount": 100,
      "currency": "USD"
    ], [
      "type": "vendor",
      "vendorIds": ["ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"]
    ], [
      "type": "metadata",
      "key": "property_id",
      "value": ["123456", "789012"]
    ], ["type": "catchall"]],
  "rule": [
    "type": "approver",
    "identifierList": [
      "type": "rolesList",
      "value": ["Admin", "Controller"]
    ],
    "numApprovers": 2
  ],
  "upstreamPolicyId": "root"
] 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/approval-policy/apvl_5ce50275-1789-42ea-bc60-bb7e6d03635c")! 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()
```