B2B - Company Mapping is not working when order or draft order is created from API

Hello,

We have a requirement where, when a draft order is created via the API, the corresponding company should be automatically mapped on the draft order page.

I have already created a customer and a company, and assigned a location to the customer. However, when the draft order is created through the API, the company is not mapped automatically (screenshot1). The company gets mapped only if I manually remove and re-add the same customer to the order (screenshot2).

Please refer to the screenshots below for reference.

Is there a way to automatically map the company to the draft order when it is created via the API?

Perhaps share the draftOrderCreate mutation you’re running. Are you passing purchasingEntity?

https://shopify.dev/docs/api/admin-graphql/latest/mutations/draftOrderCreate#arguments-input.fields.purchasingEntity

Currently, I am creating both Draft Orders and Orders using the REST API.

I asked you to share the mutation you’re running.

REST also is no longer supported and you should migrate to GraphQL.

Thanks, Luke. Sure. We have scheduled the migration to GraphQL for next month, so currently we don’t have this mutation available. However, once we implement GraphQL, we will pass the required values for purchasingEntity.

Thanks for the information.