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

# Create a company

POST https://api.middesk.com/v1/partner/companies
Content-Type: application/json

Reference: https://docs.middesk.com/api-reference/entity-management/companies/create-company

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

- `legal_name` (string, required) — Legal name of the company
- `ein` (string, optional) — Employer Identification Number
- `external_id` (string, optional) — External identifier
- `dba_name` (string, optional) — Doing business as name
- `contact_email` (string, optional)
- `contact_name` (string, optional)
- `contact_phone_number` (string, optional)
- `entity_type` (string, optional)
- `formation_state` (string, optional)
- `formation_date` (date, optional)
- `addresses` (list of CreateCompanyRequestAddressesItem, optional)

## Response

### 201

company created

- `object` (string, required)
- `id` (string, required)
- `legal_name` (string, required) — Legal name of the company
- `account_id` (string, required) — Account ID the company belongs to
- `dba_name` (string, optional, nullable) — Doing business as name
- `external_id` (string, optional, nullable) — External identifier for the company
- `parent_account` (AgentCompanyParentAccount, optional)

## Errors

### 409 Create Company Request Conflict Error

company already exists

- `errors` (list of ConflictErrorBodyErrorsItem, required)

## Types

### CreateCompanyRequestAddressesItem

- `address_line1` (string, optional)
- `address_line2` (string, optional)
- `city` (string, optional)
- `state` (string, optional)
- `postal_code` (string, optional)
- `address_type` (string, optional)

### AgentCompanyParentAccount

- `id` (string, optional)
- `name` (string, optional)
- `slug` (string, optional)

### ConflictErrorBodyErrorsItem

- `message` (string, required)
- `id` (string, optional)

## Examples

**Request**

```json
{
  "legal_name": "Acme Corporation",
  "ein": "123456789",
  "external_id": "customer_12345",
  "dba_name": "Acme Co",
  "contact_email": "contact@acme.com",
  "contact_name": "Jane Smith",
  "contact_phone_number": "(555) 123-4567",
  "entity_type": "corporation",
  "formation_state": "DE",
  "formation_date": "2020-01-15",
  "addresses": [
    {
      "address_line1": "123 Main St",
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94105",
      "address_type": "primary"
    }
  ]
}
```

**Response**

```json
{
  "object": "agent_company",
  "id": "comp_abc123",
  "legal_name": "Acme Corporation",
  "account_id": "acc_def456",
  "dba_name": "Acme Co",
  "external_id": "customer_12345",
  "parent_account": {
    "id": "acc_parent789",
    "name": "Partner Account",
    "slug": "partner-account"
  }
}
```

**SDK Code**

```python Create company
import requests

url = "https://api.middesk.com/v1/partner/companies"

payload = {
    "legal_name": "Acme Corporation",
    "ein": "123456789",
    "external_id": "customer_12345",
    "dba_name": "Acme Co",
    "contact_email": "contact@acme.com",
    "contact_name": "Jane Smith",
    "contact_phone_number": "(555) 123-4567",
    "entity_type": "corporation",
    "formation_state": "DE",
    "formation_date": "2020-01-15",
    "addresses": [
        {
            "address_line1": "123 Main St",
            "city": "San Francisco",
            "state": "CA",
            "postal_code": "94105",
            "address_type": "primary"
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create company
const url = 'https://api.middesk.com/v1/partner/companies';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"legal_name":"Acme Corporation","ein":"123456789","external_id":"customer_12345","dba_name":"Acme Co","contact_email":"contact@acme.com","contact_name":"Jane Smith","contact_phone_number":"(555) 123-4567","entity_type":"corporation","formation_state":"DE","formation_date":"2020-01-15","addresses":[{"address_line1":"123 Main St","city":"San Francisco","state":"CA","postal_code":"94105","address_type":"primary"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Create company
package main

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

func main() {

	url := "https://api.middesk.com/v1/partner/companies"

	payload := strings.NewReader("{\n  \"legal_name\": \"Acme Corporation\",\n  \"ein\": \"123456789\",\n  \"external_id\": \"customer_12345\",\n  \"dba_name\": \"Acme Co\",\n  \"contact_email\": \"contact@acme.com\",\n  \"contact_name\": \"Jane Smith\",\n  \"contact_phone_number\": \"(555) 123-4567\",\n  \"entity_type\": \"corporation\",\n  \"formation_state\": \"DE\",\n  \"formation_date\": \"2020-01-15\",\n  \"addresses\": [\n    {\n      \"address_line1\": \"123 Main St\",\n      \"city\": \"San Francisco\",\n      \"state\": \"CA\",\n      \"postal_code\": \"94105\",\n      \"address_type\": \"primary\"\n    }\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 Create company
require 'uri'
require 'net/http'

url = URI("https://api.middesk.com/v1/partner/companies")

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  \"legal_name\": \"Acme Corporation\",\n  \"ein\": \"123456789\",\n  \"external_id\": \"customer_12345\",\n  \"dba_name\": \"Acme Co\",\n  \"contact_email\": \"contact@acme.com\",\n  \"contact_name\": \"Jane Smith\",\n  \"contact_phone_number\": \"(555) 123-4567\",\n  \"entity_type\": \"corporation\",\n  \"formation_state\": \"DE\",\n  \"formation_date\": \"2020-01-15\",\n  \"addresses\": [\n    {\n      \"address_line1\": \"123 Main St\",\n      \"city\": \"San Francisco\",\n      \"state\": \"CA\",\n      \"postal_code\": \"94105\",\n      \"address_type\": \"primary\"\n    }\n  ]\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.middesk.com/v1/partner/companies")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"legal_name\": \"Acme Corporation\",\n  \"ein\": \"123456789\",\n  \"external_id\": \"customer_12345\",\n  \"dba_name\": \"Acme Co\",\n  \"contact_email\": \"contact@acme.com\",\n  \"contact_name\": \"Jane Smith\",\n  \"contact_phone_number\": \"(555) 123-4567\",\n  \"entity_type\": \"corporation\",\n  \"formation_state\": \"DE\",\n  \"formation_date\": \"2020-01-15\",\n  \"addresses\": [\n    {\n      \"address_line1\": \"123 Main St\",\n      \"city\": \"San Francisco\",\n      \"state\": \"CA\",\n      \"postal_code\": \"94105\",\n      \"address_type\": \"primary\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.middesk.com/v1/partner/companies', [
  'body' => '{
  "legal_name": "Acme Corporation",
  "ein": "123456789",
  "external_id": "customer_12345",
  "dba_name": "Acme Co",
  "contact_email": "contact@acme.com",
  "contact_name": "Jane Smith",
  "contact_phone_number": "(555) 123-4567",
  "entity_type": "corporation",
  "formation_state": "DE",
  "formation_date": "2020-01-15",
  "addresses": [
    {
      "address_line1": "123 Main St",
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94105",
      "address_type": "primary"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Create company
using RestSharp;

var client = new RestClient("https://api.middesk.com/v1/partner/companies");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"legal_name\": \"Acme Corporation\",\n  \"ein\": \"123456789\",\n  \"external_id\": \"customer_12345\",\n  \"dba_name\": \"Acme Co\",\n  \"contact_email\": \"contact@acme.com\",\n  \"contact_name\": \"Jane Smith\",\n  \"contact_phone_number\": \"(555) 123-4567\",\n  \"entity_type\": \"corporation\",\n  \"formation_state\": \"DE\",\n  \"formation_date\": \"2020-01-15\",\n  \"addresses\": [\n    {\n      \"address_line1\": \"123 Main St\",\n      \"city\": \"San Francisco\",\n      \"state\": \"CA\",\n      \"postal_code\": \"94105\",\n      \"address_type\": \"primary\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create company
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "legal_name": "Acme Corporation",
  "ein": "123456789",
  "external_id": "customer_12345",
  "dba_name": "Acme Co",
  "contact_email": "contact@acme.com",
  "contact_name": "Jane Smith",
  "contact_phone_number": "(555) 123-4567",
  "entity_type": "corporation",
  "formation_state": "DE",
  "formation_date": "2020-01-15",
  "addresses": [
    [
      "address_line1": "123 Main St",
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94105",
      "address_type": "primary"
    ]
  ]
] as [String : Any]

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

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