> For the complete documentation index, see [llms.txt](https://docs.idosgames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idosgames.com/api/api-v1/referral.md).

# Referral

This function is used to manage referral actions. It can handle activation of referral codes and validate sessions.

**URL:**

`https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Referral/[action]`

**Method:**

`GET` or `POST`

**Request Parameters:**

* `titleId` (string): Title ID of the application.
* `titleTemplateId` (string): Template ID of the title.
* `action` (string): The specific referral action to perform.
* `HttpRequest req`: HTTP request object containing the body with the following JSON structure:

```json
{  
    "WebAppLink": "string",  
    "UsageTime": "int",  
    "FunctionParameter": {  
        "ReferralCode": "string"  
    },  
    "UserID": "string",  
    "ClientSessionTicket": "string",  
    "EntityToken": "string"  
}  
```

## ActivateReferralCode

Activates a referral code provided by another user.

**URL:**

`https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Referral/ActivateReferralCode`

**Method:**

`POST`

**Request Parameters (JSON body):**

* `FunctionParameters`:
  * `ReferralCode` (string): The referral code to be activated.

**Responses:**

* **200 OK**: Referral code successfully activated. Returns a success message:
  * `REFERRAL_MESSAGE_CODE_SUCCESS_ACTIVATED`
* **400 Bad Request**: Incorrect referral code, or activation issues. Possible messages:
  * `args or refferalCode is null`
  * `INCORRECT_TITLE_ID_OR_STATUS_INACTIVE`
  * `REFERRAL_MESSAGE_CODE_YOUR`
  * `REFERRAL_MESSAGE_CODE_INCORRECT`
  * `REFERRAL_MESSAGE_CODE_ALREADY_ACTIVATED`

#### Example Usage:

**Request:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Referral/ActivateReferralCode', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        "FunctionParameter": {    
            "ReferralCode": "ABC123"   
        }    
    })    
})    
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

**Response:**

```json
{  
    "Message": "REFERRAL_MESSAGE_CODE_SUCCESS_ACTIVATED"  
}  
```
