# 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"  
}  
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.idosgames.com/api/api-v1/referral.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
