# Update Redirect By Id

PATCH https://services.leadconnectorhq.com/funnels/lookup/redirect/{id}

The "Update Redirect By Id" API Allows updating an existing URL redirect in the system. Use this endpoint to modify a URL redirect with the specified ID using details 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 |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | Yes |  |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/funnels/lookup/redirect/{id}": {
      "patch": {
        "summary": "Update Redirect By Id",
        "operationId": "updateRedirectById",
        "description": "The \"Update Redirect By Id\" API Allows updating an existing URL redirect in the system. Use this endpoint to modify a URL redirect with the specified ID using details provided in the request payload.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRedirectParams"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateRedirectResponseDTO"
                }
              }
            }
          },
          "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": {
      "UpdateRedirectParams": {
        "type": "object",
        "properties": {
          "target": {
            "type": "string",
            "example": "https://www.google.com"
          },
          "action": {
            "type": "string",
            "example": "URL",
            "enum": [
              "funnel",
              "website",
              "url",
              "all"
            ]
          },
          "locationId": {
            "type": "string",
            "example": "6p2RxpgtMKQwO3E6IUaT"
          }
        },
        "required": [
          "target",
          "action",
          "locationId"
        ],
        "title": "UpdateRedirectParams"
      },
      "UpdateRedirectResponseDTO": {
        "type": "object",
        "properties": {
          "data": {
            "description": "Data containing details of the updated 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": "UpdateRedirectResponseDTO"
      },
      "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 PATCH 'https://services.leadconnectorhq.com/funnels/lookup/redirect/<id>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "target": "https://www.google.com",
  "action": "URL",
  "locationId": "6p2RxpgtMKQwO3E6IUaT"
}'
```

**Node.js**

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

try {
  const response = await fetch('https://services.leadconnectorhq.com/funnels/lookup/redirect/<id>', 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/{id}"

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

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

response = requests.patch(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/<id>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PATCH',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "target": "https://www.google.com",
  "action": "URL",
  "locationId": "6p2RxpgtMKQwO3E6IUaT"
}',
]);

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

**Java**

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

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/funnels/lookup/redirect/<id>"
  payload := strings.NewReader(`{
  "target": "https://www.google.com",
  "action": "URL",
  "locationId": "6p2RxpgtMKQwO3E6IUaT"
}`)
  req, _ := http.NewRequest("PATCH", 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/<id>")

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

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

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

**PowerShell**

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

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

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