> For the complete documentation index, see [llms.txt](https://docs.abtasty.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abtasty.com/server-side/command-line-interface/resource-loader/feature-experimentation/targeting-key.md).

# Targeting key

#### Definition

A **Targeting Key** is a governed attribute definition that you can safely reference in variation-group targeting rules (e.g., `release`, `country`, `isLoggedIn`). Declaring keys centrally ensures consistent naming, types, and documentation across campaigns and SDKs.

#### Payload Properties

When creating or updating a targeting key, the `payload` can include:

* `id` (String, optional) — Unique targeting key identifier. Include this only when updating an existing targeting key.
* `name` (String, **required**) — Machine-readable key used in `targeting.targetings[].key`.\
  \&#xNAN;*Example:* `"release"`, `"country"`, `"targeting_key_created_with_resource_loader"`.
* `type` (String, **required**) — Data type of the key. Common values: `"string"`, `"number"`, `"boolean"`.\
  \&#xNAN;*Use the type your SDK will emit at runtime.*
* `description` (String, optional) — Human-friendly explanation of what the key represents and how it’s populated by your app/SDK.

> Notes\
> • Keep key names stable; changing them requires updating all targeting that references the key.\
> • Use the most specific type possible to enable operator validation (e.g., numbers for numeric comparisons).

**Example Project Payload:**

```json
{
  "type": "string",
  "name": "targeting_key_created_with_resource_loader",
  "description": "Loaded from resource loader"
}
```

#### Response Fields

When a Targeting Key is returned by the API/Resource Loader, you’ll receive its server-assigned ID and normalized definition:

* `id` (String) — Unique targeting key identifier.
* `name` (String) — Targeting key name used in rules.
* `type` (String) — Data type (e.g., `"string"`).
* `description` (String) — Documentation for the key.

**Example Response**

```json
{
  "description": "Loaded from resource loader",
  "id": "targeting_key",
  "name": "targeting_key_created_with_resource_loader",
  "type": "string"
}
```

#### Error Codes

* **InvalidPayload** – Missing project name when creating a project, or other payload formatting issues.
* **PermissionDenied** – User not allowed to create projects (if such permission is restricted).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.abtasty.com/server-side/command-line-interface/resource-loader/feature-experimentation/targeting-key.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
