Get a company by its ID
Description
Retrieves a company by ID, returning the fields specified in the query.
Query
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-07/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 } } }"
}'
Remix
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 data = await response.json();
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
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
{
"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
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"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/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"
}
}'
Remix
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 data = await response.json();
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
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
{
"company": {
"industry": {
"value": "retail"
}
}
}
Get metafields attached to a company
Description
Get a page of metafields attached to a specific company.
Query
query CompanyMetafields($ownerId: ID!) {
company(id: $ownerId) {
metafields(first: 3) {
edges {
node {
namespace
key
value
}
}
}
}
}
Variables
{
"ownerId": "gid://shopify/Company/426793626"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/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"
}
}'
Remix
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 data = await response.json();
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
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
{
"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
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"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/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"
}
}'
Remix
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 data = await response.json();
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
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
{
"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"
}
}
}
]
}
}
}