# Add custom attribution

> Adds marketing custom attribution data to a profile.

## 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: |
    The Adapty Web API allows you to integrate Adapty's subscription management platform 
    into your web applications. This API provides endpoints for retrieving paywalls, 
    recording paywall views, and adding attribution data.
servers:
  - url: https://api.adapty.io
    description: Production server
security:
  - apikeyAuth: []
paths:
  /api/v2/web-api/attribution/:
    post:
      summary: Add custom attribution
      description: Adds marketing custom attribution data to a profile.
      operationId: addAttribution
      security:
        - apikeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AddAttributionRequest"
            examples:
              basic:
                summary: Basic attribution data
                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: The attribution is successfully added to the profile. The response body is blank.
          content:
            application/json:
              schema:
                type: object
                description: Empty response body
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InvalidEnumerationMemberError"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedError"
        "404":
          description: Not Found
          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: Indicates if the attribution is organic or non-organic.
          example: organic
        attribution_user_id:
          type: string
          description: ID assigned to the user by the attribution source.
          example: attribution_user_id_value
        channel:
          type: string
          description: Marketing channel name.
          example: marketing_channel_value
        campaign:
          type: string
          description: Marketing campaign name.
          example: campaign_name_value
        ad_group:
          type: string
          description: Attribution ad group.
          example: ad_group_name_value
        ad_set:
          type: string
          description: Attribution ad set.
          example: ad_set_name_value
        creative:
          type: string
          description: Attribution creative keyword.
          example: creative_name_value
        customer_user_id:
          type: string
          description: User ID you use in your app to identify the user if you do. For example, it can be your user UUID, email, or any other ID. Null if you didn't set it. Either `customer_user_id` or `profile_id` is required.
          example: user123
        profile_id:
          type: string
          description: An identifier of a user in Adapty. You can find it in the **Adapty ID** field of the profile in the Adapty Dashboard. Either `customer_user_id` or `profile_id` is required.
          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: |
        API requests must be authenticated by your public API key as the **Authorization** 
        header with the value `Api-Key {your_public_api_key}`, for example, 
        `Api-Key public_live_...`. Find this key in the Adapty Dashboard -> 
        **App Settings** -> **General** tab -> **API keys** section.
```
