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

# Update Link

> Update an existing dynamic link's configuration, name, and destination

## Request

<ParamField path="code" type="string" required>
  The unique code of the link to update
</ParamField>

<ParamField header="X-API-KEY" type="string" required>
  Your API key: `b2co_your_api_key`
</ParamField>

<ParamField body="name" type="string">
  Optional display name for the link to help with organization and
  identification.
</ParamField>

<ParamField body="payload" type="object" required>
  Updated link configuration object containing destination URL and platform-specific
  settings.
</ParamField>

<ParamField body="payload.link" type="string" required>
  The destination URL where users will be redirected when they click the dynamic
  link.
</ParamField>

<ParamField body="payload.iosAppId" type="string">
  ID of a saved iOS mobile app to use for this link. When provided, the link will use the saved app's configuration instead of manual iOS settings.
</ParamField>

<ParamField body="payload.androidAppId" type="string">
  ID of a saved Android mobile app to use for this link. When provided, the link will use the saved app's configuration instead of manual Android settings.
</ParamField>

<ParamField body="payload.android" type="object">
  Android-specific configuration for deep linking and app store fallbacks.
</ParamField>

<ParamField body="payload.android.package" type="string">
  Android app package name (e.g., com.yourapp.android).
</ParamField>

<ParamField body="payload.android.store_fallback" type="string">
  Play Store URL to redirect Android users without the app.
</ParamField>

<ParamField body="payload.android.min_version" type="string">
  Minimum app version required to handle the deep link.
</ParamField>

<ParamField body="payload.android.saveApp" type="boolean">
  Whether to save this Android configuration as a new reusable mobile app.
</ParamField>

<ParamField body="payload.android.appName" type="string">
  Name for the saved mobile app (required if saveApp is true).
</ParamField>

<ParamField body="payload.ios" type="object">
  iOS-specific configuration for deep linking and App Store fallbacks.
</ParamField>

<ParamField body="payload.ios.bundleId" type="string">
  iOS app bundle identifier (e.g., com.yourapp.ios).
</ParamField>

<ParamField body="payload.ios.app_store_fallback" type="string">
  App Store URL to redirect iOS users without the app.
</ParamField>

<ParamField body="payload.ios.app_store_id" type="string">
  App Store ID for the iOS app.
</ParamField>

<ParamField body="payload.ios.min_version" type="string">
  Minimum app version required to handle the deep link.
</ParamField>

<ParamField body="payload.ios.saveApp" type="boolean">
  Whether to save this iOS configuration as a new reusable mobile app.
</ParamField>

<ParamField body="payload.ios.appName" type="string">
  Name for the saved mobile app (required if saveApp is true).
</ParamField>

<ParamField body="payload.social" type="object">
  Social media preview configuration for rich link sharing.
</ParamField>

<ParamField body="payload.social.title" type="string">
  Title displayed in social media previews.
</ParamField>

<ParamField body="payload.social.description" type="string">
  Description displayed in social media previews.
</ParamField>

<ParamField body="payload.social.image" type="string">
  Image URL displayed in social media previews.
</ParamField>

<ParamField body="payload.campaign" type="object">
  UTM campaign parameters for analytics tracking.
</ParamField>

<ParamField body="payload.campaign.utm_source" type="string">
  Campaign source parameter.
</ParamField>

<ParamField body="payload.campaign.utm_medium" type="string">
  Campaign medium parameter.
</ParamField>

<ParamField body="payload.campaign.utm_campaign" type="string">
  Campaign name parameter.
</ParamField>

<ParamField body="payload.campaign.utm_term" type="string">
  Campaign term parameter (for paid search keywords).
</ParamField>

<ParamField body="payload.campaign.utm_content" type="string">
  Campaign content parameter (for A/B testing and content-targeted ads).
</ParamField>

<ParamField body="payload.desktop_fallback" type="string">
  Fallback URL for desktop users.
</ParamField>

<ParamField body="expiresAt" type="string">
  Optional expiration date in ISO 8601 format. Link will become inactive after
  this date.
</ParamField>

<Warning>
  **Cannot Update Code**: The link code cannot be changed after creation. This is a permanent identifier for the link.
</Warning>

<Info>
  **Expired Links**: You cannot update a link that has already expired. Consider creating a new link instead.
</Info>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  The updated link confirmation
</ResponseField>

<ResponseField name="data.message" type="string">
  Success message confirming the update
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT "https://api.bit2connect.com/1.0/links/summer-sale" \
    -H "X-API-KEY: b2co_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Updated Summer Sale Campaign",
      "payload": {
        "link": "https://yourapp.com/products/summer-sale-updated",
        "iosAppId": "550e8400-e29b-41d4-a716-446655440000",
        "androidAppId": "550e8400-e29b-41d4-a716-446655440001",
        "social": {
          "title": "Summer Sale - Now 60% Off!",
          "description": "Extended sale! Don'\''t miss out!",
          "image": "https://yourapp.com/images/summer-sale-v2.jpg"
        },
        "campaign": {
          "utm_source": "api",
          "utm_medium": "dynamic_link",
          "utm_campaign": "summer_sale_extended_2024"
        }
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.bit2connect.com/1.0/links/summer-sale", {
    method: "PUT",
    headers: {
      "X-API-KEY": "b2co_your_api_key",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      name: "Updated Summer Sale Campaign",
      payload: {
        link: "https://yourapp.com/products/summer-sale-updated",
        iosAppId: "550e8400-e29b-41d4-a716-446655440000",
        androidAppId: "550e8400-e29b-41d4-a716-446655440001",
        social: {
          title: "Summer Sale - Now 60% Off!",
          description: "Extended sale! Don't miss out!",
          image: "https://yourapp.com/images/summer-sale-v2.jpg",
        },
        campaign: {
          utm_source: "api",
          utm_medium: "dynamic_link",
          utm_campaign: "summer_sale_extended_2024",
        },
      },
    }),
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.bit2connect.com/1.0/links/summer-sale"
  headers = {
      "X-API-KEY": "b2co_your_api_key",
      "Content-Type": "application/json"
  }

  payload = {
      "name": "Updated Summer Sale Campaign",
      "payload": {
          "link": "https://yourapp.com/products/summer-sale-updated",
          "iosAppId": "550e8400-e29b-41d4-a716-446655440000",
          "androidAppId": "550e8400-e29b-41d4-a716-446655440001",
          "social": {
              "title": "Summer Sale - Now 60% Off!",
              "description": "Extended sale! Don't miss out!",
              "image": "https://yourapp.com/images/summer-sale-v2.jpg"
          },
          "campaign": {
              "utm_source": "api",
              "utm_medium": "dynamic_link",
              "utm_campaign": "summer_sale_extended_2024"
          }
      }
  }

  response = requests.put(url, json=payload, headers=headers)
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "data": {
      "message": "Link updated successfully"
    }
  }
  ```

  ```json Error Response theme={null}
  {
    "success": false,
    "error": "Link not found"
  }
  ```

  ```json Expired Link Error theme={null}
  {
    "success": false,
    "error": "Cannot edit an expired link"
  }
  ```
</ResponseExample>

## Common Use Cases

### Updating Destination URL

Change where users are redirected:

```json theme={null}
{
  "payload": {
    "link": "https://yourapp.com/new-destination"
  }
}
```

### Switching to Saved Mobile Apps

Replace manual configuration with saved apps:

```json theme={null}
{
  "payload": {
    "link": "https://yourapp.com/content",
    "iosAppId": "550e8400-e29b-41d4-a716-446655440000",
    "androidAppId": "550e8400-e29b-41d4-a716-446655440001"
  }
}
```

### Updating Social Preview

Update how the link appears when shared:

```json theme={null}
{
  "payload": {
    "link": "https://yourapp.com/content",
    "social": {
      "title": "New Promotional Title",
      "description": "Updated marketing message",
      "image": "https://yourapp.com/images/new-promo.jpg"
    }
  }
}
```

### Updating Campaign Parameters

Change analytics tracking parameters:

```json theme={null}
{
  "payload": {
    "link": "https://yourapp.com/content",
    "campaign": {
      "utm_source": "newsletter",
      "utm_medium": "email",
      "utm_campaign": "winter_2024"
    }
  }
}
```

## Related Endpoints

* [Update Link Status](/api-reference/links/update-status) - Change link status (ACTIVE/PAUSED)
* [Get Link](/api-reference/links/get) - Retrieve link details
* [Delete Link](/api-reference/links/delete) - Permanently remove a link
