---
updatedAt: 2026-05-27T07:01:03.000Z
agentTools:
  projectIndex: https://open-api.docs.shoplineapp.com/llms.txt
---

# Create Affiliate Campaign

To create affiliate campaign.<br>建立推薦活動。

# OpenAPI definition

```json
{
  "info": {
    "title": "SHOPLINE Open API",
    "version": "2.348.2",
    "description": "Welcome to the shopline open-api developer hub. You'll find comprehensive guides and documentation to help you start working with shopline open-api as quickly as possible, as well as support if you get stuck. Let's jump right in!"
  },
  "servers": [
    {
      "url": "https://open.shopline.io/v1",
      "description": "Production"
    }
  ],
  "openapi": "3.0.0",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "AffiliateCampaign": {
        "type": "object",
        "properties": {
          "id": {
            "description": "Affiliate Campaign Unique ID<br>推薦活動ID",
            "type": "string",
            "example": "5ce0d084e388096bdb229a59"
          },
          "name": {
            "description": "Affiliate Campaign Name<br>推薦活動名稱",
            "type": "string",
            "example": "Affiliate Campaign Name"
          },
          "type": {
            "description": "Affiliate Campaign Type<br>推薦活動類型",
            "type": "string",
            "enum": [
              "affiliate_referral",
              "product_attribution"
            ],
            "example": "affiliate_referral"
          },
          "condition_value": {
            "description": "Condition for total order over how much money to get the reward<br>全單超過多少錢可以獲得回饋",
            "type": "integer",
            "example": 100
          },
          "reward_type": {
            "description": "Reward type<br>訂單回饋類型<br>",
            "type": "string",
            "enum": [
              null,
              "amount",
              "percentage"
            ],
            "example": "percentage"
          },
          "reward_value": {
            "description": "Reward value<br>訂單回饋值",
            "type": "integer",
            "example": 10
          },
          "promotion_ids": {
            "description": "Promotion ids<br>套用優惠折扣 ID 列表",
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "5ce0d084e388096bdb229a59"
            ]
          },
          "code": {
            "description": "Affiliate code<br>推薦代碼",
            "type": "string",
            "example": "iris123"
          },
          "referral_link": {
            "description": "Referral link<br>推薦連結",
            "type": "string",
            "example": "https://irishsu400.shoplineapp.com?sl-ref=iris123"
          },
          "partner_info": {
            "description": "Partner Info<br>合作夥伴資訊",
            "type": "object",
            "example": {
              "name": "",
              "email": ""
            }
          },
          "apply_on": {
            "description": "Apply on order or product<br>套用於訂單或商品",
            "type": "string",
            "enum": [
              "order",
              "product"
            ],
            "example": "order"
          },
          "apply_method": {
            "description": "Apply method<br> 套用方式:<br> - all: 全部<br> - item: 逐筆設定",
            "type": "string",
            "enum": [
              "all",
              "product"
            ],
            "example": "all"
          },
          "use_count": {
            "description": "Use count<br>使用次數",
            "type": "integer",
            "default": 0,
            "example": 1
          },
          "affiliate_percentage": {
            "description": "Affiliate percentage<br>分潤百分比",
            "type": "number",
            "format": "float",
            "example": 30
          },
          "affiliate_amount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Money"
              },
              {
                "description": "Affiliate amount<br>分潤固定金額"
              }
            ]
          },
          "condition_min_amount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Money"
              },
              {
                "description": "The threshold amount (for order level)<br>門檻金額 (for order level)"
              }
            ]
          },
          "campaign_products": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CampaignProduct"
              },
              {
                "example": [
                  {
                    "id": "636df5c595dfd82050ad2220",
                    "product_id": "5ce0d084e388096bdb229a59",
                    "affiliate_amount": {
                      "cents": 12,
                      "currency_symbol": "NT$",
                      "currency_iso": "TWD",
                      "label": "NT$12",
                      "dollars": 12
                    }
                  }
                ]
              }
            ]
          },
          "start_at": {
            "description": "Affiliate campaign start time<br>推薦活動開始時間<br>-<br>*UTC Time",
            "type": "string",
            "example": "2018-01-10T06:33:45.231Z"
          },
          "end_at": {
            "description": "Affiliate campaign end time<br>推薦活動結束時間<br>-<br>*UTC Time",
            "type": "string",
            "example": "2018-01-10T06:33:45.231Z"
          },
          "remarks_translations": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Translatable"
              },
              {
                "description": "Remarks translations<br>顯示於 KOL Hub 的條款說明",
                "example": {
                  "zh-hant": "條款說明"
                }
              }
            ]
          },
          "created_at": {
            "description": "Affiliate campaign created time<br>推薦活動創建時間<br>-<br>*UTC Time",
            "type": "string",
            "example": "2018-01-10T06:33:45.231Z"
          },
          "updated_at": {
            "description": "Affiliate campaign updated time<br>推薦活動更新時間<br>-<br>*UTC Time",
            "type": "string",
            "example": "2018-01-10T06:33:45.231Z"
          },
          "total_reward_value": {
            "description": "total reward value of orders",
            "$ref": "#/components/schemas/Money"
          }
        }
      },
      "Translatable": {
        "type": "object",
        "properties": {
          "en": {
            "type": "string",
            "description": "Merchant defined English name<br>店家定義英文名稱"
          },
          "zh-hant": {
            "type": "string",
            "description": "Merchant defined Traditional Chinese name<br>店家定義繁體中文名稱"
          },
          "zh-cn": {
            "type": "string",
            "description": "Merchant defined Simplified Chinese name<br>店家定義簡體中文名稱"
          },
          "vi": {
            "type": "string",
            "description": "Merchant defined Vietnamese name<br>店家定義越南文名稱"
          },
          "ms": {
            "type": "string",
            "description": "Merchant defined Malaysian name<br>店家定義馬來西亞文名稱"
          },
          "ja": {
            "type": "string",
            "description": "Merchant defined Japanese name<br>店家定義日文名稱"
          },
          "th": {
            "type": "string",
            "description": "Merchant defined Thai name<br>店家定義泰文名稱"
          },
          "id": {
            "type": "string",
            "description": "Merchant defined Indian name<br>店家定義印度文名稱"
          },
          "de": {
            "type": "string",
            "description": "Merchant defined Deutsch name<br>店家定義德文名稱"
          },
          "fr": {
            "type": "string",
            "description": "Merchant defined France name<br>店家定義法文名稱"
          }
        }
      },
      "Money": {
        "type": "object",
        "properties": {
          "cents": {
            "type": "integer"
          },
          "currency_symbol": {
            "type": "string"
          },
          "currency_iso": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "dollars": {
            "type": "number"
          }
        },
        "example": {
          "cents": 999999999,
          "currency_symbol": "NT$",
          "currency_iso": "TWD",
          "label": "NT$999,999,999",
          "dollars": 999999999
        }
      },
      "CampaignProduct": {
        "type": "object",
        "properties": {
          "id": {
            "description": "Affiliate Campaign Unique ID<br>推薦活動ID",
            "type": "string",
            "example": "5ce0d084e388096bdb229a59"
          },
          "product_id": {
            "description": "Product ID<br>商品ID",
            "type": "string",
            "example": "5ce0d084e388096bdb229a59"
          },
          "affiliate_percentage": {
            "description": "Affiliate percentage<br>分潤百分比",
            "type": "number",
            "format": "float",
            "example": 30
          },
          "affiliate_amount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Money"
              },
              {
                "description": "Affiliate amount<br>分潤固定金額"
              }
            ]
          }
        }
      },
      "ServerError": {
        "type": "object",
        "properties": {
          "message": {
            "description": "A detailed message of the reason of failure",
            "example": "Unable to create EventTrackers",
            "type": "string"
          },
          "code": {
            "description": "An error code",
            "example": "UnknownError",
            "type": "string"
          }
        }
      },
      "UnprocessableEntityError": {
        "type": "object",
        "properties": {
          "error": {
            "description": "A detailed message of the reason of failure",
            "type": "string"
          },
          "message": {
            "description": "A detailed message of the reason of failure",
            "example": "Unable to process the changes [\"event_type\" is not valid], [\"config_data.access_token\" is not valid]",
            "type": "string"
          },
          "code": {
            "description": "An error code",
            "example": "ValidationError",
            "type": "string"
          },
          "extras": {
            "description": "An extra information of the reason of failure",
            "type": "object"
          }
        }
      }
    }
  },
  "paths": {
    "/affiliate_campaigns": {
      "post": {
        "summary": "Create Affiliate Campaign",
        "description": "To create affiliate campaign.<br>建立推薦活動。",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "description": "Affiliate Campaign Name<br>推薦活動名稱",
                    "type": "string",
                    "example": "Affiliate Campaign Name"
                  },
                  "reward_type": {
                    "description": "Reward type<br>訂單回饋類型<br>",
                    "type": "string",
                    "example": "percentage"
                  },
                  "promotion_ids": {
                    "description": "Promotion Ids<br>套用優惠折扣 ID 列表",
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "example": [
                      "5f8e5dc08a8bb70a5c9cd93c"
                    ]
                  },
                  "code": {
                    "description": "Affiliate code<br>推薦代碼",
                    "type": "string",
                    "example": "iris123"
                  },
                  "start_at": {
                    "description": "Affiliate campaign start time<br>推薦活動開始時間<br>-<br>*UTC Time",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-01-01T00:00:00.000Z"
                  },
                  "end_at": {
                    "description": "Affiliate campaign end time<br>推薦活動結束時間<br>-<br>*UTC Time",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-01-02T00:00:00.000Z"
                  },
                  "remarks_translations": {
                    "description": "Remarks translations<br>顯示於 KOL Hub 的條款說明",
                    "type": "object",
                    "example": {
                      "zh-hant": "條款說明"
                    }
                  },
                  "apply_on": {
                    "description": "Apply on order or product<br>套用於訂單或商品",
                    "type": "string",
                    "enum": [
                      "order",
                      "product"
                    ],
                    "example": "order"
                  },
                  "apply_method": {
                    "description": "Apply method<br> 套用方式:<br> - all: 全部<br> - item: 逐筆設定",
                    "type": "string",
                    "enum": [
                      "all",
                      "product"
                    ],
                    "example": "all"
                  },
                  "affiliate_percentage": {
                    "description": "Affiliate percentage<br>分潤百分比",
                    "type": "number",
                    "format": "float",
                    "example": 30
                  },
                  "affiliate_amount": {
                    "description": "Affiliate amount<br>分潤固定金額",
                    "type": "object",
                    "example": {
                      "dollars": 30
                    }
                  },
                  "condition_min_amount": {
                    "description": "The threshold amount (for order level)<br>門檻金額 (for order level)",
                    "type": "object",
                    "example": {
                      "dollars": 30
                    }
                  },
                  "campaign_products": {
                    "type": "object",
                    "properties": {
                      "product_id": {
                        "$ref": "#/components/schemas/CampaignProduct/properties/product_id"
                      },
                      "affiliate_percentage": {
                        "$ref": "#/components/schemas/CampaignProduct/properties/affiliate_percentage"
                      },
                      "affiliate_amount": {
                        "type": "object",
                        "example": {
                          "dollars": 12
                        }
                      }
                    },
                    "example": [
                      {
                        "product_id": "5ce0d084e388096bdb229a59",
                        "affiliate_amount": {
                          "dollars": 12
                        }
                      }
                    ]
                  }
                },
                "required": [
                  "name",
                  "code"
                ]
              }
            }
          }
        },
        "tags": [
          "Affiliate Campaigns"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AffiliateCampaign"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableEntityError"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                },
                "examples": {
                  "1": {
                    "summary": "Unknown error",
                    "value": {
                      "message": "Unable to post create",
                      "code": "UNKNOWN"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Affiliate Campaigns",
      "description": "Operations about affiliate campaigns"
    }
  ]
}
```