Create Company
Create a new company with associated address and user account.
Endpoint
POST /companies
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The company name |
address_attributes | object | Yes | Address information for the company |
validate_address | boolean | No | Whether to validate the address against FedEx to ensure it is deliverable and correctly formatted |
currency_id | string | Yes | Currency code for the company (e.g., "GBP", "USD") |
email | string | Yes | Email for creating a user account linked to this company; this user will be used when placing orders or quotes |
Address Attributes
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | No | Name of the contact person |
company | string | No | Company name for the address |
email | string | No | Contact email address |
address_1 | string | No | Primary address line |
address_2 | string | No | Secondary address line |
address_3 | string | No | Additional address line |
postal_code | string | No | Postal/ZIP code |
city | string | No | City name |
province | string | No | Province/state |
country_id | integer | Yes | Country identifier |
phone | string | No | Contact phone number |
import_code | string | No | Import reference code |
tax_number | string | No | Tax identification number |
classification | string | No | Address classification. Must be either "business" or "residential" |
export_code | string | No | Export reference code |
Request Example
curl -X POST \
https://stream-orders-api-sandbox.herokuapp.com/client_api/v2/companies \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"name": "New Test Company",
"address_attributes": {
"name": "John Doe",
"company": "New Test Company",
"email": "example@company.com",
"address_1": "221B Baker Street",
"address_2": "Flat 2",
"address_3": "",
"postal_code": "NW1 6XE",
"city": "London",
"province": "Greater London",
"country_id": "232",
"phone": "+442079173000",
"import_code": "IMP123456",
"tax_number": "GB123456789",
"classification": "business",
"export_code": "EXP654321"
},
"validate_address": false,
"currency_id": "GBP",
"email": "test@example.com"
}'
{
"name": "New Test Company",
"address_attributes": {
"name": "John Doe",
"company": "New Test Company",
"email": "example@company.com",
"address_1": "221B Baker Street",
"address_2": "Flat 2",
"address_3": "",
"postal_code": "NW1 6XE",
"city": "London",
"province": "Greater London",
"country_id": "232",
"phone": "+442079173000",
"import_code": "IMP123456",
"tax_number": "GB123456789",
"classification": "business",
"export_code": "EXP654321"
},
"validate_address": false,
"currency_id": "GBP",
"email": "test@example.com"
}
Response
Success Response
Status Code: 201 Created
{
"company": {
"id": 2533,
"account_number": "STRNEW0013",
"account_status": "active_account",
"address": {
"id": 1075175,
"address_1": "221B Baker Street",
"address_2": "Flat 2",
"address_3": "",
"city": "London",
"classification": "business",
"company": "New Test Company",
"country_id": 232,
"email": "example@company.com",
"import_code": "IMP123456",
"latitude": null,
"longitude": null,
"name": "John Doe",
"phone": "+442079173000",
"postal_code": "NW1 6XE",
"province": "Greater London",
"summary": "Ukraine",
"tax_number": "GB123456789",
"time_zone_id": null
},
"code": "STRNEW0013",
"currency_id": "GBP",
"name": "New Test Company",
"api_users": [
{
"id": 5474,
"email": "test@vatitstream.com"
}
]
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
company.id | integer | Unique identifier for the company |
company.account_number | string | Generated account number for the company |
company.account_status | string | Current status of the account (e.g., "active_account") |
company.address | object | Complete address information with assigned ID |
company.code | string | Company code (same as account_number) |
company.currency_id | string | Currency code for the company |
company.name | string | Company name |
company.api_users | array | Array of API users associated with this company |
company.api_users[].id | integer | Unique identifier for the API user |
company.api_users[].email | string | Email address of the API user |
Error Responses
Status Code: 422 Unprocessable Entity
{
"error": "Validation failed: Api users email has already been taken, Api users email User has been taken and is on Company 'Acme Corporation' under Reseller 'Stream', Name has already been taken"
}
Notes
- The
emailparameter creates a user account that will be linked to this company - This user account will be used for placing orders and quotes
- The
validate_addressoption uses FedEx validation to ensure address deliverability - All address attributes except
country_idare optional - The
classificationfield only accepts two values: "business" or "residential" - The system automatically generates an account number and code for the new company