How to create a draft order for a specific company using APIs and its company ID?

Topic summary

Creating a draft order for a B2B company requires companyLocationId and companyContactId, but only the Company ID is available. The goal is to retrieve those IDs via APIs to proceed with draft order creation.

Latest guidance: Use the Admin GraphQL company object to fetch contacts and locations tied to the company. This requires the read_customers scope and testing on a Shopify Plus shop.

Query approach: Either query multiple companies and read their contacts/locations or query a single company by its Shopify GID (global identifier). Example fields include company id, name, contacts { id }, and locations { id }.

Action items:

  • Ensure the app has read_customers permission and the shop is Plus.
  • Query company by its GID and retrieve contacts.id and locations.id.
  • Use those IDs to create the draft order for the purchasing entity.

Notes: A GraphQL query example is central to understanding the solution. Screenshots are present but not essential.

Status: Guidance provided; no confirmation of resolution from the original poster, so the thread remains open.

Summarized with AI on January 24. AI used: gpt-5.

We’re struggling to create a draft order associated with a company using APIs and a company ID.

We found this documentation but we’re struggling to retrieve the companyLocationId and companyContactId information. The only information we have is the Company ID.

How could we create draft orders for our testing company from API using only its Company ID?

Hey @Thibaut-M - thanks for getting in touch. You should be able to pull this information through the company object in GraphQL directly, provided your app/integration has the read_customers scope and is being tested on a Plus Shop. Here’s a quick example if you wanted to pull multiple companies and the relevant contact/location info:

{
companies (first:10) {
edges {
node {
id
name
contacts (first:10) {
edges {
node {
id
}
}
}
locations (first:10) {
edges {
node {
id
}
}
}
}
}
}
}

If you know the Shopify GID of the company you want to query, you would also be able to query the same fields, using the ID as an argument on the company object itself. Hope this helps!

Al | Shopify Developer Support

1 Like