# get_subscriber_msisdn (/docs/products/ussd-flows/developers/templates/get-subscriber-msisdn)

The `get_subscriber_msisdn` template asks the subscriber if your flow may use their phone number. If they agree, the number becomes the page value, and you can save it or send it to your server in full.

Without this permission, Monime hides part of the subscriber's number whenever your flow saves it or sends it out. See [When the number is masked](#when-the-number-is-masked).

## Configuration

The `label` is the permission question. Monime adds "1. Yes" and "2. No" under it. The template takes no `template_data`.

```json
{
  "id": "share_number",
  "component": {
    "type": "template",
    "label": "Kissy Road Pharmacy will text you when your medicine is ready. Share your phone number?",
    "template_name": "get_subscriber_msisdn"
  }
}
```

If you leave out `label`, the subscriber sees: "This flow is requesting to access your phone number (their number). Do you consent to this?"

## What It Returns

| The subscriber enters | Page value         |
| --------------------- | ------------------ |
| `1` (Yes)             | Their phone number |
| `2` (No)              | Empty              |

Read it with `$(page.PAGE_ID.value)`. Both answers continue the flow, so check for an empty value before relying on it.

Any other input shows "Invalid input. Please enter 1 for 'Yes' or 2 for 'No'". After 3 wrong tries the session ends.

## When the Number Is Masked

When your flow saves the subscriber's own number to a context store, or sends it in `on_done.dataExport`, Monime masks it unless the subscriber gave permission. A masked number keeps its start and its last two digits, for example `23276****56`.

The number stays whole only when the value is exactly one of these references, with nothing else in the string:

- `$(page.PAGE_ID.value)`, where `PAGE_ID` is a `get_subscriber_msisdn` page
- `$(sc.KEY)`, where `KEY` was saved from one of the references in this list
- `$(rc.KEY)`, where `KEY` was saved from one of the references in this list

Anything else that contains the subscriber's number is masked. This includes `$(session.subscriber_msisdn)`, expressions such as `$(page.share_number.value ?? '')`, and text such as `"Tel: $(page.share_number.value)"`.

A recurring context key stays whole in later sessions too, as long as it was saved by the permission page's own `on_done` and still holds the number the subscriber is dialling from.

Masking doesn't apply to:

- Text on screen. A label with `$(session.subscriber_msisdn)` shows the subscriber their full number.
- Numbers that aren't the subscriber's, such as a friend's number typed into a prompt.

In exchange requests, `global.subscriberMsisdn` is always masked. To send the full number, add it to `on_done.dataExport` as shown below.

## Example: Send the Number to Your Server

```json
{
  "version": "1.0",
  "pages": [
    {
      "id": "share_number",
      "component": {
        "type": "template",
        "label": "Kissy Road Pharmacy will text you when your medicine is ready. Share your phone number?",
        "template_name": "get_subscriber_msisdn"
      },
      "on_done": {
        "action": "exchange",
        "url": "https://api.example.com/ussd/register-phone",
        "dataExport": {
          "phone": "$(page.share_number.value)"
        },
        "recurring_context": {
          "mutations": {
            "phone": "$(page.share_number.value)"
          }
        }
      }
    },
    {
      "id": "registered",
      "component": {
        "type": "display",
        "label": "Thank you. We will text you when your medicine is ready."
      }
    },
    {
      "id": "declined",
      "component": {
        "type": "display",
        "label": "No problem. Ask at the counter when you come in."
      }
    }
  ]
}
```

Your server receives the full number in `exportedData.phone`, or an empty string if the subscriber said no. It replies with `navigate` to `registered` or `declined`. The number is also saved in `rc.phone`, so later visits can use `$(rc.phone)` in full.

The flow calls an exchange endpoint, so it needs a public key before you can publish it. See [Exchange & Dynamic API](/docs/products/ussd-flows/developers/exchange-api/overview).
