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

# Targeting Settings

> Learn how to configure user properties and context targeting using the REST API.

Targeting allows you to display ads to specific user groups or contexts. The REST API supports both audience targeting and context targeting.

## Audience Targeting

Target ads based on user properties.

### Request Parameters

<ParamField header="Authorization" type="string" required>
  App Key (found in adrop\_service.json)
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

<ParamField body="uid" type="string" required>
  User unique identifier
</ParamField>

<ParamField body="value" type="string" required>
  Property data (JSON string). Includes preset and custom properties.
</ParamField>

<ParamField body="platform" type="string">
  Platform. e.g., `web`, `android`, `ios`
</ParamField>

<ParamField body="adid" type="string">
  Advertising identifier (ADID/IDFA)
</ParamField>

### Response

<ResponseField name="code" type="integer">
  Response code. `0` indicates success.
</ResponseField>

<ResponseField name="msg" type="string">
  Response message
</ResponseField>

<ResponseExample>
  ```json Success Response theme={null}
  {
      "code": 0,
      "msg": "OK"
  }
  ```
</ResponseExample>

***

## Preset Properties

Standard properties predefined by Adrop. The same format is used across all SDKs and REST API.

### Birth Date (BIRTH)

| Key     | Example Value | Format                  |
| ------- | ------------- | ----------------------- |
| `BIRTH` | `2024`        | yyyy (year only)        |
| `BIRTH` | `202401`      | yyyyMM (year and month) |
| `BIRTH` | `20240101`    | yyyyMMdd (full date)    |

### Gender (GDR)

| Key   | Value | Meaning |
| ----- | ----- | ------- |
| `GDR` | `M`   | Male    |
| `GDR` | `F`   | Female  |
| `GDR` | `U`   | Unknown |

### Unknown Values

| Key | Value | Description                                 |
| --- | ----- | ------------------------------------------- |
| `*` | `U`   | Use to represent "unknown" for any property |

<Note>
  Preset property keys use uppercase: `BIRTH`, `GDR`
</Note>

***

## Custom Properties

You can use custom properties defined in the console.

### Setting Custom Properties

1. Navigate to the **Targeting** menu in the [Adrop Console](https://console.adrop.io)
2. Create custom properties in the **Audience Targeting** tab
3. Send the property key-value pairs via API

```javascript theme={null}
const properties = {
    // Preset properties
    BIRTH: '19931225',
    GDR: 'M',

    // Custom properties (defined in console)
    membership: 'premium',
    lastPurchaseDate: '2024-01-15',
    favoriteCategory: 'electronics'
};
```

<Warning>
  All custom property values must be STRING type.
</Warning>

***

## Context Targeting

Target ads based on page or content context. Add the `contextId` parameter to ad requests.

### Setting Up Context Targeting

1. Navigate to the **Targeting** menu in the [Adrop Console](https://console.adrop.io)
2. Create a context in the **Context Targeting** tab
3. Use the `contextId` parameter when requesting ads

### Applying Context to Ad Requests

```
GET https://api-v2.adrop.io/request?unit=YOUR_UNIT_ID&contextId=sport
```

<CodeGroup>
  ```javascript Node.js theme={null}
  const axios = require('axios');

  const config = {
      method: 'get',
      baseURL: 'https://api-v2.adrop.io',
      url: '/request',
      params: {
          unit: 'YOUR_UNIT_ID',
          uid: 'USER_ID',
          pf: 'web',
          contextId: 'sport'  // Context ID created in console
      },
      headers: {
          'Authorization': 'YOUR_APP_KEY'
      }
  };

  axios.request(config)
      .then((response) => {
          console.log(JSON.stringify(response.data));
      })
      .catch((error) => {
          console.log(error);
      });
  ```

  ```python Python theme={null}
  import requests

  url = "https://api-v2.adrop.io/request"
  params = {
      "unit": "YOUR_UNIT_ID",
      "uid": "USER_ID",
      "pf": "web",
      "contextId": "sport"
  }
  headers = {
      "Authorization": "YOUR_APP_KEY"
  }

  response = requests.get(url, params=params, headers=headers)
  print(response.json())
  ```

  ```curl cURL theme={null}
  curl -X GET "https://api-v2.adrop.io/request?unit=YOUR_UNIT_ID&uid=USER_ID&pf=web&contextId=sport" \
    -H "Authorization: YOUR_APP_KEY"
  ```
</CodeGroup>

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Consistent User ID" icon="fingerprint">
    Always use the same `uid` for the same user. Consistent IDs are key to accurate targeting.
  </Card>

  <Card title="Update Properties" icon="rotate">
    Call the `/property` endpoint immediately when user information changes.
  </Card>

  <Card title="Follow Preset Formats" icon="check">
    Use the exact specified formats for `BIRTH` and `GDR` properties.
  </Card>

  <Card title="Leverage Context" icon="tags">
    Use context targeting for page types like news, sports, shopping, etc.
  </Card>
</CardGroup>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Audience Targeting" icon="users" href="/targeting/audience">
    Configure audience targeting in the console
  </Card>

  <Card title="Context Targeting" icon="tags" href="/targeting/context">
    Configure context targeting in the console
  </Card>
</CardGroup>
