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

# Remove Entities

POST https://api.mercoa.com/entityGroup/{entityGroupId}/removeEntities
Content-Type: application/json

Remove entities from an entity group

Reference: https://docs.mercoa.com/embedded-ap-ar/api-reference/entity-group/remove-entities

## Authentication

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

## Request

### Path parameters

- `entityGroupId` (string, required) — Entity Group ID or Entity Group ForeignID

### Body (application/json)

This endpoint expects an object.

- `entityIds` (list of string, required) — List of entity IDs or foreign IDs to remove from the group

## Response

### 200

- `id` (string, required)
- `entities` (list of object, required)
  - `id` (string, required)
  - `name` (string, required)
  - `email` (string, required)
  - `isCustomer` (boolean, required) — True if this entity has a direct relationship with your organization.
  - `accountType` (enum, required)
    - Allowed values: `business`, `individual`
  - `profile` (object, required)
    - `business` (object, optional) — Will be set if the entity is a business
      - `legalBusinessName` (string, required)
      - `taxIDProvided` (boolean, required)
      - `email` (string, optional)
      - `businessType` (enum, optional)
        - Allowed values: `soleProprietorship`, `unincorporatedAssociation`, `trust`, `publicCorporation`, `privateCorporation`, `llc`, `partnership`, `unincorporatedNonProfit`, `incorporatedNonProfit`
      - `phone` (object, optional)
        - `countryCode` (string, required)
        - `number` (string, required)
      - `doingBusinessAs` (string, optional)
      - `website` (string, optional)
      - `description` (string, optional)
      - `address` (object, optional)
        - `addressLine1` (string, required)
        - `city` (string, required)
        - `stateOrProvince` (string, required) — State or province code. Must be in the format XX.
        - `postalCode` (string, required) — Postal code. Must be in the format XXXXX or XXXXX-XXXX.
        - `addressLine2` (string, optional)
        - `country` (string, optional)
      - `ownersProvided` (boolean, optional) — True if all representatives have been provided for this business.
      - `taxId` (object, optional)
        - `ein` (object, required)
          - `number` (string, required) — Must be in the format XX-XXXXXXX.
      - `formationDate` (datetime, optional)
      - `industryCodes` (object, optional)
        - `mcc` (string, optional)
      - `averageMonthlyTransactionVolume` (double, optional)
      - `averageTransactionSize` (double, optional)
      - `maxTransactionSize` (double, optional)
    - `individual` (object, optional) — Will be set if the entity is a individual
      - `name` (object, required)
        - `firstName` (string, required)
        - `lastName` (string, required)
        - `middleName` (string, optional)
        - `suffix` (string, optional)
      - `birthDateProvided` (boolean, required)
      - `governmentIDProvided` (boolean, required)
      - `email` (string, optional)
      - `phone` (object, optional)
        - `countryCode` (string, required)
        - `number` (string, required)
      - `address` (object, optional)
        - `addressLine1` (string, required)
        - `city` (string, required)
        - `stateOrProvince` (string, required) — State or province code. Must be in the format XX.
        - `postalCode` (string, required) — Postal code. Must be in the format XXXXX or XXXXX-XXXX.
        - `addressLine2` (string, optional)
        - `country` (string, optional)
  - `status` (enum, required)
    - Allowed values: `unverified`, `pending`, `resubmit`, `review`, `verified`, `failed`
  - `acceptedTos` (boolean, required) — True if this entity has accepted the terms of service.
  - `isPayor` (boolean, required) — True if this entity can pay invoices.
  - `isPayee` (boolean, required) — True if this entity can receive payments.
  - `isNetworkPayor` (boolean, required) — True if this entity is available as a payor to any entity on your platform. Otherwise this entity will only be available as a payor to entities that have a direct relationship with this entity.
  - `isNetworkPayee` (boolean, required) — True if this entity is available as a payee to any entity on your platform. Otherwise this entity will only be available as a payee to entities that have a direct relationship with this entity.
  - `createdAt` (datetime, required)
  - `updatedAt` (datetime, required)
  - `foreignId` (string, optional) — The ID used to identify this entity in your system
  - `emailTo` (string, optional) — Local-part/username of the email address to which to send invoices to be added to the Invoice Inbox.
  - `emailToAlias` (list of string, optional) — Email inbox alias addresses. Used when forwarding emails to the emailTo address from an alias.
  - `logo` (string, optional) — URL for the entity logo
  - `oatfiStatus` (string, optional) — The OatFi status of this entity
  - `oatfiUnderwritingResponse` (map from string to string, optional) — The OatFi underwriting response of this entity
  - `metadata` (map from string to string, optional) — Simple key/value metadata associated with this entity. For more complex metadata, use the Metadata API.
- `metadata` (map from string to string, required)
- `foreignId` (string, optional)
- `name` (string, optional)
- `emailToName` (string, optional)

## 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
{
  "entityIds": [
    "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
    "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"
  ]
}
```

**Response**

```json
{
  "id": "entg_a3582b70-fd04-4888-9185-a640ae9048be",
  "entities": [
    {
      "id": "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
      "name": "Acme Inc.",
      "email": "customer@acme.com",
      "isCustomer": true,
      "accountType": "business",
      "profile": {
        "business": {
          "legalBusinessName": "Acme Inc.",
          "taxIDProvided": true,
          "email": "customer@acme.com",
          "businessType": "llc",
          "phone": {
            "countryCode": "1",
            "number": "4155551234"
          },
          "address": {
            "addressLine1": "123 Main St",
            "city": "San Francisco",
            "stateOrProvince": "CA",
            "postalCode": "94105",
            "addressLine2": "Unit 1",
            "country": "US"
          },
          "ownersProvided": true,
          "taxId": {
            "ein": {
              "number": "12-3456789"
            }
          }
        }
      },
      "status": "verified",
      "acceptedTos": true,
      "isPayor": true,
      "isPayee": false,
      "isNetworkPayor": false,
      "isNetworkPayee": false,
      "createdAt": "2024-01-01T00:00:00Z",
      "updatedAt": "2024-01-02T00:00:00Z",
      "foreignId": "MY-DB-ID-12345"
    },
    {
      "id": "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d",
      "name": "Big Box Store",
      "email": "vendor@bigboxstore.com",
      "isCustomer": false,
      "accountType": "business",
      "profile": {
        "business": {
          "legalBusinessName": "Big Box Store",
          "taxIDProvided": false,
          "email": "vendor@bigboxstore.com",
          "businessType": "publicCorporation",
          "ownersProvided": false
        }
      },
      "status": "unverified",
      "acceptedTos": false,
      "isPayor": false,
      "isPayee": true,
      "isNetworkPayor": false,
      "isNetworkPayee": false,
      "createdAt": "2024-01-01T00:00:00Z",
      "updatedAt": "2024-01-02T00:00:00Z",
      "foreignId": "MY-DB-ID-90909"
    }
  ],
  "metadata": {
    "key1": "value1"
  },
  "foreignId": "your-group-id",
  "name": "AcmeConglomerate",
  "emailToName": "acmegroup"
}
```

**SDK Code**

```python
import requests

url = "https://api.mercoa.com/entityGroup/entg_a0f6ea94-0761-4a5e-a416-3c453cb7eced/removeEntities"

payload = { "entityIds": ["ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

const client = new MercoaClient({ token: "YOUR_TOKEN" });
await client.entityGroup.removeEntities("entg_a0f6ea94-0761-4a5e-a416-3c453cb7eced", {
    entityIds: ["ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"]
});

```

```go
package main

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

func main() {

	url := "https://api.mercoa.com/entityGroup/entg_a0f6ea94-0761-4a5e-a416-3c453cb7eced/removeEntities"

	payload := strings.NewReader("{\n  \"entityIds\": [\n    \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n    \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\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))

}
```

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

url = URI("https://api.mercoa.com/entityGroup/entg_a0f6ea94-0761-4a5e-a416-3c453cb7eced/removeEntities")

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  \"entityIds\": [\n    \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n    \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n  ]\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.mercoa.com/entityGroup/entg_a0f6ea94-0761-4a5e-a416-3c453cb7eced/removeEntities")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"entityIds\": [\n    \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n    \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mercoa.com/entityGroup/entg_a0f6ea94-0761-4a5e-a416-3c453cb7eced/removeEntities', [
  'body' => '{
  "entityIds": [
    "ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
    "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.mercoa.com/entityGroup/entg_a0f6ea94-0761-4a5e-a416-3c453cb7eced/removeEntities");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"entityIds\": [\n    \"ent_8545a84e-a45f-41bf-bdf1-33b42a55812c\",\n    \"ent_21661ac1-a2a8-4465-a6c0-64474ba8181d\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["entityIds": ["ent_8545a84e-a45f-41bf-bdf1-33b42a55812c", "ent_21661ac1-a2a8-4465-a6c0-64474ba8181d"]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercoa.com/entityGroup/entg_a0f6ea94-0761-4a5e-a416-3c453cb7eced/removeEntities")! 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()
```