Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255 changes: 255 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,255 @@
---
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