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

# Generate Affiliate Links

> Convert URLs to affiliate links using the Wildfire network.

<Tip>
  **When to use:** Monetize product links by generating trackable affiliate URLs. Supports up to 100 URLs per request.
</Tip>

## Request

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication
</ParamField>

### Request Body

<ParamField body="urls" type="string[]" required>
  Array of product URLs to convert into affiliate links (maximum 100 URLs per request)

  **Requirements:**

  * Must be a non-empty array
  * Each entry must be a valid URL string
  * Maximum 100 URLs per request

  **Example:**

  ```json theme={null}
  [
    "https://www.nike.com/t/air-force-1-07-mens-shoes-5QFp5Z/CW2288-111",
    "https://www.adidas.com/us/gazelle-shoes/BB5476.html",
    "https://www.amazon.com/dp/B08XYZ123"
  ]
  ```

  **URL sanitization:** URLs are sanitized and normalized on the backend; client-side sanitization is not required.
</ParamField>

## Response

<ResponseField name="data" type="array">
  Array of affiliate link generation results, one for each input URL

  <Expandable title="Affiliate Link Result">
    <ResponseField name="wildfire_link" type="string">
      Generated affiliate tracking link (empty string if generation failed)
    </ResponseField>

    <ResponseField name="original_url" type="string">
      Original product URL that was processed
    </ResponseField>

    <ResponseField name="device_id" type="string">
      Wildfire device ID used for link generation
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Whether the affiliate link was successfully generated
    </ResponseField>

    <ResponseField name="error" type="string" optional>
      Error message if link generation failed (only present when success is false)
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="pagination" type="object">
  Pagination metadata for the results

  <Expandable title="Pagination Object">
    <ResponseField name="page" type="number">
      Current page number (always 1 for this endpoint)
    </ResponseField>

    <ResponseField name="page_size" type="number">
      Number of items per page (equals the number of URLs in the request)
    </ResponseField>

    <ResponseField name="total_items" type="number">
      Total number of URLs processed (same as `total_processed`)
    </ResponseField>

    <ResponseField name="total_pages" type="number">
      Total number of pages (always 1 for this endpoint)
    </ResponseField>

    <ResponseField name="has_next" type="boolean">
      Whether there is a next page (always false for this endpoint)
    </ResponseField>

    <ResponseField name="has_prev" type="boolean">
      Whether there is a previous page (always false for this endpoint)
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="meta" type="object">
  Response metadata and summary statistics

  <Expandable title="Meta Properties">
    <ResponseField name="total_processed" type="number">
      Total number of URLs processed in this request
    </ResponseField>

    <ResponseField name="successful" type="number">
      Number of URLs that successfully generated affiliate links
    </ResponseField>

    <ResponseField name="failed" type="number">
      Number of URLs that failed to generate affiliate links
    </ResponseField>

    <ResponseField name="request_id" type="string" optional>
      Unique request identifier for support purposes
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample dropdown>
  ```powershell cURL theme={null}
  curl -X POST https://api.getcatalog.ai/v2/affiliate \
    -H "Content-Type: application/json" \
    -H "x-api-key: $CATALOG_API_KEY" \
    -d '{
      "urls": [
        "https://www.nike.com/t/air-force-1-07-mens-shoes-5QFp5Z/CW2288-111",
        "https://www.adidas.com/us/gazelle-shoes/BB5476.html",
        "https://www.amazon.com/dp/B08XYZ123"
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.getcatalog.ai/v2/affiliate', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': 'YOUR_API_KEY'
    },
    body: JSON.stringify({
      urls: [
        'https://www.nike.com/t/air-force-1-07-mens-shoes-5QFp5Z/CW2288-111',
        'https://www.adidas.com/us/gazelle-shoes/BB5476.html',
        'https://www.amazon.com/dp/B08XYZ123'
      ]
    })
  });

  const data = await response.json();
  console.log(`Generated ${data.data.length} affiliate links`);
  console.log(`Successful: ${data.meta.successful}, Failed: ${data.meta.failed}`);
  ```

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

  response = requests.post(
      'https://api.getcatalog.ai/v2/affiliate',
      headers={
          'Content-Type': 'application/json',
          'x-api-key': 'YOUR_API_KEY'
      },
      json={
          'urls': [
              'https://www.nike.com/t/air-force-1-07-mens-shoes-5QFp5Z/CW2288-111',
              'https://www.adidas.com/us/gazelle-shoes/BB5476.html',
              'https://www.amazon.com/dp/B08XYZ123'
          ]
      }
  )

  data = response.json()
  print(f"Generated {len(data['data'])} affiliate links")
  print(f"Successful: {data['meta']['successful']}, Failed: {data['meta']['failed']}")
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "data": [
      {
        "wildfire_link": "https://wild.link/e?d=37430269&dc=www.nike.com&url=https%3A%2F%2Fwww.nike.com%2Ft%2Fair-force-1-07-mens-shoes-5QFp5Z%2FCW2288-111",
        "original_url": "https://www.nike.com/t/air-force-1-07-mens-shoes-5QFp5Z/CW2288-111",
        "device_id": "37430269",
        "success": true
      },
      {
        "wildfire_link": "https://wild.link/e?d=37430269&dc=www.adidas.com&url=https%3A%2F%2Fwww.adidas.com%2Fus%2Fgazelle-shoes%2FBB5476.html",
        "original_url": "https://www.adidas.com/us/gazelle-shoes/BB5476.html",
        "device_id": "37430269",
        "success": true
      },
      {
        "wildfire_link": "https://wild.link/e?d=37430269&dc=www.amazon.com&url=https%3A%2F%2Fwww.amazon.com%2Fdp%2FB08XYZ123",
        "original_url": "https://www.amazon.com/dp/B08XYZ123",
        "device_id": "37430269",
        "success": true
      }
    ],
    "pagination": {
      "page": 1,
      "page_size": 3,
      "total_items": 3,
      "total_pages": 1,
      "has_next": false,
      "has_prev": false
    },
    "meta": {
      "total_processed": 3,
      "successful": 3,
      "failed": 0
    }
  }
  ```
</ResponseExample>

## Important Notes

<Warning>
  * Not all product URLs may be supported by the Wildfire network
  * Commission rates and tracking depend on Wildfire's affiliate partnerships
</Warning>
