# Create a company

`POST /client_api/v2/companies`

For resellers. Sets up a client company under your reseller account, and a login for it when you send an email.

## Body

- `name` (string, required): The company's name. It has to be unique across our accounts.
- `email` (string): The email for the company's own API and portal login. Left out, no login is made.
- `password` (string): The password for that login. Left out, we make one up.
- `contact_name` (string): The person we talk to at the company.
- `contact_email` (string): That person's email address.
- `contact_number` (string): That person's phone number.
- `currency_id` (string, required): The currency the company is billed in, as a three-letter code from List currencies.
- `industry` (enum): What the company does. Possible enum values: `aerospace_defense`, `airlines_aviation`, `apparel_fashion`, `arts_crafts`, `automotive`, `aviation_aerospace`, `broadcast_media`, `chemicals`, `civil_engineering`, `computer_hardware`, `computer_software`, `construction`, `consumer_electronics`, `consumer_goods`, `defense_space`, `electrical_electronic_manufacturing`, `entertainment`, `events_services`, `fine_art`, `food_beverages`, `furniture`, `health_wellness_fitness`, `healthcare_services`, `hospital_health_care`, `industrial_automation`, `information_technology_and_services`, `investment_management`, `leisure_travel_tourism`, `logistics_supply_chain`, `luxury_goods_jewelry`, `machinery`, `manufacturing`, `mechanical_or_industrial_engineering`, `medical_devices`, `oil_energy`, `package_freight_delivery`, `paper_forest_products`, `pharmaceuticals`, `photography`, `printing`, `professional_training_coaching`, `publishing`, `retail`, `sporting_goods`, `telecommunications`, `textiles`, `transportation_trucking_railroad`, `utilities`, `wireless`, `other`.
- `markup_multiplier` (number): What the company pays as a multiple of our price to you. `1.5` adds 50%.
- `address_attributes` (object, required): The company's address. Its country decides which bank details the company's invoices show.
  - `name` (string): The person to ask for. At most 35 characters.
  - `company` (string): The company at the address. At most 35 characters.
  - `address_1` (string): The street address. At most 34 characters.
  - `city` (string): The city or town. At most 20 characters.
  - `province` (string): The province, state or county.
  - `postal_code` (string): The postal code. Some countries, such as Ireland, refuse an address without one.
  - `country_id` (integer, required): The country. Take the id from List countries. Ids differ between the sandbox and production.
  - `email` (string): An email address for the person at the address. Carriers use it for delivery notices.
  - `phone` (string): A phone number for the person at the address. At most 15 characters.

## Returns

Returns the company.

- `company` (object, required): The company.
  - `id` (integer, required): The company's id.
  - `account_number` (string, required): The company's account number. Order reference numbers start with it.
  - `account_status` (enum, required): Whether the company can ship. A suspended or dormant company gets no waybills. Possible enum values: `active`, `suspended`, `dormant`.
  - `address` (object, required): The company's address.
    - `id` (integer, required): The address's id. Send it as `origin_address_id` or `destination_address_id` to use the address again.
    - `address_1` (string, required): The street address. At most 34 characters.
    - `address_2` (object, nullable, required): A second address line, such as a floor or unit. At most 34 characters.
    - `address_3` (object, nullable, required): A third address line.
    - `city` (string, required): The city or town. At most 20 characters.
    - `classification` (enum, required): Whether the address is a business or a home. Carriers charge more to deliver to a home. Possible enum values: `business`, `residential`.
    - `company` (string, required): The company at the address. At most 35 characters.
    - `country_id` (integer, required): The country. Take the id from List countries.
    - `email` (string, required): An email address for the person at the address. Carriers use it for delivery notices.
    - `import_code` (object, nullable, required): The importer number of the party at the address. The country's `import_code_label` says what it is called there.
    - `latitude` (object, nullable, required): Where the address is, filled in by us shortly after the address is saved. Empty until then.
    - `longitude` (object, nullable, required): Where the address is, filled in by us shortly after the address is saved. Empty until then.
    - `name` (string, required): The person to ask for. At most 35 characters.
    - `phone` (string, required): A phone number for the person at the address. At most 15 characters.
    - `postal_code` (string, required): The postal code. Some countries, such as Ireland, refuse an address without one.
    - `province` (string, required): The province, state or county.
    - `summary` (string, required): The country's name.
    - `tax_number` (object, nullable, required): The tax or VAT number of the party at the address. The country's `tax_number_label` says what it is called there.
    - `time_zone_id` (object, nullable, required): The address's time zone, filled in by us shortly after the address is saved. Empty until then.
  - `api_users` (array of objects, required): The company's logins.
    - `id` (integer, required): The login's id.
    - `email` (string, required): The login's email address.
    - `identity` (string, required): The login's name, or its email address when it has no name.
  - `code` (string, required): The company's code with us, the same as its account number.
  - `company_billing` (boolean, required): `true` when we invoice the company directly, `false` when we invoice you as its reseller.
  - `currency_id` (string, required): The currency the company is billed in.
  - `name` (string, required): The company's name.

## Errors

- `400 Bad Request`: The request body isn't valid JSON, or something failed on our side.
- `401 Unauthorized`: The token is missing, expired or invalid. Sign in again.

## Example request (curl)

```bash
curl -X POST "https://sandbox-api.vatit-stream.com/client_api/v2/companies" \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Karoo Leather Works",
    "email": "admin@karooleather.example",
    "password": "choose-a-password",
    "contact_name": "Pieter van Wyk",
    "contact_email": "pieter@karooleather.example",
    "contact_number": "+27 23 555 0198",
    "currency_id": "ZAR",
    "industry": "consumer_goods",
    "markup_multiplier": 1.5,
    "address_attributes": {
      "name": "Pieter van Wyk",
      "company": "Karoo Leather Works",
      "address_1": "8 Church Street",
      "city": "Prince Albert",
      "province": "Western Cape",
      "postal_code": "6930",
      "country_id": 20,
      "email": "pieter@karooleather.example",
      "phone": "+27 23 555 0198"
    }
  }'
```

## Example response (201)

```json
{
  "company": {
    "id": 11,
    "account_number": "MYSKAR001",
    "account_status": "active",
    "address": {
      "id": 147,
      "address_1": "8 Church Street",
      "address_2": null,
      "address_3": null,
      "city": "Prince Albert",
      "classification": "business",
      "company": "Karoo Leather Works",
      "country_id": 20,
      "email": "pieter@karooleather.example",
      "import_code": null,
      "latitude": null,
      "longitude": null,
      "name": "Pieter van Wyk",
      "phone": "+27235550198",
      "postal_code": "6930",
      "province": "Western Cape",
      "summary": "South Africa",
      "tax_number": null,
      "time_zone_id": null
    },
    "api_users": [
      {
        "id": 15,
        "email": "admin@karooleather.example",
        "identity": "admin@karooleather.example"
      }
    ],
    "code": "MYSKAR001",
    "company_billing": true,
    "currency_id": "ZAR",
    "name": "Karoo Leather Works"
  }
}
```
