# Update affiliate link

{% hint style="warning" %}
Keep in mind that when you change a link's token, the previous token will immediately stop tracking visits. If this is a concern, considering [creating a new affiliate link](/rest-api/affiliate-links/create.md) rather than updating existing links.
{% endhint %}

## Request

| Method | URL                                                   |
| ------ | ----------------------------------------------------- |
| `PUT`  | `https://api.getrewardful.com/v1/affiliate_links/:id` |

### Parameters

| Parameter | Required? | Description                            |
| --------- | --------- | -------------------------------------- |
| `token`   | Yes       | The new token to be used for the link. |

### Example

```bash
curl --request PUT \
  --url https://api.getrewardful.com/v1/affiliate_links/d0ed8392-8880-4f39-8715-60230f9eceab \
  -u YOUR_API_SECRET: \
  -d token=darth-vader
```

## Response

{% tabs %}
{% tab title="Success" %}

<table><thead><tr><th width="279.73584905660374">Response code</th><th>Body</th></tr></thead><tbody><tr><td><code>200</code></td><td>An <a href="/pages/5UWf9jRSW3ZgQfaYbAf4">affiliate link object</a> (JSON)</td></tr></tbody></table>
{% endtab %}

{% tab title="Failures" %}

### Not found

| Response code | Body                              |
| ------------- | --------------------------------- |
| `404`         | JSON object describing the error. |

```javascript
{  "error": "Affiliate link not found: " }
```

### Authentication failure

| Response code | Body                                       |
| ------------- | ------------------------------------------ |
| `401`         | Description of the authentication failure. |

```javascript
{  "error": "Invalid API Secret." }
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.rewardful.com/rest-api/affiliate-links/update.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
