---
title: "Creates a redirect from a path."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.sherpo.io/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Sherpo merchant API › site

`POST /v1/stores/{store}/redirects`

## Authentication

- `bearer`, http, header `Authorization`, scopes: `site:write`

## Path parameters

- `store` (`createRedirect.path.store`; string, required) — The store's id.

## Header parameters

- `Idempotency-Key` (`createRedirect.header.Idempotency-Key`; string, optional) — Repeats within 24 hours answer the first result; the same key with other arguments is a conflict.
  - minLength 1; maxLength 255; pattern `^[\x21-\x7E]+$`

## Request body

_Required._

- `from_path` (`createRedirect.from_path`; string, required)
  - minLength 1; maxLength 2000; pattern `^/[^\s?#]*$`
- `to_path` (`createRedirect.to_path`; string, required)
  - minLength 1; maxLength 2000; pattern `^(?:/[^\s\x00-\x1F\x7F-\x9F]*|https?://[^\s\x00-\x1F\x7F-\x9F]+)$`
- `status` (`createRedirect.status`; any of, optional)
  - any of: `number`, `number`, `number`, `number`
- `enabled` (`createRedirect.enabled`; boolean, optional) — Off keeps it but never resolves it.

## Example request

```json
{
  "from_path": "string",
  "to_path": "string",
  "status": 308,
  "enabled": true
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.sherpo.io/merchant/v1/stores/<store>/redirects' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "from_path": "string",
  "to_path": "string",
  "status": 308,
  "enabled": true
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/merchant/v1/stores/<store>/redirects';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({from_path: 'string', to_path: 'string', status: 308, enabled: true})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sherpo.io/merchant/v1/stores/<store>/redirects"

payload = {
    "from_path": "string",
    "to_path": "string",
    "status": 308,
    "enabled": True
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Creates a redirect from a path.

#### Example

```json
{
  "id": "string",
  "from_path": "string",
  "to_path": "string",
  "status": 0,
  "enabled": true,
  "live": true,
  "connection_ended_at": "string",
  "created_at": "string"
}
```

- `id` (`createRedirect.response.201.id`; string, required)
- `from_path` (`createRedirect.response.201.from_path`; string, required)
- `to_path` (`createRedirect.response.201.to_path`; string, required)
- `status` (`createRedirect.response.201.status`; number, required)
- `enabled` (`createRedirect.response.201.enabled`; boolean, required)
- `live` (`createRedirect.response.201.live`; boolean, required) — Resolved: enabled and within the redirects of its kind the plan applies.
- `connection_ended_at` (`createRedirect.response.201.connection_ended_at`; any of, required) — When it was turned off because the connection that set it up ended.
  - any of: `string`, `null`
- `created_at` (`createRedirect.response.201.created_at`; any of, required)
  - any of: `string`, `null`

### default

A problem; see https://api.sherpo.io/merchant/docs/errors.

#### Example

```json
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "context": {},
  "reached_core": true,
  "core_answer": "string"
}
```

- `type` (`createRedirect.response.default.type`; string, required)
  - format `uri`
- `title` (`createRedirect.response.default.title`; string, required)
- `status` (`createRedirect.response.default.status`; integer, required)
- `detail` (`createRedirect.response.default.detail`; string, required)
- `code` (`createRedirect.response.default.code`; string, optional)
- `context` (`createRedirect.response.default.context`; object, optional)
- `reached_core` (`createRedirect.response.default.reached_core`; boolean, optional)
- `core_answer` (`createRedirect.response.default.core_answer`; string, optional)


Source: https://docs.sherpo.io/merchant-api/reference/create-redirect/index.md
