> ## Documentation Index
> Fetch the complete documentation index at: https://docs.storerocket.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update with PUT

> The existing update contract, retained for supported integrations.

Requires `location:update` and project API access. `name` and `city` are required on each request; a street address is optional.
For a change that should preserve all omitted choices, use [PATCH](/api/locations/update).

<Note>Run write requests with the cURL, JavaScript or PHP examples. They change real location data. Use [PATCH](/api/locations/update) for new integrations that update selected fields.</Note>

<ParamField path="project_id" type="string" required>The public project ID.</ParamField>
<ParamField path="location_id" type="string" required>The public location ID.</ParamField>
<ParamField body="name" type="string" required>Location name.</ParamField>
<ParamField body="city" type="string" required>Location city.</ParamField>
<ParamField body="phone" type="string">Phone number.</ParamField>

JavaScript examples run in Node.js 22 or later; PHP examples require PHP 8.2 or later with cURL. Both read `STOREROCKET_TOKEN` from your environment. See the [quickstart](/api/quickstart) for setup.

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT 'https://storerocket.io/api/v2/projects/PROJECT_ID/locations/LOCATION_ID' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"name":"Downtown Store","city":"Seattle","phone":"555-0101"}'
  ```

  ```javascript JavaScript theme={null}
  const token = process.env.STOREROCKET_TOKEN;
  if (!token) throw new Error("Set STOREROCKET_TOKEN first.");
  const projectId = "PROJECT_ID";
  const locationId = "LOCATION_ID";

  const url = new URL(`https://storerocket.io/api/v2/projects/${encodeURIComponent(projectId)}/locations/${encodeURIComponent(locationId)}`);
  const response = await fetch(url, {
    method: "PUT",
    headers: {
      Authorization: `Bearer ${token}`,
      Accept: "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "name": "Downtown Store",
      "city": "Seattle",
      "phone": "555-0101"
    }),
    signal: AbortSignal.timeout(30_000),
  });

  const text = await response.text();
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
  console.log(JSON.parse(text));
  ```

  ```php PHP theme={null}
  <?php

  $token = getenv("STOREROCKET_TOKEN") ?: throw new RuntimeException("Set STOREROCKET_TOKEN first.");
  $projectId = "PROJECT_ID";
  $locationId = "LOCATION_ID";

  $url = 'https://storerocket.io/api/v2/projects/' . rawurlencode($projectId) . '/locations/' . rawurlencode($locationId);

  $curl = curl_init($url);
  curl_setopt_array($curl, [
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_HTTPHEADER => [
          "Authorization: Bearer $token",
          "Accept: application/json",
          "Content-Type: application/json",
      ],
      CURLOPT_POSTFIELDS => json_encode([
          'name' => 'Downtown Store',
          'city' => 'Seattle',
          'phone' => '555-0101',
      ], JSON_THROW_ON_ERROR),
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CONNECTTIMEOUT => 5,
      CURLOPT_TIMEOUT => 30,
  ]);

  $text = curl_exec($curl);
  $error = curl_error($curl);
  $status = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
  curl_close($curl);

  if ($text === false) {
      throw new RuntimeException("Request failed: $error");
  }
  if ($status < 200 || $status >= 300) {
      throw new RuntimeException("HTTP $status: $text");
  }
  $data = json_decode($text, false, 512, JSON_THROW_ON_ERROR);
  echo json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR), PHP_EOL;
  ```
</RequestExample>

Returns `200` and the [location resource](/api/locations/get#response-format). Field descriptions are on [Create a location](/api/locations/create).

## Existing PUT behavior

* Omitted scalar values generally remain saved; PUT does not have PATCH's preserve-all-omissions contract.
* Supplied `fields` and `callsToAction` objects replace their respective attachments. Their omitted keys are removed; an empty object clears those attachments.
* Supplied `filters` replaces the filter list; an empty list clears it. An omitted filter list is preserved.
* Omitted marker and location-type selections use the project's defaults.
* Omitted hours, null hours, and `{}` leave any existing hours unchanged. A nonempty hours object must include all seven days; it replaces the saved week.
* Use PATCH for `hours:null` clearing or partial weekdays.
* PUT can geocode synchronously when either coordinate is missing or zero; it retains the older behavior described under [addresses and coordinates](/api/errors#addresses-and-coordinates).

Errors: `401`, `403`, `404`, `422`, `429`. Invalid input saves no part of the location update. See [errors](/api/errors).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.