> ## 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.

# Create Dynamic Link

> Learn how to create dynamic links with the Bit2Connect API

## Overview

Create a new dynamic link that intelligently routes users to the right destination based on their device and app installation status. Dynamic links work across iOS, Android, and web platforms with advanced analytics tracking.

## Endpoint

<CodeGroup>
  ```bash Public API theme={null}
  POST https://api.bit2connect.com/1.0/links
  ```

  ```bash Headers Required theme={null}
  X-API-KEY: b2co_your_api_key_here
  Content-Type: application/json
  ```
</CodeGroup>

## Request Parameters

For detailed information about all request parameters and payload configuration, see the [Create Link API Reference](/api-reference/links/create).

### Mobile App Integration

You have two options for configuring mobile app behavior:

**1. Use Saved Mobile Apps (Recommended)**

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

**2. Configure Manually (with optional save)**

```json theme={null}
{
  "payload": {
    "link": "https://example.com/content",
    "ios": {
      "bundleId": "com.example.app",
      "app_store_fallback": "https://apps.apple.com/app/id123456789",
      "saveApp": true,
      "appName": "My iOS App"
    }
  }
}
```

<Info>
  Learn more about mobile app management in the [Mobile Apps Guide](/guides/mobile-apps-overview).
</Info>

### Code Validation

When specifying a custom `code` parameter:

* **Length**: 3-50 characters
* **Characters**: Alphanumeric, hyphens (-), and underscores (\_) only
* **Uniqueness**: Must be unique within your project

<Tip>
  **Check Availability First**: Use the [Check Code
  Availability](/guides/check-code-availability) endpoint to verify if your
  desired code is available before creating the link.
</Tip>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.bit2connect.com/1.0/links" \
    -H "X-API-KEY: b2co_your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "code": "product-launch",
      "name": "New Product Launch",
      "payload": {
        "link": "https://example.com/products/new-launch",
        "android": {
          "package": "com.example.app",
          "store_fallback": "https://play.google.com/store/apps/details?id=com.example.app"
        },
        "ios": {
          "bundleId": "com.example.app",
          "app_store_fallback": "https://apps.apple.com/app/example-app/id123456789"
        },
        "social": {
          "title": "Introducing Our Latest Product!",
          "description": "Discover amazing features and exclusive deals",
          "image": "https://example.com/images/product-launch.jpg"
        },
        "campaign": {
          "utm_source": "api",
          "utm_medium": "dynamic_link",
          "utm_campaign": "product_launch_2024"
        }
      },
      "expiresAt": "2024-12-31T23:59:59Z"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.bit2connect.com/1.0/links", {
    method: "POST",
    headers: {
      "X-API-KEY": "b2co_your_api_key_here",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      code: "product-launch",
      name: "New Product Launch",
      payload: {
        link: "https://example.com/products/new-launch",
        android: {
          package: "com.example.app",
          store_fallback:
            "https://play.google.com/store/apps/details?id=com.example.app",
        },
        ios: {
          bundleId: "com.example.app",
          app_store_fallback:
            "https://apps.apple.com/app/example-app/id123456789",
        },
        social: {
          title: "Introducing Our Latest Product!",
          description: "Discover amazing features and exclusive deals",
          image: "https://example.com/images/product-launch.jpg",
        },
        campaign: {
          utm_source: "api",
          utm_medium: "dynamic_link",
          utm_campaign: "product_launch_2024",
        },
      },
      expiresAt: "2024-12-31T23:59:59Z",
    }),
  });

  const data = await response.json();
  console.log("Short URL:", data.data.shortUrl);
  ```

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

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

  payload = {
      "code": "product-launch",
      "name": "New Product Launch",
      "payload": {
          "link": "https://example.com/products/new-launch",
          "android": {
              "package": "com.example.app",
              "store_fallback": "https://play.google.com/store/apps/details?id=com.example.app"
          },
          "ios": {
              "bundleId": "com.example.app",
              "app_store_fallback": "https://apps.apple.com/app/example-app/id123456789"
          },
          "social": {
              "title": "Introducing Our Latest Product!",
              "description": "Discover amazing features and exclusive deals",
              "image": "https://example.com/images/product-launch.jpg"
          },
          "campaign": {
              "utm_source": "api",
              "utm_medium": "dynamic_link",
              "utm_campaign": "product_launch_2024"
          }
      },
      "expiresAt": "2024-12-31T23:59:59Z"
  }

  response = requests.post(url, json=payload, headers=headers)
  data = response.json()
  print(f"Short URL: {data['data']['shortUrl']}")
  ```
</CodeGroup>

## Response

### Success Response

```json theme={null}
{
  "success": true,
  "data": {
    "id": "clp123abc456",
    "code": "product-launch",
    "shortUrl": "https://b2co.link/product-launch",
    "originalUrl": "https://example.com/products/new-launch",
    "name": "New Product Launch",
    "status": "ACTIVE",
    "qrCode": "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=https://b2co.link/product-launch",
    "createdAt": "2024-01-15T10:30:00Z",
    "expiresAt": "2024-12-31T23:59:59Z",
    "clickCount": 0
  },
  "timestamp": "2024-01-15T10:30:00Z"
}
```

### Error Response

```json theme={null}
{
  "success": false,
  "error": {
    "code": "CODE_ALREADY_EXISTS",
    "message": "The specified code is already in use"
  }
}
```

For detailed response fields and error codes, see the [Create Link API Reference](/api-reference/links/create).

## Next Steps

<CardGroup cols={2}>
  <Card title="List Links" icon="list" href="/guides/list-links">
    Retrieve and manage your existing dynamic links
  </Card>

  <Card title="Get Link Details" icon="eye" href="/guides/get-link">
    Fetch detailed information about a specific link
  </Card>

  <Card title="Update Link Status" icon="toggle-on" href="/guides/update-link-status">
    Activate, pause, or archive your links
  </Card>

  <Card title="Delete Link" icon="trash" href="/guides/delete-link">
    Permanently remove links from your project
  </Card>
</CardGroup>
