Anchor to locationAddlocation
locationAdd
mutation
Requires access scope.
Adds a new location.
Anchor to Arguments
Arguments
- Anchor to inputinput•Location
Add requiredInput! The properties of the location to add.
Was this section helpful?
Anchor to LocationAddPayload returnsLocationAddPayload returns
- Anchor to locationlocation•
The location that was added.
- Anchor to userErrorsuser•
Errors [LocationAdd non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Add a location and return the location ID
- Create a new metafield on a new location
- locationAdd reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation {
locationAdd(input: {name: "New York Warehouses", address: {address1: "101 Liberty Street", city: "New York", provinceCode: "NY", countryCode: US, zip: "10006"}, fulfillsOnlineOrders: true}) {
location {
id
name
address {
address1
provinceCode
countryCode
zip
}
fulfillsOnlineOrders
}
}
}`,
);
const data = await response.json();
mutation {
locationAdd(input: {name: "New York Warehouses", address: {address1: "101 Liberty Street", city: "New York", provinceCode: "NY", countryCode: US, zip: "10006"}, fulfillsOnlineOrders: true}) {
location {
id
name
address {
address1
provinceCode
countryCode
zip
}
fulfillsOnlineOrders
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation { locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) { location { id name address { address1 provinceCode countryCode zip } fulfillsOnlineOrders } } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation {
locationAdd(input: {name: "New York Warehouses", address: {address1: "101 Liberty Street", city: "New York", provinceCode: "NY", countryCode: US, zip: "10006"}, fulfillsOnlineOrders: true}) {
location {
id
name
address {
address1
provinceCode
countryCode
zip
}
fulfillsOnlineOrders
}
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `mutation {
locationAdd(input: {name: "New York Warehouses", address: {address1: "101 Liberty Street", city: "New York", provinceCode: "NY", countryCode: US, zip: "10006"}, fulfillsOnlineOrders: true}) {
location {
id
name
address {
address1
provinceCode
countryCode
zip
}
fulfillsOnlineOrders
}
}
}`,
});
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
mutation {
locationAdd(input: {name: "New York Warehouses", address: {address1: "101 Liberty Street", city: "New York", provinceCode: "NY", countryCode: US, zip: "10006"}, fulfillsOnlineOrders: true}) {
location {
id
name
address {
address1
provinceCode
countryCode
zip
}
fulfillsOnlineOrders
}
}
}
QUERY
response = client.query(query: query)
Response
JSON{
"locationAdd": {
"location": {
"id": "gid://shopify/Location/1072404546",
"name": "New York Warehouses",
"address": {
"address1": "101 Liberty Street",
"provinceCode": "NY",
"countryCode": "US",
"zip": "10006"
},
"fulfillsOnlineOrders": true
}
}
}