# company - admin-graphql - QUERY Version: 2025-01 ## Description Returns a `Company` object by ID. ### Access Scopes ## Arguments * [id](/docs/api/admin-graphql/2025-01/scalars/ID): ID! - The ID of the `Company` to return. ## Returns * [contactCount](/docs/api/admin-graphql/2025-01/scalars/Int): Int! The number of contacts that belong to the company. * [contactsCount](/docs/api/admin-graphql/2025-01/objects/Count): Count The number of contacts that belong to the company. * [createdAt](/docs/api/admin-graphql/2025-01/scalars/DateTime): DateTime! The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was created in Shopify. * [customerSince](/docs/api/admin-graphql/2025-01/scalars/DateTime): DateTime! The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company became the customer. * [defaultCursor](/docs/api/admin-graphql/2025-01/scalars/String): String! A default [cursor](https://shopify.dev/api/usage/pagination-graphql) that returns the single next record, sorted ascending by ID. * [defaultRole](/docs/api/admin-graphql/2025-01/objects/CompanyContactRole): CompanyContactRole The role proposed by default for a contact at the company. * [externalId](/docs/api/admin-graphql/2025-01/scalars/String): String A unique externally-supplied ID for the company. * [hasTimelineComment](/docs/api/admin-graphql/2025-01/scalars/Boolean): Boolean! Whether the merchant added a timeline comment to the company. * [id](/docs/api/admin-graphql/2025-01/scalars/ID): ID! A globally-unique ID. * [lifetimeDuration](/docs/api/admin-graphql/2025-01/scalars/String): String! The lifetime duration of the company, since it became a customer of the shop. Examples: `2 days`, `3 months`, `1 year`. * [locationsCount](/docs/api/admin-graphql/2025-01/objects/Count): Count The number of locations that belong to the company. * [mainContact](/docs/api/admin-graphql/2025-01/objects/CompanyContact): CompanyContact The main contact for the company. * [metafield](/docs/api/admin-graphql/2025-01/objects/Metafield): Metafield A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information. * [name](/docs/api/admin-graphql/2025-01/scalars/String): String! The name of the company. * [note](/docs/api/admin-graphql/2025-01/scalars/String): String A note about the company. * [ordersCount](/docs/api/admin-graphql/2025-01/objects/Count): Count The total number of orders placed for this company, across all its locations. * [totalSpent](/docs/api/admin-graphql/2025-01/objects/MoneyV2): MoneyV2! The total amount spent by this company, across all its locations. * [updatedAt](/docs/api/admin-graphql/2025-01/scalars/DateTime): DateTime! The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was last modified. ## Examples ### Get a company by its ID Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { company(id: \\\"gid://shopify/Company/426793626\\\") { id name note externalId totalSpent { amount currencyCode } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "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 Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) { company(id: $ownerId) { industry: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"industry\",\n \"ownerId\": \"gid://shopify/Company/426793626\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"industry\",\n \"ownerId\": \"gid://shopify/Company/426793626\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"industry\",\n \"ownerId\": \"gid://shopify/Company/426793626\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"industry\",\n \"ownerId\": \"gid://shopify/Company/426793626\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}" #### Graphql Input { "namespace": "my_fields", "key": "industry", "ownerId": "gid://shopify/Company/426793626" } #### Graphql Response { "data": { "company": { "industry": { "value": "retail" } } } } ### Get metafields attached to a company Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CompanyMetafields($ownerId: ID!) { company(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/Company/426793626\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"ownerId\": \"gid://shopify/Company/426793626\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"ownerId\": \"gid://shopify/Company/426793626\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"ownerId\": \"gid://shopify/Company/426793626\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n}" #### Graphql Input { "ownerId": "gid://shopify/Company/426793626" } #### Graphql Response { "data": { "company": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "industry", "value": "retail" } } ] } } } } ### Get pinned metafield definitions associated with a company Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } } } } }\",\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Company/426793626\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Company/426793626\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Company/426793626\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Company/426793626\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n}" #### Graphql Input { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Company/426793626", "first": 10, "sortKey": "PINNED_POSITION" } #### Graphql Response { "data": { "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" } } } ] } } } }