# Update a redirect

**Publié le** : 2026-05-08
**Catégorie** : SEO & Analytics

## `PUT /redirects/:id`

**Update a redirect**

Updates a redirect's source path, target URL, status code, or options.

Required permissions: `redirects.update`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | Yes | Unique identifier |


### Request Body

Content-Type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sourcePath` | string | No | 1-2048 characters |
| `targetPath` | string | No | 1-2048 characters |
| `statusCode` | "301" \| "302" \| "307" \| "308" | No | One of: 301, 302, 307, 308 |
| `isRegex` | boolean | No | Boolean |
| `preserveQueryString` | boolean | No | Boolean |
| `isActive` | boolean | No | Boolean |
| `note` | string | No | Max 500 characters |


### Responses

| Status | Description |
| --- | --- |
| `200` | Successful response |
| `401` | Unauthorized — invalid or missing API token |
| `403` | Forbidden — insufficient permissions |
| `404` | Not found |
| `422` | Validation error |


### Examples

```bash
curl -X PUT https://api.lynkow.com/v1/redirects/1 \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "targetUrl": "/new-blog",
    "statusCode": 302
  }'
```

### Response Example

```json
{
  "data": {
    "id": 1,
    "sourcePath": "/old-blog",
    "targetUrl": "/new-blog",
    "statusCode": 302,
    "isRegex": false,
    "isActive": true,
    "preserveQueryString": true,
    "hitCount": 237,
    "lastHitAt": "2025-04-05T18:22:00.000Z",
    "createdAt": "2025-02-01T10:00:00.000Z",
    "updatedAt": "2025-04-06T12:00:00.000Z"
  }
}
```

---