# Create a redirect

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

## `POST /redirects`

**Create a redirect**

Creates a new URL redirect. Provide `sourcePath`, `targetUrl`,
`statusCode` (301, 302, 307, 308), and optional `isRegex` flag
for pattern matching.

Required permissions: `redirects.create`

### Request Body

Content-Type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sourcePath` | string | Yes | Required. 1-2048 characters |
| `targetPath` | string | Yes | Required. 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 |
| --- | --- |
| `201` | Successful response |
| `401` | Unauthorized — invalid or missing API token |
| `403` | Forbidden — insufficient permissions |
| `422` | Validation error |


### Examples

```bash
curl -X POST https://api.lynkow.com/v1/redirects \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "sourcePath": "/old-page",
    "targetUrl": "/new-page",
    "statusCode": 301,
    "preserveQueryString": true
  }'
```

### Response Example

```json
{
  "data": {
    "id": 25,
    "sourcePath": "/old-page",
    "targetUrl": "/new-page",
    "statusCode": 301,
    "isRegex": false,
    "isActive": true,
    "preserveQueryString": true,
    "hitCount": 0,
    "lastHitAt": null,
    "createdAt": "2025-04-06T11:45:00.000Z"
  }
}
```

---