# Create Redirect

POST https://services.leadconnectorhq.com/funnels/lookup/redirect

The "Create Redirect" API Allows adding a new url redirect to the system. Use this endpoint to create a url redirect with the specified details. Ensure that the required information is provided in the request payload.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `funnels/redirect.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/funnels/lookup/redirect": {
      "post": {
        "summary": "Create Redirect",
        "operationId": "createRedirect",
        "description": "The \"Create Redirect\" API Allows adding a new url redirect to the system. Use this endpoint to create a url redirect with the specified details. Ensure that the required information is provided in the request payload.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRedirectParams"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRedirectResponseDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "funnels/redirect.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "CreateRedirectParams": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string",
            "example": "6p2RxpgtMKQwO3E6IUaT"
          },
          "domain": {
            "type": "string",
            "example": "example.com"
          },
          "path": {
            "type": "string",
            "example": "/Hello"
          },
          "target": {
            "type": "string",
            "example": "https://www.google.com"
          },
          "action": {
            "type": "string",
            "example": "URL",
            "enum": [
              "funnel",
              "website",
              "url",
              "all"
            ]
          }
        },
        "required": [
          "locationId",
          "domain",
          "path",
          "target",
          "action"
        ],
        "title": "CreateRedirectParams"
      },
      "CreateRedirectResponseDTO": {
        "type": "object",
        "properties": {
          "data": {
            "description": "Data containing details of the created redirect",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "example": "6p2RxpgtMKQwO3E6IUaT",
                    "description": "Unique identifier of the redirect"
                  },
                  "locationId": {
                    "type": "string",
                    "example": "6p2RxpgtMKQwO3E6IUaT",
                    "description": "Identifier of the location associated with the redirect"
                  },
                  "domain": {
                    "type": "string",
                    "example": "www.example.com",
                    "description": "Domain where the redirect occurs"
                  },
                  "path": {
                    "type": "string",
                    "example": "/old-path",
                    "description": "Original path that will be redirected"
                  },
                  "pathLowercase": {
                    "type": "string",
                    "example": "/old-path",
                    "description": "Lowercase version of the original path"
                  },
                  "type": {
                    "type": "string",
                    "example": "Permanent",
                    "description": "Type of redirect (e.g., Permanent, Temporary)"
                  },
                  "target": {
                    "type": "string",
                    "example": "https://www.example.com/new-path",
                    "description": "Target URL to which the original path will be redirected"
                  },
                  "action": {
                    "type": "string",
                    "example": "url",
                    "description": "Action performed by the redirect"
                  }
                },
                "required": [
                  "id",
                  "locationId",
                  "domain",
                  "path",
                  "pathLowercase",
                  "type",
                  "target",
                  "action"
                ],
                "title": "RedirectResponseDTO"
              }
            ]
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateRedirectResponseDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/funnels/lookup/redirect' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "locationId": "6p2RxpgtMKQwO3E6IUaT",
  "domain": "example.com",
  "path": "/Hello",
  "target": "https://www.google.com",
  "action": "URL"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "locationId": "6p2RxpgtMKQwO3E6IUaT",
      "domain": "example.com",
      "path": "/Hello",
      "target": "https://www.google.com",
      "action": "URL"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/funnels/lookup/redirect', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/funnels/lookup/redirect"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "locationId": "6p2RxpgtMKQwO3E6IUaT",
    "domain": "example.com",
    "path": "/Hello",
    "target": "https://www.google.com",
    "action": "URL"
}

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

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/funnels/lookup/redirect',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "locationId": "6p2RxpgtMKQwO3E6IUaT",
  "domain": "example.com",
  "path": "/Hello",
  "target": "https://www.google.com",
  "action": "URL"
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/funnels/lookup/redirect")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"locationId\":\"6p2RxpgtMKQwO3E6IUaT\",\"domain\":\"example.com\",\"path\":\"/Hello\",\"target\":\"https://www.google.com\",\"action\":\"URL\"}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/funnels/lookup/redirect"
  payload := strings.NewReader(`{
  "locationId": "6p2RxpgtMKQwO3E6IUaT",
  "domain": "example.com",
  "path": "/Hello",
  "target": "https://www.google.com",
  "action": "URL"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/funnels/lookup/redirect")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "locationId": "6p2RxpgtMKQwO3E6IUaT",
  "domain": "example.com",
  "path": "/Hello",
  "target": "https://www.google.com",
  "action": "URL"
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "locationId": "6p2RxpgtMKQwO3E6IUaT",
  "domain": "example.com",
  "path": "/Hello",
  "target": "https://www.google.com",
  "action": "URL"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/funnels/lookup/redirect' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
