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

# Calculate fees

POST https://api.mercoa.com/fees
Content-Type: application/json

Calculate the estimated fees associated with an payment given the amount, payment source, and disbursement method. Can be used to calculate fees for a payment before creating an invoice.

Reference: https://docs.mercoa.com/embedded-ap-ar/api-reference/calculate/fee

## Authentication

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

## Request

### Body (application/json)

This endpoint expects an object.

- `amount` (double, required) — Total amount in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated.
- `paymentSourceId` (string, required) — ID of payment source.
- `paymentDestinationId` (string, required) — ID of payment destination.
- `currency` (enum, optional) — Currency code for the amount. Defaults to USD.
  - 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`
- `creatorEntityId` (string, optional) — ID of the entity creating the invoice. If not provided, the fees will be calculated with the default pricing for the organization.
- `paymentDestinationOptions` (object, optional) — Options for the payment destination. Depending on the payment destination, this may include things such as check delivery method.
  - `type`: `check`
    - `delivery` (enum, optional) — Delivery method for check disbursements. Defaults to MAIL.
      - Allowed values: `PRINT`, `MAIL`, `MAIL_PRIORITY`, `MAIL_UPS_NEXT_DAY`
    - `printDescription` (boolean, optional) — If true, prints the invoice description (noteToSelf) on the check note. Defaults to false.
  - `type`: `bankAccount`
    - `delivery` (enum, optional) — Delivery method for ACH payments. Defaults to ACH_SAME_DAY.
      - Allowed values: `ACH_STANDARD`, `ACH_SAME_DAY`, `ACH_ACCELERATED`
    - `description` (string, optional) — ACH Statement Description. By default, this will be 'AP' followed by the first 8 characters of the invoice ID (for a single invoice) or the first 8 characters of the transaction ID (for a batch payment). Must be at least 4 characters and no more than 10 characters, and follow this regex pattern `^[a-zA-Z0-9\-#.$&* ]{4,10}$`
  - `type`: `utility`
    - `accountId` (string, required) — The ID for the utility account to pay with. Links to accounts listed on payor/payee relationship.
  - `type`: `custom`
    - `dynamicUrls` (map from string to string, optional) — Map of field names to dynamic URL values that will be used for dynamicUrl fields in custom payment method schemas
- `type` (enum, optional) — Type of payment to calculate fees for. Defaults to PAYABLE (Accounts Payable).
  - Allowed values: `PAYABLE`, `RECEIVABLE`

## Response

### 200

- `sourcePaymentMethodFee` (double, required) — Fee charged to the platform (C1) for processing the source payment method. For example, credit card interchange and acquiring fees.
- `sourcePlatformMarkupFee` (double, required) — Fee charged to the payer (C2).
- `destinationPaymentMethodFee` (double, required) — Fee charged to the platform (C1) for processing the destination payment method. For example, postage for a check payment.
- `destinationPlatformMarkupFee` (double, required) — Fee charged to the payee (C3).

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

**Request**

```json
{
  "amount": 100,
  "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
  "paymentDestinationId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769"
}
```

**Response**

```json
{
  "sourcePaymentMethodFee": 0.1,
  "sourcePlatformMarkupFee": 0.2,
  "destinationPaymentMethodFee": 1,
  "destinationPlatformMarkupFee": 1.5
}
```

**SDK Code**

```python Default
import requests

url = "https://api.mercoa.com/fees"

payload = {
    "amount": 100,
    "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
    "paymentDestinationId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.calculate.fee({
    amount: 100,
    paymentSourceId: "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
    paymentDestinationId: "pm_4794d597-70dc-4fec-b6ec-c5988e759769"
});

```

```go Default
package main

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

func main() {

	url := "https://api.mercoa.com/fees"

	payload := strings.NewReader("{\n  \"amount\": 100,\n  \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n  \"paymentDestinationId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\"\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 Default
require 'uri'
require 'net/http'

url = URI("https://api.mercoa.com/fees")

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  \"amount\": 100,\n  \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n  \"paymentDestinationId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/fees")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount\": 100,\n  \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n  \"paymentDestinationId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/fees', [
  'body' => '{
  "amount": 100,
  "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
  "paymentDestinationId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Default
using RestSharp;

var client = new RestClient("https://api.mercoa.com/fees");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"amount\": 100,\n  \"paymentSourceId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\",\n  \"paymentDestinationId\": \"pm_4794d597-70dc-4fec-b6ec-c5988e759769\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Default
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "amount": 100,
  "paymentSourceId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769",
  "paymentDestinationId": "pm_4794d597-70dc-4fec-b6ec-c5988e759769"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/fees")! 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()
```