# Use custom identifiers to prevent fraud

> The [Update customer session][update] endpoint of the [Integration API][integ] allows you to add custom identifiers in addition to the session identifier. To add custom identifiers, use the identifiers property in the body.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

Let's see how we can prevent multiple account abuse with this property.

## Prevent multiple accounts

Let's imagine we have created a [standard campaign](/docs/product/campaigns/overview#standard-campaigns)
that gives registered customers a $20 discount for their first order. We suspect some
customers will create multiple accounts to benefit from this campaign multiple times.

We can limit this if we have a way to identify the customer in a more accurate manner
than with just a [customer ID][customer-integration-id].

### Identify a device

One way we can identify a customer is by checking the IP address of the devices they use.

Let's assume that our ecommerce app is aware of the IP address used by all the customers
who are signed in. We can share a hashed version of this information with Talon.One
using the `identifiers` property while sending a request to the [Update customer session][update] endpoint.

:::tip
We highly recommend you anonymize the identifier you send to Talon.One.
Consider applying salted hashing,
for example, using [hashlib (Python)](https://docs.python.org/3/library/hashlib.html)
or [crypto (Node.js)](https://nodejs.org/api/crypto.html).
:::

Compare the following payload examples:

<Tabs
  defaultValue='init'
  values={[
    { label: 'Initial payload', value: 'init' },
    { label: 'Updated payload', value: 'identify' },
  ]}
>
  <TabItem value='init'>

  When a customer creates their first cart, for example, containing a pair of shoes,
  the `Update customer session` payload looks like this:

  ```json
  {
    "customerSession": {
      "profileId": "someid",
      "cartItems": [
        {
          "name": "summer shoes",
          "sku": "SKU1234",
          "quantity": 1,
          "price": 90,
          "category": "shoes",
          "attributes": {
            "ItemBrand": "Nike",
            "Color": "orange",
            "image": "11.jpeg",
            "size": 46
          }
        }
      ],

      "attributes": {
        "ShippingCity": "Berlin"
      }
    },
    "responseContent": ["triggeredCampaigns"]
  }
  ```

  </TabItem>

  <TabItem value='identify'>

  To identify the device, we can create or update a session by adding a hashed version
  of the device's IP address in the `identifiers` property:

  ```json {4}
  {
    "customerSession": {
      "profileId": "someid",
      "identifiers": ["d41306257915f83fe01e54092ae470f631161ea16fcf4415842eed41470386ea"],
      "cartItems": [
        {
          "name": "summer shoes",
          "sku": "SKU1234",
          "quantity": 1,
          "price": 90,
          "category": "shoes",
          "attributes": {
            "ItemBrand": "Nike",
            "Color": "orange",
            "image": "11.jpeg",
            "size": 46
          }
        }
      ],

      "attributes": {
        "ShippingCity": "Berlin"
      }
    },
    "responseContent": ["triggeredCampaigns"]
  }
  ```

  </TabItem>
</Tabs>

At this stage, we are sharing the device's hashed IP address with Talon.One so we can now
leverage that data inside our campaign's rules.

### Limit discount per identifier

The Campaign Manager offers [budget limits per identifier][budget-types].
In our case the identifier is an IP address. Let's create such a limit for our discount total:

1. [Create a campaign](/docs/product/campaigns/create-and-manage-campaigns.md).
1. In the [campaign's budgets][campaign-budgets] section, add a unique identifier budget.
1. In the budget, set the **Discount Total** limit as `20`.

### Create the rule

Let's create a rule that offers the $20 discount only to fresh checkouts:

1. In the [Rule Builder](/docs/product/rules/overview.md) of your campaign, in the **Conditions** section,
   add **[Check attribute value][check-attrib-val]**.
   - Select <Attribute name="Total Sales (Customer Profile)" type="builtin" /> > **is equal to**, and type `0`.
1. In the [**Effects**][discount-effects] section, add the **[Discount session total][discount-session-total]** effect.
   1. In **Discount Name**, type: `$20 off`.
   1. In **Discount value**, type: `20`.

After you save your rule, the campaign is ready.

:::important
- The discount effect reflects the budget we set earlier for the campaign and limits
  the amount of total discounts given per IP address. The Rule Engine checks the budget
  when evaluating the effect and looks for an identifier in the session.

- Ensure the session includes [the `identifiers` property](#identify-a-device)
  when [you close it](/docs/dev/concepts/entities/customer-sessions.md#customer-session-states).
  Otherwise, the budget cannot be evaluated, and the rule will fail even if the conditions are met.
:::

## Other ideas to use identifiers

Other examples include passing a hashed version of a credit card number as an identifier.
This way, we can prevent cases where two different customers try to get a discount when
paying with the same credit card.

## Other ways to prevent fraud

To prevent fraud, we can combine [unique identifier budgets][budget-types]
with other types of budgets, and we can directly narrow down the scope of our campaign when
setting our [conditions](/docs/product/rules/conditions/available-conditions.md). For example,
we can use [geolocation](/docs/dev/tutorials/use-geolocation.md) to grant discounts only to
customers who are in a specific location.

## Related pages

- [Manage campaign budgets](/docs/product/campaigns/settings/manage-campaign-budgets.md)
- [Cancel a session with campaign budgets](/docs/dev/tutorials/roll-back-effects.md)

[campaign-budgets]: /docs/product/campaigns/settings/manage-campaign-budgets.md
[budget-types]: /docs/product/campaigns/settings/manage-campaign-budgets.md#budget-types
[integ]: /docs/dev/integration-api/overview.md
[update]: /integration-api#tag/Customer-sessions/operation/updateCustomerSessionV2
[check-attrib-val]: /docs/product/rules/conditions/available-conditions.md#attribute-conditions
[discount-effects]: /docs/product/rules/effects/available-effects.md#discount-effects
[discount-session-total]: /docs/product/rules/effects/use-effects.md#discount-session-total
[customer-integration-id]: /docs/dev/concepts/entities/customer-profiles.md
