> This documentation belongs to Invofox, an AI-powered document processing
> platform. The API extracts structured data (fields) from unstructured
> documents (invoices, contracts, forms, bank statements, and more).
> Key concepts: Account, Environment, Document Type, Field, File, Import,
> and Document. When answering, prefer the exact terminology defined in the
> Glossary and cite the relevant API Reference endpoint when applicable.

# Update a company.

PUT https://api.invofox.com/companies/{id}
Content-Type: application/json

Reference: https://developers.invofox.com/api-reference/main-reference/collections/companies/update-a-company

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Request

### Path parameters

- `id` (string, required) — id of the company to modify

### Body (application/json)

This endpoint expects an object.

- `countryCode` (string, required) — country code in two-digits format (ISO 3166-1 alpha-2)
- `taxId` (string, required) — Tax id number
- `name` (string, required) — Business name of company

## Response

### 200

The company was successfully updated

- `result` (Company, optional)

## Errors

### 400 Bad Request Error

Request error of one of many supported types

- `UpdateACompanyRequestBadRequestError`

### 403 Forbidden Error

User is not authorized to carry out this action

- `code` (string, optional)

### 500 Internal Server Error

Unkown server error

- `code` (string, optional)

## Types

### Company

- `_id` (string, optional)
- `account` (string, optional)
- `environment` (string, optional)
- `name` (string, optional)
- `countryCode` (string, optional)
- `taxId` (string, optional) — Tax id number
- `data` (CompanyData, optional)
- `clientData` (CompanyClientData, optional)

### ErrMissingParams

Missing some or all parameters

- `code` (string, optional)
- `additionalInfo` (ErrMissingParamsAdditionalInfo, optional)

### ErrWrongParam

Wrong value for a parameter

- `code` (string, optional)
- `additionalInfo` (ErrWrongParamAdditionalInfo, optional)

### CompanyData

- `custom` (CompanyDataCustom, optional)

### CompanyClientData

### ErrMissingParamsAdditionalInfo

- `param` (string, optional) — Name of missing parameter, if there is only one
- `params` (list of string, optional) — Names of missing parameters, if there are several

### ErrWrongParamAdditionalInfo

- `param` (string, optional) — Name of parameter with wrong value
- `provided` (string, optional) — Provided value
- `valid` (ErrWrongParamAdditionalInfoValid, optional) — Valid values

### CompanyDataCustom

### ErrWrongParamAdditionalInfoValid

Valid values

## Examples

**Request**

```json
{
  "countryCode": "US",
  "taxId": "12-3456789",
  "name": "Acme Corporation"
}
```

**Response**

```json
{
  "result": {
    "_id": "5f8d0d55b54764421b7156c3",
    "account": "acc_987654321",
    "environment": "production",
    "name": "Acme Corporation",
    "countryCode": "US",
    "taxId": "12-3456789",
    "data": {
      "custom": {}
    },
    "clientData": {}
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.invofox.com/companies/id"

payload = {
    "countryCode": "US",
    "taxId": "12-3456789",
    "name": "Acme Corporation"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.invofox.com/companies/id';
const options = {
  method: 'PUT',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"countryCode":"US","taxId":"12-3456789","name":"Acme Corporation"}'
};

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

```go
package main

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

func main() {

	url := "https://api.invofox.com/companies/id"

	payload := strings.NewReader("{\n  \"countryCode\": \"US\",\n  \"taxId\": \"12-3456789\",\n  \"name\": \"Acme Corporation\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	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.invofox.com/companies/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"countryCode\": \"US\",\n  \"taxId\": \"12-3456789\",\n  \"name\": \"Acme Corporation\"\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.put("https://api.invofox.com/companies/id")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"countryCode\": \"US\",\n  \"taxId\": \"12-3456789\",\n  \"name\": \"Acme Corporation\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.invofox.com/companies/id', [
  'body' => '{
  "countryCode": "US",
  "taxId": "12-3456789",
  "name": "Acme Corporation"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.invofox.com/companies/id");
var request = new RestRequest(Method.PUT);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"countryCode\": \"US\",\n  \"taxId\": \"12-3456789\",\n  \"name\": \"Acme Corporation\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "countryCode": "US",
  "taxId": "12-3456789",
  "name": "Acme Corporation"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.invofox.com/companies/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```