GraphQL Company Create not Supporting province in Shipping or Billing Address why?

Hi All

I am using the GraphQL API to create Companies. problem is that Our Region uses Provinces and Not states. If I manually create the Company Shipping and Billing in the UI and I query it via Graph QL I get a Province option.

But when creating I don’t ?

https://shopify.dev/docs/api/admin-graphql/2024-10/objects/Company#mutations

How do I use Province when craeting a Company via GraphQL. There is no Rest version for Company?

Tried with zoneCode but that is not allowing me.

mutation CreateUpdateCompany(
  $name: String!,
  $externalId: String!,
  $contactEmail: String!,
  $firstName: String!,
  $lastName: String!,
  $phone: String!,
  $address1: String!,
  $city: String!,
  $countryCode: CountryCode!,
  $zip: String!,
  $recipient: String!,
  $billingExternalId: String!,
  $shippingAddressee: String!,
  $shippingAddress1: String!,
  $shippingAddress2: String!,
  $shippingAttention: String!,
  $shippingCity: String!,
  $shippingProvince: String!,
  $shippingZip: String!,
  $shippingPhone: String!,
  $shippingCountryCode: CountryCode!
) {
  companyCreate(
    input: {
      company: {
        name: $name,
        externalId: $externalId
      },
      companyContact: {
        email: $contactEmail,
        firstName: $firstName,
        lastName: $lastName,
        phone: $phone
      },
      companyLocation: {
        billingSameAsShipping: false,
        externalId: $billingExternalId,
        billingAddress: {
          address1: $address1,
          city: $city,
          countryCode: $countryCode,
          firstName: $firstName,
          lastName: $lastName,
          phone: $phone,
          recipient: $recipient,
          zip: $zip,
          address2: ""
        },
        buyerExperienceConfiguration: {
          editableShippingAddress: false
        },
        shippingAddress: {
          address1: $shippingAddress1,
          address2: $shippingAddress2,
          city: $shippingCity,
          zoneCode: $shippingProvince,
          countryCode: $shippingCountryCode,
          phone: $shippingPhone,
          firstName: $shippingAddressee,
          zip: $shippingZip,
          recipient: $shippingAttention
        }
      }
    }
  ) {
    company {
      id
      externalId
    }
  }
}

my Vars

{
  "name": "Test Company",
  "externalId": "3363",
  "contactEmail": "testbuyer@testcompany.co.za",
  "firstName": "Testname",
  "lastName": "LastnameTest",
  "phone": "016 123 4567",
  "address1": "20 Fake Street",
  "city": "Vereeniging",
  "countryCode": "ZA",
  "zip": "1930",
  "recipient": "Buyer",
  "billingExternalId": "3363",
  "shippingAddressee": "Test Receiver",
  "shippingAddress1": "20 Fake Street",
  "shippingAddress2": "",
  "shippingAttention": "",
  "shippingCity": "Vereeniging",
  "shippingProvince": "Gauteng",
  "shippingZip": "1930",
  "shippingPhone": "",
  "shippingCountryCode": "ZA"
}

Also Changing the

zoneCode: $shippingState,

to

province: $shippingState,

obviously doesn’t work because it has no valid endpoint for that

Any assistance would be great!

Thank you

I think you might need to use the province code instead of the province name. Shopify checkout represents the provinces with codes, for example, Guateng is represented with code “GP”. The REST API for getting province code is here: https://shopify.dev/docs/api/admin-rest/2024-01/resources/province#get-countries-country-id-provinces

Thank for responding. I actually did try that. GP but still doesn’t work if I use it in the ZoneCode

I also managed to add this to my query

userErrors {  
      field
      message

It returned another error I had to resolve. Then I tried you answer again. Working now. Thank you