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

# Create attribution link

> Create a creator attribution link

Use this endpoint to create an attribution link. The request must include `brand_id` and `product_id`; it may also include optional `tracking_id` and `destination_url`.

Field notes:

* `tracking_id`: Client-side tracking tag, up to 200 characters. Put your downstream tag, campaign, or source value here. Leading/trailing whitespace is trimmed and ASCII control characters are rejected. Create and list responses return the normalized value, and future reports will use it for downstream attribution.
* `destination_url`: Amazon landing page URL. If omitted, OpenLight uses the product detail page. It controls where the click lands and is not a tracking tag.

A successful request returns `201` with `{ "link": LinkDTO }`.

The response `marketplace` field returns the Amazon marketplace domain for the link, such as `amazon.com`, `amazon.co.uk`, or `amazon.de`. It identifies the link's Amazon site; it is not a partnership status or tracking tag.

Possible errors include:

* `400 invalid_request`: The request body is incomplete or invalid.
* `403 forbidden_resource`: The current token owner cannot access the brand or product.
* `403 ads_not_connected`: The brand ads connection is not ready for link creation.
* `404 product_not_found`: The product does not exist or is not accessible.

Related operation: to view existing attribution links, use [List attribution links](/en/creator/links/list-links).


## OpenAPI

````yaml POST /api/creator/v1/links
openapi: 3.1.0
info:
  title: OpenLight Public API
  version: 1.0.0
  summary: OpenLight seller and creator public API
  description: |
    Public API for external seller and creator integrations.
    Console/internal APIs remain documented separately in docs/openapi.yaml.
servers:
  - url: https://app.openlight.tech
    description: Production
  - url: http://localhost:8080
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: Creator Brands
  - name: Creator Products
  - name: Creator Links
  - name: Creator Reports
  - name: Seller Brands
  - name: Seller Products
paths:
  /api/creator/v1/links:
    post:
      tags:
        - Creator Links
      summary: Create an attribution link
      description: >
        Creates an attribution link for an approved brand product. The request
        must include `brand_id` and `product_id`. Use optional `tracking_id` as
        your own downstream tracking tag; it is returned by link listing and
        future reports. `destination_url` controls the Amazon landing page and
        defaults to the product detail page. The response includes
        `marketplace`, the Amazon marketplace domain derived from the landing
        page or product.
      operationId: createCreatorLink
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - brand_id
                - product_id
              properties:
                brand_id:
                  type: string
                  description: 品牌 ID。Brand ID.
                product_id:
                  type: string
                  description: 商品 ID。Product ID.
                destination_url:
                  type: string
                  description: >-
                    Amazon 落地页 URL；可选，默认使用商品详情页。Amazon landing page URL;
                    optional, defaults to the product detail page.
                tracking_id:
                  type: string
                  maxLength: 200
                  description: >-
                    客户侧追踪标识；可选，前后空白会被裁剪，不能包含 ASCII
                    控制字符。创建和列表响应会返回规范化后的值，后续报表也会使用该字段做下游归因。Client-side tracking
                    tag; optional, leading/trailing whitespace is trimmed and
                    ASCII control characters are rejected. Create/list responses
                    return the normalized value, intended for downstream
                    reporting.
      responses:
        '201':
          description: Attribution link created
          content:
            application/json:
              schema:
                type: object
                required:
                  - link
                properties:
                  link:
                    $ref: '#/components/schemas/PublicLink'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    PublicLink:
      type: object
      required:
        - id
        - brand_id
        - product_id
        - url
        - destination_url
        - marketplace
        - tracking_id
        - status
        - created_at
      properties:
        id:
          type: string
          description: 归因链接 ID。Attribution link ID.
        brand_id:
          type: string
          description: 品牌 ID。Brand ID.
        product_id:
          type: string
          description: 商品 ID。Product ID.
        url:
          type: string
          description: 可分发的归因链接 URL。Shareable attribution link URL.
        destination_url:
          type: string
          description: >-
            Amazon 落地页 URL，通常为商品详情页或创建链接时传入的目标页。Amazon landing page URL, usually
            the product detail page or the requested destination.
        marketplace:
          type: string
          description: >-
            归因链接对应的 Amazon 站点域名，例如 amazon.com、amazon.co.uk、amazon.de；不是合作状态或追踪
            tag。Amazon marketplace domain for this attribution link, such as
            amazon.com, amazon.co.uk, or amazon.de; not a partnership status or
            tracking tag.
        tracking_id:
          type: string
          description: >-
            创建链接时传入并规范化后的客户侧追踪标识；未传入时为空字符串。Normalized client-side tracking tag
            supplied at creation time; empty string when omitted.
        status:
          type: string
          description: 链接状态；当前固定为 active。Link status; currently always active.
          enum:
            - active
        created_at:
          type: string
          format: date-time
          description: 链接创建时间。Link creation time.
    PublicErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          description: 错误详情。Error detail.
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: 机器可读错误码。Machine-readable error code.
              examples:
                - invalid_api_token
                - forbidden_resource
            message:
              type: string
              description: 面向开发者的错误说明。Developer-facing error message.
  responses:
    BadRequest:
      description: Invalid request or pagination parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicErrorResponse'
          examples:
            invalid_request:
              summary: Invalid request
              value:
                error:
                  code: invalid_request
                  message: invalid_request
            invalid_pagination:
              summary: Invalid pagination
              value:
                error:
                  code: invalid_pagination
                  message: invalid_pagination
    Unauthorized:
      description: Missing or invalid API token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicErrorResponse'
    Forbidden:
      description: Token cannot access the requested role or resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicErrorResponse'
          examples:
            forbidden_resource:
              summary: Forbidden resource
              value:
                error:
                  code: forbidden_resource
                  message: forbidden_resource
            ads_not_connected:
              summary: Ads not connected
              value:
                error:
                  code: ads_not_connected
                  message: ads_not_connected
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicErrorResponse'
          examples:
            product_not_found:
              summary: Product not found
              value:
                error:
                  code: product_not_found
                  message: product_not_found
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````