---
updatedAt: 2025-11-15T02:17:20.000Z
agentTools:
  projectIndex: https://developers.rebrandly.com/llms.txt
---

# Updating a script

Scripts can be updated via a `POST` method to `https://api.rebrandly.com/v1/scripts/:id`, where `:id` is the unique identifier (id) of the script, which accepts a JSON object describing the [Script](https://developers.rebrandly.com/docs/retargeting-scripts).

> 🚧 Check compatibility first
>
> Double check whether your API key or OAuth token is enabled to use the Scripts feature.\
> For every account, you can check for features and limits with [a preliminary API call](https://developers.rebrandly.com/docs/account-model).

## PATH Parameters

| Path parameter | Description                                        |
| :------------- | :------------------------------------------------- |
| id             | Unique identifier of the script you want to update |

## Script Parameters

The table below shows the parameters you should specify when updating a script.\
If you do not want to modify some parameters, you can simply leave them unchanged, i.e. pass their values as you originally received them.

<table>
<thead>
<tr>
  <th>Tag property</th>
  <th>Type</th>
  <th>Constraints</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td><p>name</p></td>
  <td><p>string</p></td>
  <td><p><strong>required</strong><br/>UTF8<br/>Min 3 chars<br/>Max 255 chars</p></td>
  <td><p>New name you want to assign to the script</p></td>
</tr>
<tr>
  <td><p>value</p></td>
  <td><p>string</p></td>
  <td><p><strong>required</strong><br/>Valid javascript code</p></td>
  <td><p>Javascript snippet including opening and closing \<script> HTML tags</p></td>
</tr>
</tbody>
</table>

## Updating an existing script

```text cURL
$ curl 'https://api.rebrandly.com/v1/scripts/gewa4cc5b6ee45d6gkj65b06ac2d1hww' \
-X POST \
-H 'apikey: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d \
'{
  "name": "NewAlert",
  "value": "<script>alert('test');</script>"
}'

HTTP/1.1 200 OK
```

## JSON response (updated script)

```text JSON
{
  "id": "gewa4cc5b6ee45d6gkj65b06ac2d1hww",
  "name": "NewAlert",
  "color": "<script>alert('test');</script>"
}
```

## Handling errors

<table>
<thead>
<tr>
  <th>HTTP status</th>
  <th>Error type</th>
  <th>Description</th>
</tr>
</thead>
<tbody>
<tr>
  <td><p>403</p></td>
  <td><p><a href="doc:validation-errors">403 - Invalid format</a></p></td>
  <td><p>Invalid Link object. Double check value for <code>property</code> field. Details about validation failure in <code>message</code> field</p></td>
</tr>
<tr>
  <td><p>404</p></td>
  <td><p><a href="doc:404-not-found-errors">404 - Not found</a><br/>with <code>property</code> value &quot;id&quot;</p></td>
  <td><p>Given <code>id</code> does not correspond to any existing script</p></td>
</tr>
</tbody>
</table>