data-src=../../includes/commerce-only.md
Manage company objects
This section describes the REST endpoints used to manage Company objects.
Service Name:
companyCompanyRepositoryV1
REST Endpoints:
POST /V1/company/
PUT /V1/company/:companyId
GET /V1/company/:companyId
DELETE /V1/company/:companyId
GET /V1/company/
CompanyInterface Parameters:
The following table lists the parameters defined in CompanyInterface.
idstatuscompany_namelegal_namecompany_emailvat_tax_idreseller_idcommentstreetcitycountry_idregionregion_idpostcodetelephonecustomer_group_id1 assigns the default shared catalog.sales_representative_idreject_reasonrejected_atsuper_user_idcustomer_id of the company administrator. When creating a company, the customer_id must already exist.Company Address Book Extension Attributes:
The B2B Storefront Compatibility Package's CompanyAddressStorefrontCompatibilityRest module adds the following extension attributes to CompanyInterface. They can be set in the extension_attributes object of POST and PUT requests, and are always returned in the extension_attributes object of GET requests.
data-variant=info
data-slots=text
is_company_address_book_enabled and is_custom_shipping_address_allowed are part of the B2B Storefront Compatibility Package and are only available on Adobe Commerce as a Cloud Service.is_company_address_book_enabledfalse for a new company.is_custom_shipping_address_allowedfalse whenever is_company_address_book_enabled is false, regardless of the value sent in the request.false for a new company.Create a company
The following example creates a company and assigns the default shared catalog (customer_group_id). The company admin (super_user_id) must be a previously-defined customer_id. This example also enables the company's address book (is_company_address_book_enabled) and allows custom shipping addresses at checkout (is_custom_shipping_address_allowed).
Sample Usage:
POST <host>/rest/<store_code>/V1/company/
data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON
Payload
{
"company": {
"company_name": "Test company",
"company_email": "newemail@example.com",
"street":[
"100 Big Tree Avenue"
],
"city": "San Francisco",
"country_id": "US",
"region": "CA",
"region_id": "12",
"postcode": "99999",
"telephone": "4155551212",
"super_user_id": 5,
"customer_group_id": 1,
"extension_attributes": {
"is_company_address_book_enabled": true,
"is_custom_shipping_address_allowed": true
}
}
}
Response
{
"id": 2,
"company_name": "Test company",
"company_email": "newemail@example.com",
"street": [
"100 Big Tree Avenue"
],
"city": "San Francisco",
"country_id": "US",
"region": "California",
"region_id": "12",
"postcode": "99999",
"telephone": "4155551212",
"customer_group_id": 1,
"sales_representative_id": 1,
"reject_reason": null,
"rejected_at": null,
"super_user_id": 5,
"extension_attributes": {
"quote_config": {
"company_id": "2",
"is_quote_enabled": false
},
"is_company_address_book_enabled": true,
"is_custom_shipping_address_allowed": true
}
}
Update the company
The following call changes the company status to Rejected (2) and explains why.
Sample Usage:
PUT <host>/rest/<store_code>/V1/company/2
data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON
Payload
{
"company": {
"id": 2,
"company_name": "Test company",
"company_email": "newemail@example.com",
"customer_group_id": 1,
"street":[
"100 Big Tree Avenue"
],
"city": "San Francisco",
"country_id": "US",
"region": "CA",
"region_id": "12",
"postcode": "99999",
"telephone": "4155551212",
"super_user_id": 5,
"status": 2,
"reject_reason": "Failed background check.",
"extension_attributes": {
"is_company_address_book_enabled": true,
"is_custom_shipping_address_allowed": true
}
}
}
Response
{
"id": 2,
"company_name": "Test company",
"company_email": "newemail@example.com",
"street": [
"100 Big Tree Avenue"
],
"city": "San Francisco",
"country_id": "US",
"region": "California",
"region_id": "12",
"postcode": "99999",
"telephone": "4155551212",
"customer_group_id": 1,
"sales_representative_id": 1,
"reject_reason": null,
"rejected_at": null,
"super_user_id": 5,
"extension_attributes": {
"quote_config": {
"company_id": "2",
"is_quote_enabled": true
},
"is_company_address_book_enabled": true,
"is_custom_shipping_address_allowed": true
}
}
Disable a company's address book
The following example disables the company address book for company 2. Even though the request also sends is_custom_shipping_address_allowed as true, Adobe Commerce always saves it as false whenever is_company_address_book_enabled is false.
Sample Usage:
PUT <host>/rest/<store_code>/V1/company/2
data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON
Payload
{
"company": {
"id": 2,
"company_name": "Test company",
"company_email": "newemail@example.com",
"customer_group_id": 1,
"street":[
"100 Big Tree Avenue"
],
"city": "San Francisco",
"country_id": "US",
"region": "CA",
"region_id": "12",
"postcode": "99999",
"telephone": "4155551212",
"super_user_id": 5,
"extension_attributes": {
"is_company_address_book_enabled": false,
"is_custom_shipping_address_allowed": true
}
}
}
Response
{
"id": 2,
"company_name": "Test company",
"company_email": "newemail@example.com",
"street": [
"100 Big Tree Avenue"
],
"city": "San Francisco",
"country_id": "US",
"region": "California",
"region_id": "12",
"postcode": "99999",
"telephone": "4155551212",
"customer_group_id": 1,
"sales_representative_id": 1,
"reject_reason": null,
"rejected_at": null,
"super_user_id": 5,
"extension_attributes": {
"quote_config": {
"company_id": "2",
"is_quote_enabled": true
},
"is_company_address_book_enabled": false,
"is_custom_shipping_address_allowed": false
}
}
is_custom_shipping_address_allowed is forced to false in the saved config and in the response, regardless of the value sent in the request, whenever is_company_address_book_enabled is false. Once the address book is disabled, requests to create, update, delete, or set the default company addresses return 400 Bad Request with the message Company address book is not enabled for this company.
Return all information about a company
This call returns detailed information about the specified company. Sample Usage:
GET <host>/rest/<store_code>/V1/company/2
data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON
payload
// none
Response
{
"id": 2,
"status": 0,
"company_name": "Test company",
"company_email": "newemail@example.com",
"street": [
"100 Big Tree Avenue"
],
"city": "San Francisco",
"country_id": "US",
"region": "California",
"region_id": "12",
"postcode": "99999",
"telephone": "4155551212",
"customer_group_id": 1,
"sales_representative_id": 1,
"reject_reason": null,
"rejected_at": null,
"super_user_id": 5,
"extension_attributes": {
"quote_config": {
"company_id": "2",
"is_quote_enabled": true
},
"is_company_address_book_enabled": false,
"is_custom_shipping_address_allowed": false
}
}
GET requests always include is_company_address_book_enabled and is_custom_shipping_address_allowed in extension_attributes, defaulting to false for a company that has never had these values set.
Delete a company
When you delete a company, Adobe Commerce assigns the "Inactive" status to all company members. The system also removes company ID from the customer profile of all company members.
Sample Usage:
DELETE <host>/rest/<store_code>/V1/company/2
data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON
payload
// none
Response
// `true`, indicating the request was successful
Search for companies
The following call returns all companies that are located in California (region_id = 12)
See Search using REST APIs for information about constructing a search query.
Sample Usage:
GET <host>/rest/<store_code>/V1/company?searchCriteria[filter_groups][0][filters][0][field]=region_id&searchCriteria[filter_groups][0][filters][0][value]=12&searchCriteria[filter_groups][0][filters][0][condition_type]=eq
data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON
payload
// none
Response
{
"items": [
{
"id": 2,
"status": 1,
"company_name": "Test Company",
"legal_name": "Test Company",
"company_email": "newemail@example.com",
"street": [
"100 Big Tree Avenue"
],
"city": "San Francisco",
"country_id": "US",
"region": "California",
"region_id": "12",
"postcode": "99999",
"telephone": "4155551212",
"customer_group_id": 1,
"sales_representative_id": 1,
"reject_reason": null,
"rejected_at": null,
"super_user_id": 3,
"extension_attributes": {
"applicable_payment_method": 0,
"available_payment_methods": "banktransfer,cashondelivery,checkmo,payflowpro,payflow_advanced,payflow_link,braintree,cybersource,eway,authorizenet_directpost,free,braintree_paypal,paypal_billing_agreement,payflow_express_bml,paypal_express_bml,paypal_express,payflow_express,hosted_pro,worldpay,companycredit,purchaseorder,braintree_paypal_vault,braintree_cc_vault,payflowpro_cc_vault",
"use_config_settings": 1,
"quote_config": {
"is_quote_enabled": true
},
"is_company_address_book_enabled": false,
"is_custom_shipping_address_allowed": false
}
},
{
"id": 3,
"status": 1,
"company_name": "Widgets, Inc",
"legal_name": "Widgets, Inc",
"company_email": "widgetsinc@example.com",
"street": [
"8383 Wilshire Blvd",
"Ste 1500"
],
"city": "Beverly Hills",
"country_id": "US",
"region": "California",
"region_id": "12",
"postcode": "90211",
"telephone": "(310) 555-0000",
"customer_group_id": 1,
"sales_representative_id": 1,
"reject_reason": null,
"rejected_at": null,
"super_user_id": 10,
"extension_attributes": {
"applicable_payment_method": 0,
"available_payment_methods": "banktransfer,cashondelivery,checkmo,payflowpro,payflow_advanced,payflow_link,braintree,cybersource,eway,authorizenet_directpost,free,braintree_paypal,paypal_billing_agreement,payflow_express_bml,paypal_express_bml,paypal_express,payflow_express,hosted_pro,worldpay,companycredit,purchaseorder,braintree_paypal_vault,braintree_cc_vault,payflowpro_cc_vault",
"use_config_settings": 1,
"quote_config": {
"is_quote_enabled": true
},
"is_company_address_book_enabled": true,
"is_custom_shipping_address_allowed": true
}
}
],
"search_criteria": {
"filter_groups": [
{
"filters": [
{
"field": "region_id",
"value": "12",
"condition_type": "eq"
}
]
}
]
},
"total_count": 2
}