For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Dev Portal
DocsAPI ReferenceLearnCommunityChangelog
DocsAPI ReferenceLearnCommunityChangelog
  • Overview
    • Quick Start
    • Sandboxes
    • Tools & SDKs
    • Support
  • Docs
      • Getting Started
          • Overview
          • Authentication
          • Best Practices
          • Analytics
          • B2B
          • Cart and Checkout
          • Customers
          • Orders
          • Routes and Content
          • Storefront Scripts
    • Archive
    • Closed Beta Programs
Dev Portal
LogoLogo
On this page
  • Overview
  • Tokens
  • Registering a Company Account
  • Required Fields
  • Example Mutation
  • Considerations
  • Resources
  • Documentation
  • API Reference
  • Tools
  • Community
DocsStorefrontGuidesGraphQL Storefront

GraphQL Storefront API: Company Account Registration

Was this page helpful?
Previous

Analytics

Next

Customers

Built with

Overview

In most scenarios, B2B Edition’s GraphQL Storefront API powers access to Company account objects, including a Company’s users and addresses. The default Buyer Portal uses these queries and mutations to handle the Company creation and management experience for buyers.

However, BigCommerce’s GraphQL Storefront API includes the registerCompany mutation for requesting a Company account as a storefront user with an existing customer account. This allows you to build separate forms for registering customers and Companies using a unified set of APIs and authentication models.

The registerCompany mutation accepts Company information like name, primary address, and custom fields configured in the B2B Edition control panel. If you’ve created extra fields for Company user records, it also allows current B2C customers to supply that information while requesting a B2B account. Upon success, this generates a new Company account in either the Pending or Active status, depending on your store’s Company management configurations. See the “General Settings” section of B2B Edition Settings in the Help Center for more information.

The mutation also passes the customer_id and channel_id of the current session in order to generate a Company user account for the customer and set the corresponding storefront as the user’s origin channel.

Tokens

To authenticate calls to the GraphQL Storefront API, your application can generate a bearer token. This can be done by using either the Create a storefront token or the Create a customer impersonation token REST endpoint. On a Stencil storefront, you can also access a token directly from the page context.

For more information, see Storefront tokens in the Authenticating requests to the GraphQL Storefront API article and Dynamic tokens in the Strategies and Example Requests article.

Registering a Company Account

Required Fields

For successful Company registration, the request must include the following information:

  • Company name (name)
  • Primary Company email address (email)
  • Primary Company phone number (phone)
  • Company physical address object (address) with the following fields:
    • firstName
    • lastName
    • address1
    • city
    • countryCode
    • stateOrProvince if required by the country (must be the full name and not the two-letter code)

You may also need to include extra fields for Company accounts, Company users, and addresses depending on how their configuration. See Considerations for more information.

Example Mutation

Request
Response
Example mutation: Register a Company account
mutation {
company {
registerCompany(
input: {
name: "Great Buys Incorporated",
email: "info@greatbuysinc.com",
phone: "5121234567",
fileList:[
{fileId: "uniquefile.pdf"}
],
address: {
firstName: "Marie",
lastName: "Curie",
address1: "123 Main Street",
city: "Austin",
countryCode: "US",
stateOrProvince: "Texas",
phone: "5121234567",
postalCode: "78704"
# Address extra fields
extraFields: {
texts: [
{ name: "Text Field Name", text: "Text Value" }
],
multilineTexts: [
{ name: "Multiline Field Name", multilineText: "Multi-Line Text Value" }
],
multipleChoices: [
{ name: "Multiple Choice Field Name", fieldValue: "Choice Value" }
],
numbers: [
{ name: "Number Field Name", number: 1.0 }
]
}
},
# Company account extra fields
extraFields: {
texts: [
{ name: "Text Field Name", text: "Text Value" }
],
multilineTexts: [
{ name: "Multiline Field Name", multilineText: "Multi-Line Text Value" }
],
multipleChoices: [
{ name: "Multiple Choice Field Name", fieldValue: "Choice Value" }
],
numbers: [
{ name: "Number Field Name", number: 1.0 }
]
},
# Company user extra fields
companyUser: {
extraFields: {
texts: [
{ name: "Text Field Name", text: "Text Value" }
],
multilineTexts: [
{ name: "Multiline Field Name", multilineText: "Multi-Line Text Value" }
],
multipleChoices: [
{ name: "Multiple Choice Field Name", fieldValue: "Choice Value" }
],
numbers: [
{ name: "Number Field Name", number: 1.0 }
]
}
}
}
) {
entityId
status
errors {
... on ValidationError {
message
path
}
}
}
}
}

Considerations

While using the registerCompany mutation, take note of the following information:

Required Extra Fields

When configuring extra fields in your B2B Edition control panel for Company accounts, users, and addresses, you can mark individual fields as required. Any required extra fields must be captured in the request. To learn more about extra fields, see the “Extra Fields Settings” section of B2B Edition Settings in the Help Center.

Company Files

The fileList array contains fileId strings comprised of each file’s name and extension. It is optional and only used if the customer has uploaded a file during registration. For more information on Company file attachments, such as file size and type requirements, see the “Managing Attached Files” section of Companies in the Help Center.

Pending Company Accounts

After making a successful request, the newly-created Company is assigned the Pending status. In the Settings › General area of your B2B Edition control panel, you can further configure the Company registration experience by limiting product visibility and purchasing for pending Company users, or by automatically approving all applications. See the “General Settings” section of B2B Edition Settings in the Help Center for more information on Company management settings.

Resources

Documentation

  • GraphQL Storefront API Overview
  • Guide to API Accounts
  • Customers: Register a customer

API Reference

  • Create a storefront token
  • Create a customer impersonation token
  • REST Management API: Companies REST Storefront API: Companies

Tools

  • GraphQL Storefront API reference
  • GraphQL Storefront Playground

Community

  • Developer community