> ## 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 selected fields

> Change selected fields and clear values without resending the location.

Requires `location:update` and project API access. Send a JSON object containing only the fields you want to change. Omitted inputs and attachments keep their saved values; generated addresses can refresh when address components change, as described below.
Returns `200` and the [updated location](/api/locations/get#response-format).

<Note>Run write requests with the cURL, JavaScript or PHP examples. They change real location data; use a location you created for testing.</Note>

<ParamField path="project_id" type="string" required>The public project ID.</ParamField>
<ParamField path="location_id" type="string" required>The public location ID belonging to the project.</ParamField>
<ParamField body="phone" type="string | null">Change the phone, or send null to clear it.</ParamField>
<ParamField body="name" type="string">If supplied, a nonempty string of at most 255 characters.</ParamField>
<ParamField body="city" type="string">If supplied, a nonempty string of at most 255 characters.</ParamField>
<ParamField body="visible" type="boolean">Show or hide the location. `false` is valid; null is not.</ParamField>
<ParamField body="hours" type="object | null">Update selected weekdays, send `{}` to preserve hours, or null to remove the schedule.</ParamField>
<ParamField body="fields" type="object | null">Merge named custom fields. Null values remove attachments.</ParamField>
<ParamField body="callsToAction" type="object | null">Merge named calls to action. Null values remove attachments.</ParamField>
<ParamField body="filters" type="array | string | null">Replace the filter list; `[]` or null clears it.</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 PATCH '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 '{"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: "PATCH",
    headers: {
      Authorization: `Bearer ${token}`,
      Accept: "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "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 => "PATCH",
      CURLOPT_HTTPHEADER => [
          "Authorization: Bearer $token",
          "Accept: application/json",
          "Content-Type: application/json",
      ],
      CURLOPT_POSTFIELDS => json_encode([
          '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>

You do not need to resend the name, city, hours, filters, or other saved information. See [Create a location](/api/locations/create#additional-fields) for public field names.

## Test an update

1. [Read your test location](/api/locations/get) with `includeHours=1` and record its phone, name, city and hours.
2. Replace `PROJECT_ID`, `LOCATION_ID` and `YOUR_TOKEN` in the cURL example. JavaScript and PHP use `STOREROCKET_TOKEN` from the [quickstart](/api/quickstart).
3. Run the example. Expect `200` with `data.phone` set to `555-0101`.
4. Read the same location again with `includeHours=1`. The phone has changed; the omitted name, city and hours are unchanged.

For clearing tests, replace the JSON body with an example below, run the same PATCH request, and read the location again with `includeHours=1` or the matching include flag. Expect the result shown in each table. Restore any values you want to keep after testing.

## Opening hours

Update just Monday without changing other days:

```json theme={null}
{"hours":{"mon":"09:00-17:00"}}
```

Short or full weekday names are accepted. Values are strings such as `09:00-17:00`, `closed`, or null. If a schedule does not yet exist, omitted days stay unset.

| Input | Result |
| - | - |
| Omit `hours` | Keep the entire schedule |
| `"hours": {}` | Keep the entire schedule |
| `"hours": null` | Remove the schedule from this location |
| `"hours": {"mon": null}` | Clear Monday only |
| `"hours": {"mon": "closed"}` | Mark Monday as closed |

Hours are an object, not an array. Avoid conflicting short and full names for the same day. Removing a schedule from a location does not delete a reusable hours template.

## Custom fields and calls to action

```json theme={null}
{
  "fields":{"Manager":"Sam","Old label":null},
  "callsToAction":{"Book":"https://example.com/book"}
}
```

Supplied keys are added or updated; omitted keys keep their attachments. A key with a null value removes that attachment. `{}` does nothing. Null for the whole object clears every attachment of that kind from this location.

## Filters, markers, types, and cover

| Input | Result |
| - | - |
| Omit `filters` | Keep the filter list |
| Supply `filters` | Replace the list |
| `"filters": []` or null | Clear the list |
| Omit `marker_id` or `location_type` | Keep the selection |
| `"marker_id": null` or `"location_type": null` | Restore the corresponding project default |
| `"cover": null` | Clear the cover association and external cover URL |

A supplied marker ID, location-type name, or stored cover image must belong to this project. An invalid selection returns `422` and saves nothing.

## Other fields and generated values

Send null to clear nullable text fields, including phone, email, website, and social profiles. `name`, `city`, and `visible` cannot be null. Zero coordinates and false visibility are valid.

Use [public field names](/api/locations/create#additional-fields). Internal fields such as `project_id` and `location_type_id` are ignored. `socials` is a response field; send the individual profile fields.

Changing address components refreshes an automatically generated `address` or `display_address`. A custom combined address is preserved when omitted. Send `"address": null` to regenerate it from saved components; clearing a slug can generate one from the location.

PATCH touching address/coordinate fields queues geocoding only if a coordinate is missing. Other PATCH requests do not trigger geocoding. The immediate response may precede a queued geocode result.

## Atomic validation

Invalid input returns `422` with `message` and `errors`; no portion of that update is saved. See [errors](/api/errors).
This endpoint accepts `application/json`; its object/array/null behavior is the StoreRocket contract described here.


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