# Thêm attribution tùy chỉnh

> Thêm dữ liệu attribution marketing tùy chỉnh vào hồ sơ người dùng.

## OpenAPI

```yaml
/api-specs/web-api.yaml post /api/v2/web-api/attribution/
openapi: 3.1.0
info:
  title: Adapty Web API
  version: 1.0.0
  description: |
    Adapty Web API cho phép bạn tích hợp nền tảng quản lý gói đăng ký của Adapty
    vào các ứng dụng web của bạn. API này cung cấp các endpoint để lấy paywall,
    ghi lại lượt xem paywall và thêm dữ liệu attribution.
servers:
  - url: https://api.adapty.io
    description: Máy chủ production
security:
  - apikeyAuth: []
paths:
  /api/v2/web-api/attribution/:
    post:
      summary: Thêm attribution tùy chỉnh
      description: Thêm dữ liệu attribution marketing tùy chỉnh vào hồ sơ người dùng.
      operationId: addAttribution
      security:
        - apikeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AddAttributionRequest"
            examples:
              basic:
                summary: Dữ liệu attribution cơ bản
                value:
                  status: organic
                  attribution_user_id: attribution_user_id_value
                  channel: marketing_channel_value
                  campaign: campaign_name_value
                  ad_group: ad_group_name_value
                  ad_set: ad_set_name_value
                  creative: creative_name_value
                  customer_user_id: user123
      responses:
        "201":
          description: Attribution đã được thêm thành công vào hồ sơ người dùng. Nội dung phản hồi trống.
          content:
            application/json:
              schema:
                type: object
                description: Nội dung phản hồi rỗng
        "400":
          description: Yêu cầu không hợp lệ
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InvalidEnumerationMemberError"
        "401":
          description: Không được phép
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedError"
        "404":
          description: Không tìm thấy
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileNotFoundError"
components:
  schemas:
    AddAttributionRequest:
      type: object
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - organic
            - non_organic
            - unknown
          description: Cho biết attribution là organic hay non-organic.
          example: organic
        attribution_user_id:
          type: string
          description: ID được nguồn attribution gán cho người dùng.
          example: attribution_user_id_value
        channel:
          type: string
          description: Tên kênh marketing.
          example: marketing_channel_value
        campaign:
          type: string
          description: Tên chiến dịch marketing.
          example: campaign_name_value
        ad_group:
          type: string
          description: Nhóm quảng cáo attribution.
          example: ad_group_name_value
        ad_set:
          type: string
          description: Bộ quảng cáo attribution.
          example: ad_set_name_value
        creative:
          type: string
          description: Từ khóa creative của attribution.
          example: creative_name_value
        customer_user_id:
          type: string
          description: ID người dùng bạn sử dụng trong ứng dụng để nhận dạng người dùng nếu có. Ví dụ, đây có thể là UUID người dùng, email hoặc bất kỳ ID nào khác. Null nếu bạn chưa thiết lập. Bắt buộc có `customer_user_id` hoặc `profile_id`.
          example: user123
        profile_id:
          type: string
          description: Mã định danh của người dùng trong Adapty. Bạn có thể tìm thấy nó trong trường **Adapty ID** của hồ sơ người dùng trong Adapty Dashboard. Bắt buộc có `customer_user_id` hoặc `profile_id`.
          example: 3286abd3-48b0-4e9c-a5f6-ac0a006804a6
    InvalidEnumerationMemberError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    UnauthorizedError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    ProfileNotFoundError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
  securitySchemes:
    apikeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        Các yêu cầu API phải được xác thực bằng public API key của bạn trong header **Authorization**
        với giá trị `Api-Key {your_public_api_key}`, ví dụ:
        `Api-Key public_live_...`. Tìm key này trong Adapty Dashboard ->
        **App Settings** -> tab **General** -> mục **API keys**.
```
