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

# Set Referrer

> Creates a referral relationship between a referrer and a referral user in a specific campaign. Both users will be registered if they don't exist, and campaign entries will be created as needed. The referral user must not have an existing referrer or completed tasks.



## OpenAPI

````yaml /openapi.yaml post /user/referrer
openapi: 3.0.0
info:
  title: claimr API
  version: 1.0.0
  description: >-
    Advanced features of claimr for business partners. This API provides a
    seamless integration with claimr services
  termsOfService: https://claimr.io/terms-of-service/
  contact:
    name: claimr support team
    email: support@claimr.io
servers:
  - url: https://prod.claimr.io/api/v1
    description: Production server
  - url: https://prod.claimr.io/api/v1
    description: Development server
security: []
tags: []
paths:
  /user/referrer:
    post:
      tags:
        - User
      summary: Set Referrer
      description: >-
        Creates a referral relationship between a referrer and a referral user
        in a specific campaign. Both users will be registered if they don't
        exist, and campaign entries will be created as needed. The referral user
        must not have an existing referrer or completed tasks.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - referrer
                - referral
                - platform
                - pid
              properties:
                referrer:
                  type: string
                  description: >-
                    Account identifier of the user who is referring (will be
                    registered if doesn't exist)
                referral:
                  type: string
                  description: >-
                    Account identifier of the user being referred (will be
                    registered if doesn't exist, cannot be same as referrer)
                platform:
                  type: string
                  description: Platform for both users' accounts
                pid:
                  type: string
                  description: Campaign ID (must belong to the authenticated organization)
      responses:
        '200':
          description: Referral relationship successfully established.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    description: Empty data object
        '400':
          $ref: '#/components/responses/bad_request'
          description: >-
            Bad request - missing parameters, campaign not found, campaign
            doesn't belong to organization, or referral link creation failed
        '401':
          $ref: '#/components/responses/unauthorized'
        '403':
          $ref: '#/components/responses/access_denied'
        '404':
          description: Not found - user registration failed or referral link missing
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    enum:
                      - missing_user
                      - missing_referral_link
        '409':
          description: >-
            Conflict - self-referral not allowed, user already has referrer, or
            user has completed tasks
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    enum:
                      - self_referral_not_allowed
                      - user_already_referred
        '500':
          $ref: '#/components/responses/internal_error'
      security:
        - bearer: []
components:
  responses:
    bad_request:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
              error:
                type: object
                properties:
                  code:
                    type: integer
                    format: int32
                    default: 400
                  message:
                    type: string
                    default: bad request
    unauthorized:
      description: Unauthorized request
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
              error:
                type: object
                properties:
                  code:
                    type: integer
                    format: int32
                    default: 401
                  message:
                    type: string
                    default: unauthorized
    access_denied:
      description: Access denied
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
              error:
                type: object
                properties:
                  code:
                    type: integer
                    format: int32
                    default: 403
                  message:
                    type: string
                    default: access denied
    internal_error:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
              error:
                type: object
                properties:
                  code:
                    type: integer
                    format: int32
                    default: 500
                  message:
                    type: string
                    default: internal error
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````