|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +group: b2b |
| 4 | +subgroup: 10_REST |
| 5 | +title: Manage company objects |
| 6 | +menu_title: Manage company objects |
| 7 | +menu_order: 12 |
| 8 | +version: 2.2 |
| 9 | +ee_only: true |
| 10 | +level3_menu_node: level3child |
| 11 | +level3_subgroup: company |
| 12 | +github_link: b2b/company-object.md |
| 13 | +--- |
| 14 | + |
| 15 | + |
| 16 | +## Manage company objects |
| 17 | + |
| 18 | +This section describes the REST endpoints used to manage `Company` objects. |
| 19 | + |
| 20 | +**Service Name** |
| 21 | + |
| 22 | +`companyCompanyRepositoryV1` |
| 23 | + |
| 24 | +**REST Endpoints** |
| 25 | + |
| 26 | +{% highlight json %} |
| 27 | +POST /V1/company/ |
| 28 | +PUT /V1/company/:companyId |
| 29 | +GET /V1/company/:companyId |
| 30 | +DELETE /V1/company/:companyId |
| 31 | +GET /V1/company/ |
| 32 | +{% endhighlight %} |
| 33 | + |
| 34 | +**CompanyInterface Parameters** |
| 35 | + |
| 36 | +The following table lists the parameters defined in `CompanyInterface`. |
| 37 | + |
| 38 | +<table> |
| 39 | +<tr> |
| 40 | +<th>Name</th><th>Description</th><th>Format</th><th>Requirements</th></tr> |
| 41 | +<tr> |
| 42 | +<td><code>id</code></td><td>System-generated company ID </td><td>integer </td><td>Required for updates and deletes. </td></tr> |
| 43 | +<tr> |
| 44 | +<td><code>status</code></td><td>0 - Pending approval<br>1 - Approved<br>2 - Rejected<br>3 - Blocked </td><td>integer </td><td>Optional </td></tr> |
| 45 | +<tr> |
| 46 | +<td><code>company_name </code></td><td>Company name </td><td>string </td><td>Required to create or update a company. </td></tr> |
| 47 | +<tr> |
| 48 | +<td><code>legal_name </code></td><td>Legal name </td><td>string </td><td>Optional </td></tr> |
| 49 | +<tr> |
| 50 | +<td><code>company_email </code></td><td>Official e-mail address of the company. It does not have to be unique. </td><td>string</td><td>Required to create or update a company.</td></tr> |
| 51 | +<tr> |
| 52 | +<td><code>vat_tax_id </code></td><td>The company's Value Added Tax ID </td><td>string </td><td>Optional </td></tr> |
| 53 | +<tr> |
| 54 | +<td><code>reseller_id </code></td><td>Unique ID of the company reseller </td><td>string </td><td>Optional </td></tr> |
| 55 | +<tr> |
| 56 | +<td><code>comment </code></td><td>Additional details about the company</td><td>string</td><td>Optional </td></tr> |
| 57 | +<tr> |
| 58 | +<td><code>street</code></td><td>Street address where the company is registered. The array can contain one or two lines.</td><td>Array[string]</td><td>Required to create or update a company.</td></tr> |
| 59 | +<tr> |
| 60 | +<td><code>city</code></td><td>The company's city </td><td>string </td><td>Required to create or update a company.</td></tr> |
| 61 | +<tr> |
| 62 | +<td><code>country_id</code></td><td>The country where the company is registered.</td><td>string </td><td>Required to create or update a company. </td></tr> |
| 63 | +<tr> |
| 64 | +<td><code>region</code></td><td>State or province</td><td>string</td><td>Required to create or update a company.</td></tr> |
| 65 | +<tr> |
| 66 | +<td><code>region_id</code></td><td>An ID assigned to a state or province</td><td>string </td><td>Optional</td></tr> |
| 67 | +<tr> |
| 68 | +<td><code>postcode</code></td><td>The company's ZIP or postal code</td><td>string </td><td>Required to create or update a company.</td></tr> |
| 69 | +<tr> |
| 70 | +<td><code>telephone</code></td><td>The company contact's phone number</td><td>string</td><td>Required to create or update a company.</td></tr> |
| 71 | +<tr> |
| 72 | +<td><code>customer_group_id </code></td><td>Defines the company's shared catalog. A value of `1` assigns the default shared catalog.</td><td>integer</td><td>Required to create or update a company.</td></tr> |
| 73 | +<tr> |
| 74 | +<td><code>sales_representative_id</code></td><td>User ID of the Sales Representative for the company</td><td>integer</td><td>Optional</td></tr> |
| 75 | +<tr> |
| 76 | +<td><code>reject_reason</code></td><td>Specifies why a company's request to be a B2B customer is rejected</td><td>string</td><td>Optional </td></tr> |
| 77 | +<tr> |
| 78 | +<td><code>rejected_at</code></td><td>A timestamp incdicating when the company was rejected.</td><td>string</td><td>Optional</td></tr> |
| 79 | +<tr> |
| 80 | +<td><code>super_user_id</code></td><td>The `customer_id` of the company administrator. When creating a company, the `customer_id` must already exist. </td><td>integer</td><td>Required to create or update a company.</td></tr> |
| 81 | +</table> |
| 82 | + |
| 83 | + |
| 84 | +### Create a company |
| 85 | + |
| 86 | +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`. |
| 87 | + |
| 88 | +**Sample Usage** |
| 89 | + |
| 90 | +`POST /V1/company/` |
| 91 | + |
| 92 | +**Payload** |
| 93 | + |
| 94 | +{% highlight json %} |
| 95 | +{ |
| 96 | + "company": { |
| 97 | + "company_name": "Test company", |
| 98 | + "company_email": " [email protected]", |
| 99 | + "street":[ |
| 100 | + "100 Big Tree Avenue" |
| 101 | + ], |
| 102 | + "city": "San Francisco", |
| 103 | + "country_id": "US", |
| 104 | + "region": "CA", |
| 105 | + "region_id": "12", |
| 106 | + "postcode": "99999", |
| 107 | + "telephone": "4155551212", |
| 108 | + "super_user_id": 5, |
| 109 | + "customer_group_id": 1 |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +{% endhighlight %} |
| 114 | + |
| 115 | +**Response** |
| 116 | + |
| 117 | +{% highlight json %} |
| 118 | +{ |
| 119 | + "id": 2, |
| 120 | + "company_name": "Test company", |
| 121 | + "company_email": " [email protected]", |
| 122 | + "street": [ |
| 123 | + "100 Big Tree Avenue" |
| 124 | + ], |
| 125 | + "city": "San Francisco", |
| 126 | + "country_id": "US", |
| 127 | + "region": "California", |
| 128 | + "region_id": "12", |
| 129 | + "postcode": "99999", |
| 130 | + "telephone": "4155551212", |
| 131 | + "customer_group_id": 1, |
| 132 | + "sales_representative_id": 1, |
| 133 | + "reject_reason": null, |
| 134 | + "rejected_at": null, |
| 135 | + "super_user_id": 5, |
| 136 | + "extension_attributes": { |
| 137 | + "quote_config": { |
| 138 | + "company_id": "2", |
| 139 | + "is_quote_enabled": false |
| 140 | + } |
| 141 | + } |
| 142 | +} |
| 143 | +{% endhighlight %} |
| 144 | + |
| 145 | +### Update the company |
| 146 | + |
| 147 | +The following call changes the company status to Rejected (`2`) and explains why. |
| 148 | + |
| 149 | +**Sample Usage** |
| 150 | + |
| 151 | +`PUT /V1/company/2` |
| 152 | + |
| 153 | +**Payload** |
| 154 | + |
| 155 | +{% highlight json %} |
| 156 | +{ |
| 157 | + "company": { |
| 158 | + "id": 2, |
| 159 | + "company_name": "Test company", |
| 160 | + "company_email": " [email protected]", |
| 161 | + "customer_group_id": 1, |
| 162 | + "street":[ |
| 163 | + "100 Big Tree Avenue" |
| 164 | + ], |
| 165 | + "city": "San Francisco", |
| 166 | + "country_id": "US", |
| 167 | + "region": "CA", |
| 168 | + "region_id": "12", |
| 169 | + "postcode": "99999", |
| 170 | + "telephone": "4155551212", |
| 171 | + "super_user_id": 5, |
| 172 | + "status": 2, |
| 173 | + "reject_reason": "Failed background check." |
| 174 | + |
| 175 | + } |
| 176 | +} |
| 177 | +{% endhighlight %} |
| 178 | + |
| 179 | +**Response** |
| 180 | + |
| 181 | +{% highlight json %} |
| 182 | +{ |
| 183 | + "id": 2, |
| 184 | + "company_name": "Test company", |
| 185 | + "company_email": " [email protected]", |
| 186 | + "street": [ |
| 187 | + "100 Big Tree Avenue" |
| 188 | + ], |
| 189 | + "city": "San Francisco", |
| 190 | + "country_id": "US", |
| 191 | + "region": "California", |
| 192 | + "region_id": "12", |
| 193 | + "postcode": "99999", |
| 194 | + "telephone": "4155551212", |
| 195 | + "customer_group_id": 1, |
| 196 | + "sales_representative_id": 1, |
| 197 | + "reject_reason": null, |
| 198 | + "rejected_at": null, |
| 199 | + "super_user_id": 5, |
| 200 | + "extension_attributes": { |
| 201 | + "quote_config": { |
| 202 | + "company_id": "2", |
| 203 | + "is_quote_enabled": true |
| 204 | + } |
| 205 | + } |
| 206 | +} |
| 207 | +{% endhighlight %} |
| 208 | + |
| 209 | +### Return all information about a company |
| 210 | + |
| 211 | +This call returns detailed information about the specified company. |
| 212 | +**Sample Usage** |
| 213 | + |
| 214 | +`GET /V1/company/2` |
| 215 | + |
| 216 | +**Payload** |
| 217 | + |
| 218 | +None |
| 219 | + |
| 220 | +**Response** |
| 221 | + |
| 222 | +{% highlight json %} |
| 223 | +{ |
| 224 | + "id": 2, |
| 225 | + "status": 0, |
| 226 | + "company_name": "Test company", |
| 227 | + "company_email": " [email protected]", |
| 228 | + "street": [ |
| 229 | + "100 Big Tree Avenue" |
| 230 | + ], |
| 231 | + "city": "San Francisco", |
| 232 | + "country_id": "US", |
| 233 | + "region": "California", |
| 234 | + "region_id": "12", |
| 235 | + "postcode": "99999", |
| 236 | + "telephone": "4155551212", |
| 237 | + "customer_group_id": 1, |
| 238 | + "sales_representative_id": 1, |
| 239 | + "reject_reason": null, |
| 240 | + "rejected_at": null, |
| 241 | + "super_user_id": 5, |
| 242 | + "extension_attributes": { |
| 243 | + "quote_config": { |
| 244 | + "company_id": "2", |
| 245 | + "is_quote_enabled": true |
| 246 | + } |
| 247 | + } |
| 248 | +} |
| 249 | +{% endhighlight %} |
| 250 | + |
| 251 | + |
| 252 | +### Delete a company |
| 253 | + |
| 254 | +When you delete a company, Magento assigns the "Inactive" status to all company members. The system also removes company ID from the customer profile of all company members. |
| 255 | + |
| 256 | +**Sample Usage** |
| 257 | + |
| 258 | +`DELETE /V1/company/2` |
| 259 | + |
| 260 | +**Payload** |
| 261 | + |
| 262 | +None |
| 263 | + |
| 264 | +**Response** |
| 265 | + |
| 266 | +`true`, indicating the request was successful |
| 267 | + |
| 268 | +### Search for a company |
| 269 | + |
| 270 | +See [Search using REST APIs]({{page.baseurl}}howdoi/webapi/search-criteria.html) for information about constructing a query using the `GET /V1/company/` endpoint. |
| 271 | + |
| 272 | +## Related information |
| 273 | + |
| 274 | +* [Integrate with the Company module]({{page.baseurl}}b2b/company.html) |
| 275 | +* [Manage company users]({{page.baseurl}}b2b/company-users.html) |
| 276 | +* [Manage company roles]({{page.baseurl}}b2b/roles.html) |
| 277 | +* [Manage company structures]({{page.baseurl}}b2b/company-structures.html) |
0 commit comments