Skip to main content

Company Creation (B2B)

🏒 Company Create/Update Functionality on Shopify

The endpoint allows you to create or update a B2B Company on Shopify, including contacts (company contact) and locations (company location).

Company search logic​

Before creating or updating, the system searches for an existing company on Shopify:

  1. If the company Id is present, a search is performed via Shopify Id (node(id: …)).
    • If the company exists, the flow continues with an update.
    • If not found, the flow continues with creation.
  2. If the Id is not set, the search is performed via Reference (input field reference β†’ externalId on Shopify).
    • Search filter: external_id:{reference}.
    • If the company exists β†’ update; otherwise β†’ creation.

πŸ’‘ Note: The reference field is required in every request (ingress validation). Even when id is present, reference must be set.

Input validation​

Validation is performed by the adapter before any call to Shopify. If validation fails, the message is rejected with the corresponding error.

FieldRule
referenceRequired on every request
contacts[].emailRequired for each contact when the contacts list is provided
contacts[].emailMust be unique within the list (case-insensitive)
contacts[].phoneWhen set, must be unique within the list
locations[].referenceRequired for each location when the locations list is provided
locations[].referenceMust be unique within the list (case-insensitive)
locations (update)When the list is present, it cannot be an empty array ([]). Allowed values: null or one or more objects

πŸ’‘ Main contact: set isMainContact: true on exactly one contact in the contacts list.

Contact checks​

In addition to ingress validation, before creating or linking a contact the service checks whether a Shopify customer already exists with the same email (or, when both are set, via the contact id and email).

SituationOutcome
Customer not found on ShopifyThe contact can be created
Existing customer, not linked to any companyThe contact can be linked to the company
Customer already linked to another companyError β€” synchronization not allowed

Error message:

The following contacts are already associated with another company: email1@example.com, email2@example.com.

Create and update​

The endpoint creates or updates the company, contacts, and locations in upsert mode.

Company​

Managed fields: reference, name, note. On update, omitted fields keep their existing values on Shopify.

Contacts​

Matching with existing contacts on Shopify (in order):

  1. Company contact id (GID or normalized numeric value)
  2. email (case-insensitive comparison)
ResultAction
Not foundContact creation or linking
FoundUpdate of the existing contact
Present on Shopify, absent in inputContact deletion

Location​

Matching with existing locations on Shopify (in order):

  1. Company location id (GID or normalized numeric value)
  2. reference (mapped to externalId on Shopify)
ResultAction
Not foundLocation creation
FoundLocation update (master data, configuration, tax exemptions, shipping and billing addresses)
Present on Shopify, absent in inputLocation deletion

On location update, the following are also supported:

  • Tax exemptions via configurations.taxExemptions
  • Shipping (shippingAddress) and billing (billingAddress) addresses
  • When isBillingSameAsShipping is true, the billing address matches the shipping address

Destination configuration​

Configure a Shopify destination and associate it with the flow, in addition to the basic data flow configuration.

FieldValueNotes
Destination TypeShopify
OperationSync companyPOST /egress/sync-company-to-shopify
GraphQL endpoint URLhttps://SHOPIFYURL.myshopify.com/Shopify Admin GraphQL API endpoint URL
Admin API access tokenshpat_CODICEALFANUMERICOOr Client ID (API key) + Client secret β€” see Authentication
Client ID (API key)YOUR_CLIENT_ID
Client secretYOUR_CLIENT_SECRET
x-parallel-processes-number1 (default)Number of parallel workers for bulk processing (minimum 1)

Deprecated β€” previous configuration (HTTP Adapter)​

Deprecated

Configuration via HTTP Adapter with Base Url, Resource Path, and x-api-key header in Settings Override is deprecated. Use the Shopify destination configuration described above.

In addition to the basic data flow configuration, the following Settings Override settings were required:

FieldValueNotes
Base Urlhttps://adapter.flowlyze.ioAdapter URL
Resource Pathapi/adp/shopify/egress/sync-company-to-shopifyAdapter path for the company sync flow
Headers :: x-api-key**********API key for endpoint interaction verification
Headers :: x-shopify-access-tokenshpat_CODICEALFANUMERICOSecret of the custom app created for integration
Headers :: x-shopify-graphql-urlhttps://SHOPIFYURL.myshopify.com/Shopify shop URL to connect to
Headers :: x-parallel-processes-number1Message processing parallelism

Input message examples​

1. Full company creation / update​

{
"reference": "ACME-001",
"name": "Acme Corporation",
"note": "Primary B2B customer",
"contacts": [
{
"isMainContact": true,
"email": "mario.rossi@acme.com",
"firstName": "Mario",
"lastName": "Rossi",
"phone": "+393401234567",
"title": "Purchasing Manager"
},
{
"email": "luisa.bianchi@acme.com",
"firstName": "Luisa",
"lastName": "Bianchi",
"title": "Accounting"
}
],
"locations": [
{
"reference": "ACME-HQ-MILANO",
"name": "Milan Office",
"phone": "+390212345678",
"isBillingSameAsShipping": true,
"shippingAddress": {
"firstName": "Mario",
"lastName": "Rossi",
"street1": "Via Roma 1",
"city": "Milano",
"zip": "20100",
"countryCode": "IT",
"phone": "+393401234567"
},
"configurations": {
"checkoutToDraft": false,
"editableShippingAddress": true,
"paymentTermsTemplateId": "gid://shopify/PaymentTermsTemplate/2",
"taxExemptions": []
}
},
{
"reference": "ACME-WH-ROMA",
"name": "Rome Warehouse",
"isBillingSameAsShipping": false,
"shippingAddress": {
"street1": "Via Appia 100",
"city": "Roma",
"zip": "00100",
"countryCode": "IT"
},
"billingAddress": {
"street1": "Via del Corso 50",
"city": "Roma",
"zip": "00186",
"countryCode": "IT"
},
"configurations": {
"checkoutToDraft": false,
"editableShippingAddress": true,
"depositPercentage": 50,
"paymentTermsTemplate": "Net 30",
"taxExemptions": ["CA_BC_COMMERCIAL_FISHERY_EXEMPTION"]
}
}
]
}