---
title: "Create/Update External Entity"
method: POST
path: "/entity/{entityId}/external-accounting-system/create"
tags: ["entity > external-accounting-system"]
---

# Create/Update External Entity

`POST /entity/{entityId}/external-accounting-system/create`

## Request

- Base URL: `https://api.mercoa.com`
- URL: `https://api.mercoa.com/entity/{entityId}/external-accounting-system/create`
- Auth: HTTP bearer

Create/Link an entity to an external accounting system like Codat or Rutter. If the entity is already linked to an external accounting system, this will return the existing connection.

## Path parameters

- `entityId` string, required

## Request body

- union
  - object
    - `type` 'codat', required: Discriminator value: codat
    - `companyId` string: If the company already exists in Codat, provide the company ID to link the company to the entity. If the company does not exist, leave this field blank and Codat will create a new company.
  - object
    - `type` 'rutter', required: Discriminator value: rutter
    - `accessToken` string: The access token for the existing Rutter connection. If the connection does not exist, leave this field blank and Rutter will create a new connection.

## Response `200`

Response with status 200

- union
  - object
    - `type` 'codat', required: Discriminator value: codat
    - `companyId` string, required
  - object
    - `type` 'rutter', required: Discriminator value: rutter
    - `accessToken` string, required
  - object
    - `type` 'none', required: Discriminator value: none
    - `companyId` string, required

## Other responses

- `400`: Error response with status 400
- `401`: Error response with status 401
- `403`: Error response with status 403
- `404`: Error response with status 404
- `409`: Error response with status 409
- `500`: Error response with status 500
- `501`: Error response with status 501

---

[API](https://skmtc.dev/mercoa/apis/mercoa-2.md) - [All operations](https://skmtc.dev/mercoa/apis/mercoa-2/llms.txt) - [OpenAPI document](https://skmtc.dev/mercoa/apis/mercoa-2/revisions/00a8e403ae18?raw)
