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

# TikTok Integration

> Endpoints for TikTok Shop integration and creator management

## Authentication

### Initiate Authorization

<ParamField query="GET /auth/tiktok">
  Initiate TikTok Shop authorization flow
</ParamField>

#### Parameters

<ParamField query="userId" type="string" required>
  The ID of the user
</ParamField>

#### Response

Redirects to TikTok auth page or error page with the following URL structure:

```
https://auth.tiktok-shop.com/oauth/authorize?app_key=YOUR_APP_KEY&state=USER_ID_RANDOM_STRING
```

### Authorization Callback

<ParamField query="GET /tiktok/callback">
  Callback endpoint for TikTok Shop authorization
</ParamField>

#### Parameters

<ParamField query="code" type="string" required>
  Authorization code from TikTok
</ParamField>

<ParamField query="state" type="string" required>
  State parameter containing userId and random string for security verification
</ParamField>

<ParamField query="error" type="string">
  Optional error message from TikTok if authorization fails
</ParamField>

#### Response

Redirects to one of:

* Success page: `/auth/success?platform=tiktok`
* Error page: `/auth/error?platform=tiktok&error=ERROR_MESSAGE`

### Refresh Token

<ParamField query="POST /auth/tiktok/refresh">
  Refresh TikTok Shop access token
</ParamField>

#### Parameters

<ParamField query="userId" type="string" required>
  The ID of the user
</ParamField>

#### Response

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

<ResponseField name="expiresAt" type="string">
  New token expiration timestamp
</ResponseField>

```json
{
  "message": "Token refreshed successfully",
  "expiresAt": "2024-04-14T12:00:00Z"
}
```

## Shop Operations

### Get Shop Info

<ParamField query="GET /tiktok/shop-info">
  Get TikTok Shop information
</ParamField>

#### Parameters

<ParamField query="userId" type="string" required>
  The ID of the user
</ParamField>

#### Response

<ResponseField name="shopId" type="string">
  TikTok Shop ID
</ResponseField>

<ResponseField name="region" type="string">
  Shop region code
</ResponseField>

<ResponseField name="status" type="string">
  Shop status (active/inactive)
</ResponseField>

```json
{
  "shopId": "shop123",
  "region": "US",
  "status": "active",
  "name": "My TikTok Shop",
  "createdAt": "2024-01-01T00:00:00Z"
}
```

### Search Creators

<ParamField query="GET /tiktok/creator/search">
  Search for TikTok creators
</ParamField>

#### Parameters

<ParamField query="userId" type="string" required>
  The ID of the user
</ParamField>

<ParamField query="page_token" type="string">
  Token for pagination
</ParamField>

#### Response

<ResponseField name="creators" type="array">
  List of creator profiles
</ResponseField>

<ResponseField name="next_page_token" type="string">
  Token for the next page of results
</ResponseField>

```json
{
  "creators": [
    {
      "id": "creator123",
      "username": "@creator",
      "followers": 100000,
      "engagement_rate": 0.05,
      "region": "US"
    }
  ],
  "next_page_token": "token123"
}
```

### Advanced Creator Search

<ParamField query="POST /tiktok/creator/search">
  Advanced search for TikTok creators with filters
</ParamField>

#### Parameters

<ParamField query="userId" type="string" required>
  The ID of the user
</ParamField>

<ParamField query="page_token" type="string">
  Token for pagination
</ParamField>

#### Request Body

```json
{
  "filters": {
    "minFollowers": 10000,
    "maxFollowers": 1000000,
    "minEngagementRate": 0.02,
    "regions": ["US", "CA"],
    "categories": ["fashion", "beauty"]
  }
}
```

#### Response

<ResponseField name="creators" type="array">
  List of filtered creator profiles
</ResponseField>

<ResponseField name="next_page_token" type="string">
  Token for the next page of results
</ResponseField>

```json
{
  "creators": [
    {
      "id": "creator123",
      "username": "@creator",
      "followers": 100000,
      "engagement_rate": 0.05,
      "region": "US",
      "categories": ["fashion"]
    }
  ],
  "next_page_token": "token123"
}
```
