# locationAdd - admin-graphql - MUTATION
Version: 2025-01

## Description
Adds a new location.

### Access Scopes
`write_locations` access scope.


## Arguments
* [input](/docs/api/admin-graphql/2025-01/input-objects/LocationAddInput): LocationAddInput! - The properties of the location to add.


## Returns
* [location](/docs/api/admin-graphql/2025-01/objects/Location): Location The location that was added.
* [userErrors](/docs/api/admin-graphql/2025-01/objects/LocationAddUserError): LocationAddUserError! The list of errors that occurred from executing the mutation.


## Examples
### Add a location and return the location 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\": \"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 } } }\"\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n  data: `mutation {\n    locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n      location {\n        id\n        name\n        address {\n          address1\n          provinceCode\n          countryCode\n          zip\n        }\n        fulfillsOnlineOrders\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  mutation {\n    locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n      location {\n        id\n        name\n        address {\n          address1\n          provinceCode\n          countryCode\n          zip\n        }\n        fulfillsOnlineOrders\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  mutation {\n    locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n      location {\n        id\n        name\n        address {\n          address1\n          provinceCode\n          countryCode\n          zip\n        }\n        fulfillsOnlineOrders\n      }\n    }\n  }`,\n);\n\nconst data = await response.json();\n"
Graphql query: "mutation {\n  locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n    location {\n      id\n      name\n      address {\n        address1\n        provinceCode\n        countryCode\n        zip\n      }\n      fulfillsOnlineOrders\n    }\n  }\n}"
#### Graphql Input
null
#### Graphql Response
{
  "data": {
    "locationAdd": {
      "location": {
        "id": "gid://shopify/Location/1072404546",
        "name": "New York Warehouses",
        "address": {
          "address1": "101 Liberty Street",
          "provinceCode": "NY",
          "countryCode": "US",
          "zip": "10006"
        },
        "fulfillsOnlineOrders": true
      }
    }
  }
}

### Create a new metafield on a new location
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\": \"mutation createLocationMetafields($input: LocationAddInput!) { locationAdd(input: $input) { location { id metafields(first: 3) { edges { node { id namespace key value } } } } userErrors { message field } } }\",\n \"variables\": {\n    \"input\": {\n      \"metafields\": [\n        {\n          \"namespace\": \"my_field\",\n          \"key\": \"delivery_type\",\n          \"type\": \"single_line_text_field\",\n          \"value\": \"local\"\n        }\n      ],\n      \"name\": \"Warehouse\",\n      \"address\": {\n        \"countryCode\": \"CA\"\n      }\n    }\n  }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n  data: {\n    \"query\": `mutation createLocationMetafields($input: LocationAddInput!) {\n      locationAdd(input: $input) {\n        location {\n          id\n          metafields(first: 3) {\n            edges {\n              node {\n                id\n                namespace\n                key\n                value\n              }\n            }\n          }\n        }\n        userErrors {\n          message\n          field\n        }\n      }\n    }`,\n    \"variables\": {\n      \"input\": {\n        \"metafields\": [\n          {\n            \"namespace\": \"my_field\",\n            \"key\": \"delivery_type\",\n            \"type\": \"single_line_text_field\",\n            \"value\": \"local\"\n          }\n        ],\n        \"name\": \"Warehouse\",\n        \"address\": {\n          \"countryCode\": \"CA\"\n        }\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  mutation createLocationMetafields($input: LocationAddInput!) {\n    locationAdd(input: $input) {\n      location {\n        id\n        metafields(first: 3) {\n          edges {\n            node {\n              id\n              namespace\n              key\n              value\n            }\n          }\n        }\n      }\n      userErrors {\n        message\n        field\n      }\n    }\n  }\nQUERY\n\nvariables = {\n  \"input\": {\n    \"metafields\": [{\"namespace\"=>\"my_field\", \"key\"=>\"delivery_type\", \"type\"=>\"single_line_text_field\", \"value\"=>\"local\"}],\n    \"name\": \"Warehouse\",\n    \"address\": {\n      \"countryCode\": \"CA\"\n    }\n  }\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  mutation createLocationMetafields($input: LocationAddInput!) {\n    locationAdd(input: $input) {\n      location {\n        id\n        metafields(first: 3) {\n          edges {\n            node {\n              id\n              namespace\n              key\n              value\n            }\n          }\n        }\n      }\n      userErrors {\n        message\n        field\n      }\n    }\n  }`,\n  {\n    variables: {\n      \"input\": {\n        \"metafields\": [\n          {\n            \"namespace\": \"my_field\",\n            \"key\": \"delivery_type\",\n            \"type\": \"single_line_text_field\",\n            \"value\": \"local\"\n          }\n        ],\n        \"name\": \"Warehouse\",\n        \"address\": {\n          \"countryCode\": \"CA\"\n        }\n      }\n    },\n  },\n);\n\nconst data = await response.json();\n"
Graphql query: "mutation createLocationMetafields($input: LocationAddInput!) {\n  locationAdd(input: $input) {\n    location {\n      id\n      metafields(first: 3) {\n        edges {\n          node {\n            id\n            namespace\n            key\n            value\n          }\n        }\n      }\n    }\n    userErrors {\n      message\n      field\n    }\n  }\n}"
#### Graphql Input
{
  "input": {
    "metafields": [
      {
        "namespace": "my_field",
        "key": "delivery_type",
        "type": "single_line_text_field",
        "value": "local"
      }
    ],
    "name": "Warehouse",
    "address": {
      "countryCode": "CA"
    }
  }
}
#### Graphql Response
{
  "data": {
    "locationAdd": {
      "location": {
        "id": "gid://shopify/Location/1072404547",
        "metafields": {
          "edges": [
            {
              "node": {
                "id": "gid://shopify/Metafield/1069229305",
                "namespace": "my_field",
                "key": "delivery_type",
                "value": "local"
              }
            }
          ]
        }
      },
      "userErrors": []
    }
  }
}