Skip to content
8 changes: 8 additions & 0 deletions src/pages/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
- [Manage company users](/rest/b2b/company-users.md)
- [Manage company roles](/rest/b2b/roles.md)
- [Manage company structures](/rest/b2b/company-structures.md)
- [Create a company address](/rest/b2b/create-address.md)
- [Update a company address](/rest/b2b/update-address.md)
- [Delete a company address](/rest/b2b/delete-address.md)
- [Set a company address as default](/rest/b2b/set-default-address.md)
- [Company credit](/rest/b2b/company-credit.md)
- [Manage company credit](/rest/b2b/credit-manage.md)
- [Shared catalog](/rest/b2b/shared-catalog.md)
Expand Down Expand Up @@ -257,13 +261,17 @@
- [Mutations](/graphql/schema/b2b/company/mutations/index.md)
- [assignChildCompany](/graphql/schema/b2b/company/mutations/assign-child-company.md)
- [createCompany](/graphql/schema/b2b/company/mutations/create.md)
- [createCompanyAddress](/graphql/schema/b2b/company/mutations/create-address.md)
- [createCompanyRole](/graphql/schema/b2b/company/mutations/create-role.md)
- [createCompanyTeam](/graphql/schema/b2b/company/mutations/create-team.md)
- [createCompanyUser](/graphql/schema/b2b/company/mutations/create-user.md)
- [deleteCompanyAddress](/graphql/schema/b2b/company/mutations/delete-address.md)
- [deleteCompanyRole](/graphql/schema/b2b/company/mutations/delete-role.md)
- [deleteCompanyTeam](/graphql/schema/b2b/company/mutations/delete-team.md)
- [deleteCompanyUser](/graphql/schema/b2b/company/mutations/delete-user.md)
- [setDefaultCompanyAddress](/graphql/schema/b2b/company/mutations/set-default-address.md)
- [updateCompany](/graphql/schema/b2b/company/mutations/update.md)
- [updateCompanyAddress](/graphql/schema/b2b/company/mutations/update-address.md)
- [unassignChildCompany](/graphql/schema/b2b/company/mutations/unassign-child-company.md)
- [updateCompanyRole](/graphql/schema/b2b/company/mutations/update-role.md)
- [updateCompanyStructure](/graphql/schema/b2b/company/mutations/update-structure.md)
Expand Down
253 changes: 253 additions & 0 deletions src/pages/graphql/schema/b2b/company/mutations/create-address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
---
title: createCompanyAddress mutation
description: The createCompanyAddress mutation allows a company admin or user who is assigned a role that contains the Magento_CompanyAddressStorefrontCompatibility::add permission to create a new company address.
keywords:
- B2B
---

<Fragment src="../../../../../includes/commerce-only.md"/>

# createCompanyAddress mutation

<InlineAlert variant="info" slots="text1" />

This mutation is part of the B2B Storefront Compatibility Package and is only available on [Adobe Commerce as a Cloud Service](https://experienceleague.adobe.com/en/docs/commerce/cloud-service/overview).

The `createCompanyAddress` mutation allows a company admin or user who is assigned a role that contains the `Magento_CompanyAddressStorefrontCompatibility::add` permission to create a new company address.

This mutation requires a valid [customer authentication token](../../../customer/mutations/generate-token.md).

## Syntax

```graphql
mutation {
createCompanyAddress(
input: CompanyAddressInput!
) {
CompanyAddress
}
}
```

## Example usage

### Create a company address (type: billing)

The following example creates a company billing address.

**Request:**

```graphql
mutation CreateCompanyAddress {
createCompanyAddress(
input: {
nickname: "HQ Billing"
address_type: BILLING
is_default: true
firstname: "John"
lastname: "Doe"
middlename: "Q"
prefix: "Mr."
suffix: "Jr."
company: "Company name"
street: ["123 Main St"]
city: "Austin"
country_code: US
region: {
region_id: 57
region: "Texas"
region_code: "TX"
}
postcode: "78701"
telephone: "5551234567"
fax: "5551234568"
vat_id: "US123456789"
custom_attributes: [
{ attribute_code: "my_custom_attr", value: "custom value" }
]
}
) {
id
nickname
company_id
address_type
is_default
firstname
lastname
middlename
prefix
suffix
company
street
city
country_code
region_id
region {
region_id
region
region_code
}
postcode
telephone
fax
vat_id
custom_attributes {
code
... on AttributeValue {
value
}
}
}
}
```

**Response:**

```json
{
"data": {
"createCompanyAddress": {
"id": "MTI=",
"nickname": "HQ Billing",
"company_id": "Mw==",
"address_type": "BILLING",
"is_default": true,
"firstname": "John",
"lastname": "Doe",
"middlename": "Q",
"prefix": "Mr.",
"suffix": "Jr.",
"company": "Company name",
"street": ["123 Main St"],
"city": "Austin",
"country_code": "US",
"region_id": 57,
"region": {
"region_id": 57,
"region": "Texas",
"region_code": "TX"
},
"postcode": "78701",
"telephone": "5551234567",
"fax": "5551234568",
"vat_id": "US123456789",
"custom_attributes": []
}
}
}
```

### Create a company address (type: shipping)

The following example creates a company billing address.

**Request:**

```graphql
mutation CreateCompanyAddress {
createCompanyAddress(
input: {
nickname: "HQ Shipping"
address_type: SHIPPING
is_default: true
firstname: "John"
lastname: "Doe"
middlename: "Q"
prefix: "Mr."
suffix: "Jr."
company: "Company name"
street: ["123 Main St"]
city: "Austin"
country_code: US
region: {
region_id: 57
region: "Texas"
region_code: "TX"
}
postcode: "78701"
telephone: "5551234567"
fax: "5551234568"
vat_id: "US123456789"
custom_attributes: [
{ attribute_code: "my_custom_attr", value: "custom value" }
]
}
) {
id
nickname
company_id
address_type
is_default
firstname
lastname
middlename
prefix
suffix
company
street
city
country_code
region_id
region {
region_id
region
region_code
}
postcode
telephone
fax
vat_id
custom_attributes {
code
... on AttributeValue {
value
}
}
}
}
```

**Response:**

```json
{
"data": {
"createCompanyAddress": {
"id": "MTM=",
"nickname": "HQ Shipping",
"company_id": "Mw==",
"address_type": "SHIPPING",
"is_default": true,
"firstname": "John",
"lastname": "Doe",
"middlename": "Q",
"prefix": "Mr.",
"suffix": "Jr.",
"company": "Company name",
"street": ["123 Main St"],
"city": "Austin",
"country_code": "US",
"region_id": 57,
"region": {
"region_id": 57,
"region": "Texas",
"region_code": "TX"
},
"postcode": "78701",
"telephone": "5551234567",
"fax": "5551234568",
"vat_id": "US123456789",
"custom_attributes": []
}
}
}
```

## Errors

| Error | Description |
| --- | --- |
| `Customer is not a company user.` | Not authenticated or not a company user |
| `Company context is required.` | Missing `X-Adobe-Company` header |
| `Company address book is not enabled for this company.` | Address book disabled for company |
| `You do not have authorization to perform this action.` | Missing add or set-default ACL |
54 changes: 54 additions & 0 deletions src/pages/graphql/schema/b2b/company/mutations/delete-address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: deleteCompanyAddress mutation
description: The deleteCompanyAddress mutation allows a company admin or user who is assigned a role that contains the Magento_CompanyAddressStorefrontCompatibility::delete permission to delete an existing company address.
keywords:
- B2B
---

<Fragment src="../../../../../includes/commerce-only.md"/>

# deleteCompanyAddress mutation

<InlineAlert variant="info" slots="text1" />

This mutation is part of the B2B Storefront Compatibility Package and is only available on [Adobe Commerce as a Cloud Service](https://experienceleague.adobe.com/en/docs/commerce/cloud-service/overview).

The `deleteCompanyAddress` mutation allows a company admin or user who is assigned a role that contains the `Magento_CompanyAddressStorefrontCompatibility::delete` permission to delete an existing company address using a provided company UID.

This mutation requires a valid [customer authentication token](../../../customer/mutations/generate-token.md).

## Syntax

```graphql
mutation {
deleteCompanyAddress(
id: ID!
) {
Boolean
}
}
```

## Example usage

### Delete a company address

The following example deletes an existing company address.

**Request:**

```graphql
mutation DeleteCompanyAddress {
deleteCompanyAddress(id: "MTI=")
}
```

**Response:**

```json
{
"data": {
"deleteCompanyAddress": true
}
}
```
7 changes: 7 additions & 0 deletions src/pages/graphql/schema/b2b/company/mutations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ The B2B company mutations allow you to perform the management operations:
* Move the position of a company team in the company hierarchy.
* Create, update, and delete company roles.
* Assign and unassign a company to a company hierarchy.

# Company Address Book mutations

The company address book mutations allow you to perform the company address management operations:

* Create, update and delete a company address.
* Set default company billing or shipping address.
Loading
Loading