# Subscriber Identification (/docs/products/ussd-flows/developers/exchange-api/subscriber-identification)

Requests to your server don't include the subscriber's full phone number. They include two fields based on it:

| Field                     | Contains                                                             | Use it for                                               |
| ------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------- |
| `global.subscriberId`     | A stable ID made from the phone number                               | Recognising the subscriber, database lookups             |
| `global.subscriberMsisdn` | The phone number with four digits hidden, for example `+23276****56` | Showing the subscriber which number a transaction is for |

## subscriberId

`global.subscriberId` is a UUID (version 5, URL namespace) made from the subscriber's phone number in international format with the `+`, for example `+23276123456`. The same number always gives the same ID, so you can store it and use it to recognise the subscriber next time.

There are two ways to use it:

- **Store it as the subscriber's ID.** You never need the phone number itself to link sessions to the same person.
- **Match it against a number you already have.** If the subscriber gave you their number another way, such as at sign-up, compute the ID from that number and compare.

You can't turn `subscriberId` back into a phone number directly. But anyone can compute it from a known number, so treat it as personal data.

## subscriberMsisdn

`global.subscriberMsisdn` is the phone number with four digits replaced by `*`, for example `+23276****56`. Use it only in text shown to the subscriber, such as "Paying from +23276\*\*\*\*56".

> **Warning:** Don't use `subscriberMsisdn` to look up or match subscribers. Different numbers can look the same once masked.

## Getting the full phone number

To get the subscriber's full number, ask for their consent with the [`get_subscriber_msisdn`](/docs/products/ussd-flows/developers/templates/get-subscriber-msisdn) template. You can then pass the number to your server through `on_done.dataExport`, for example `"phone_number": "$(rc.player_msisdn)"`. It arrives in `exportedData`. Without the subscriber's consent, Monime sends the number masked.

## Matching a number you already have

Compute the ID from the stored number and compare it with `subscriberId`. Store numbers in the same format: international, with the `+`.

```javascript Node.js
// npm install uuid
const { v5: uuidv5 } = require("uuid");

function isSameSubscriber(storedPhoneNumber, subscriberId) {
  return uuidv5(storedPhoneNumber, uuidv5.URL) === subscriberId;
}

isSameSubscriber("+23276123456", payload.global.subscriberId);
```

```python Python
import uuid

def is_same_subscriber(stored_phone_number: str, subscriber_id: str) -> bool:
    return str(uuid.uuid5(uuid.NAMESPACE_URL, stored_phone_number)) == subscriber_id

is_same_subscriber("+23276123456", payload["global"]["subscriberId"])
```

```php PHP
<?php
// composer require ramsey/uuid
use Ramsey\Uuid\Uuid;

function isSameSubscriber(string $storedPhoneNumber, string $subscriberId): bool {
    return Uuid::uuid5(Uuid::NAMESPACE_URL, $storedPhoneNumber)->toString() === $subscriberId;
}

isSameSubscriber('+23276123456', $payload['global']['subscriberId']);
```

```java Java
// Maven: com.fasterxml.uuid:java-uuid-generator
import com.fasterxml.uuid.Generators;
import com.fasterxml.uuid.impl.NameBasedGenerator;

static boolean isSameSubscriber(String storedPhoneNumber, String subscriberId) {
    String id = Generators.nameBasedGenerator(NameBasedGenerator.NAMESPACE_URL)
        .generate(storedPhoneNumber)
        .toString();
    return id.equals(subscriberId);
}
```

```go Go
// go get github.com/google/uuid
import "github.com/google/uuid"

func isSameSubscriber(storedPhoneNumber string, subscriberId string) bool {
    return uuid.NewSHA1(uuid.NameSpaceURL, []byte(storedPhoneNumber)).String() == subscriberId
}
```

For example, `+23276123456` gives `c9b4e86f-a1d8-5056-8dc4-5d1aafc6994a`. Use this pair to check your code.
