--- title: company - GraphQL Admin description: Returns a `Company` resource by ID. api_version: 2025-10 api_name: admin type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/queries/company md: https://shopify.dev/docs/api/admin-graphql/latest/queries/company.md --- # company query Returns a `Company` resource by ID. ## Arguments * id [ID!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/ID) required The ID of the `Company` to return. *** ## Possible returns * Company [Company](https://shopify.dev/docs/api/admin-graphql/latest/objects/Company) Represents information about a company which is also a customer of the shop. *** ## Examples * ### Get a company by its ID #### Description Retrieves a company by ID, returning the fields specified in the query. #### Query ```graphql query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { company(id: \"gid://shopify/Company/426793626\") { id name note externalId totalSpent { amount currencyCode } } }" }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } }`, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } }`, }); ``` #### Response ```json { "company": { "id": "gid://shopify/Company/426793626", "name": "Fancy Pants Inc.", "note": "test notes", "externalId": "external_id1", "totalSpent": { "amount": "120.0", "currencyCode": "USD" } } } ``` * ### Get a metafield attached to a company #### Description Get the metafield value identified by \`my\_fields.industry\` on a specific company. #### Query ```graphql query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) { company(id: $ownerId) { industry: metafield(namespace: $namespace, key: $key) { value } } } ``` #### Variables ```json { "namespace": "my_fields", "key": "industry", "ownerId": "gid://shopify/Company/426793626" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) { company(id: $ownerId) { industry: metafield(namespace: $namespace, key: $key) { value } } }", "variables": { "namespace": "my_fields", "key": "industry", "ownerId": "gid://shopify/Company/426793626" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) { company(id: $ownerId) { industry: metafield(namespace: $namespace, key: $key) { value } } }`, { variables: { "namespace": "my_fields", "key": "industry", "ownerId": "gid://shopify/Company/426793626" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) { company(id: $ownerId) { industry: metafield(namespace: $namespace, key: $key) { value } } } QUERY variables = { "namespace": "my_fields", "key": "industry", "ownerId": "gid://shopify/Company/426793626" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) { company(id: $ownerId) { industry: metafield(namespace: $namespace, key: $key) { value } } }`, "variables": { "namespace": "my_fields", "key": "industry", "ownerId": "gid://shopify/Company/426793626" }, }, }); ``` #### Response ```json { "company": { "industry": { "value": "retail" } } } ``` * ### Get metafields attached to a company #### Description Get a page of metafields attached to a specific company. #### Query ```graphql query CompanyMetafields($ownerId: ID!) { company(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } } ``` #### Variables ```json { "ownerId": "gid://shopify/Company/426793626" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query CompanyMetafields($ownerId: ID!) { company(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }", "variables": { "ownerId": "gid://shopify/Company/426793626" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query CompanyMetafields($ownerId: ID!) { company(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }`, { variables: { "ownerId": "gid://shopify/Company/426793626" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query CompanyMetafields($ownerId: ID!) { company(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } } QUERY variables = { "ownerId": "gid://shopify/Company/426793626" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query CompanyMetafields($ownerId: ID!) { company(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }`, "variables": { "ownerId": "gid://shopify/Company/426793626" }, }, }); ``` #### Response ```json { "company": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "industry", "value": "retail" } } ] } } } ``` * ### Get pinned metafield definitions associated with a company #### Description Get names and types of the first page of pinned metafield definitions associated with a company. #### Query ```graphql query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { company(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } } ``` #### Variables ```json { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Company/426793626", "first": 10, "sortKey": "PINNED_POSITION" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { company(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }", "variables": { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Company/426793626", "first": 10, "sortKey": "PINNED_POSITION" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { company(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }`, { variables: { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Company/426793626", "first": 10, "sortKey": "PINNED_POSITION" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { company(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } } QUERY variables = { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Company/426793626", "first": 10, "sortKey": "PINNED_POSITION" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { company(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }`, "variables": { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Company/426793626", "first": 10, "sortKey": "PINNED_POSITION" }, }, }); ``` #### Response ```json { "company": { "metafieldDefinitions": { "edges": [ { "node": { "name": "Website", "namespace": "my_fields", "key": "website", "type": { "name": "single_line_text_field" } } }, { "node": { "name": "Industry", "namespace": "my_fields", "key": "industry", "type": { "name": "single_line_text_field" } } } ] } } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20%7B%0A%20%20company\(id%3A%20%22gid%3A%2F%2Fshopify%2FCompany%2F426793626%22\)%20%7B%0A%20%20%20%20id%0A%20%20%20%20name%0A%20%20%20%20note%0A%20%20%20%20externalId%0A%20%20%20%20totalSpent%20%7B%0A%20%20%20%20%20%20amount%0A%20%20%20%20%20%20currencyCode%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } }`, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { company(id: \"gid://shopify/Company/426793626\") { id name note externalId totalSpent { amount currencyCode } } }" }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } }`, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } }`, }); ``` ##### Ruby ``` session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query { company(id: "gid://shopify/Company/426793626") { id name note externalId totalSpent { amount currencyCode } } } QUERY response = client.query(query: query) ``` ## Response JSON ```json { "company": { "id": "gid://shopify/Company/426793626", "name": "Fancy Pants Inc.", "note": "test notes", "externalId": "external_id1", "totalSpent": { "amount": "120.0", "currencyCode": "USD" } } } ```