# Creating a redirect

To create a redirect using the GraphQL API, you will need the following:

* [ ] The site id. Sent as the `input.siteId` variable.
* [ ] A valid [access token](https://docs.parameter1.com/basecms-graphql/introduction#logging-in). Include this as a `Bearer` authorization header.
* [ ] The old and new URLs. Sent as the `input.payload` variable.

The example below creates a redirect.

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

```
mutation CreateWebsiteRedirect($input: CreateWebsiteRedirectMutationInput!) {
  createWebsiteRedirect(input: $input) {
    id
    from
    to
    code
  }
}
```

{% endtab %}

{% tab title="Variables" %}

```
{
  "input": {
    "siteId": "5d76bfaf665fc42e008b4569",
    "payload": {
      "from": "/old-url",
      "to": "/new-url"
    }
  }
}
```

{% endtab %}

{% tab title="Headers" %}

```
X-Tenant-Key: my_tenant_key
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

```

{% endtab %}

{% tab title="Response" %}

```
{
  "data": {
    "createWebsiteRedirect": {
      "id": "5bd8737fee1fdb00d6e83196",
      "from": "/old-url",
      "to": "/new-url",
      "code": 301
    }
  }
}
```

{% endtab %}
{% endtabs %}
