# Authentication

To use the SDK, you’ll need to get two kinds of keys: A CDP *API Key* to send data to Customer.io and a *Site ID*, telling the SDK which workspace your messages come from.

To get your SDK keys and send data to the right places, you’ll need to set up your app as a data inAn integration that feeds data *into* Customer.io. integration in Customer.io, and route it to your workspace. The SDK lets you route data to any number of destinations, but you *must* connect it to your workspace destination to send data, like the people you identify, the events you track, and so on, to Customer.io.

**If you haven’t already set up your app as an integration in Customer.io, [do that first](#set-up-a-new-source).**

## API Keys you’ll need[](#api-keys-youll-need)

1.  **API Key**: This key, shown in code samples as `cdpApiKey`, lets you send data to Customer.io. You’ll need it to initialize the SDK. You’ll get this key when you set up your mobile app as a data inAn integration that feeds data *into* Customer.io. integration in Customer.io.
2.  **Site ID**: This key tells the SDK which workspace your messages come from. You’ll use it to initialize the `MessagingInApp` package and send in-app messages from your workspace. If you’re upgrading from a previous version of the Customer.io SDK, it also serves as the `migrationSiteId`.

## Get your API Key[](#get-your-api-key)

You’ll use your write key to initialize the SDK and send data to Customer.io; you’ll get this key from your mobile app’s integration card in Customer.io. If you haven’t already set up your Android integration in Customer.io, you’ll need to [do that first](#set-up-a-new-source).

1.  Go to *Data & Integrations* > Integrations\* and click **Add Integration**.
2.  On the *Overview* tab, select your Android integration. If you don’t see your Android integration, you’ll need to [set one up](#set-up-a-new-source).
    
    [![the connections page, showing an android source connected to a journeys destination](https://docs.customer.io/images/cdp-android-connected-destination.png)](#4255c5da58043a443ae665bd1bd65dab-lightbox)
    
3.  Go to **Settings** and find your **API Key**. Copy this key into your initialization call. If you’re upgrading from a previous version of the SDK, you should keep the `siteId` that you used in previous versions as the `migrationSiteId` in your config.
    
    [![get your CDP API Key from your source's settings page](https://docs.customer.io/images/cdp-android-source-api-key.png)](#d626f85b621d02e02c8551c99c73c97f-lightbox)
    
    ```kotlin
    val builder = CustomerIOConfigBuilder(
        applicationContext = this,
        cdpApiKey = "your_cdp_api_key"
    ).addCustomerIOModule(
        ModuleMessagingInApp(
            config = MessagingInAppModuleConfig.Builder(
                siteId = "your_site_id",
                region = Region.US // Replace with Region.EU if your Customer.io account is in the EU.
            ).setEventListener(InAppMessageEventListener()).build()
        )
    ).addCustomerIOModule(ModuleMessagingPushFCM())
    
    CustomerIO.initialize(builder.build())
    ```
    

 You’re not done yet

You still need your [Site IDEquivalent to the *user name* you’ll use to interface with the Journeys Track API; also used with our JavaScript snippets. You can find your Site ID under *Workspace Settings* > *API Credentials*](https://fly.customer.io/env/last/settings/api_credentials) to initialize the `MessagingInApp` package and to support people updating your app from a previous version of Customer.io SDK. See [Get your Site ID](#get-your-site-id) below.

### Set up a new integration in Customer.io[](#set-up-a-new-source)

If you don’t already have a write key, you’ll need to set up a new data inAn integration that feeds data *into* Customer.io. integration in Customer.io. The “integration” represents your app and the stream of data that you’ll send to Customer.io.

1.  Go to [*Data & Integrations* > *Integrations*](https://fly.customer.io/workspaces/last/journeys/integrations/all/overview) and click **Add Integration**.
2.  Select **Android**.
    
    [![set up your android source](https://docs.customer.io/images/cdp-android-source.png)](#ca6b19a9972ef425e33c8ce9c19c2744-lightbox)
    
3.  Enter a *Name* for your integration, like “My Android App”.
4.  We’ll present you with a code sample containing a `cdpApiKey` that you’ll use to initialize the SDK. Copy this key and keep it handy.
5.  Click **Complete Setup** to finish setting up your integration.
    
    [![Set your name, get your CDP API Key, and click Complete Setup](https://docs.customer.io/images/cdp-android-source-setup.png)](#61f1ba08da415a2bac90e7b32907faf7-lightbox)
    

Now the *Integrations* page shows that your Android integration is connected to your workspace. You can also [connect your Android integration to other services](/integrations/data-out/add-destination/) if you want to send your mobile data to other places outside of Customer.io—like your analytics provider, data warehouse, or CRM.

## Get your Site ID[](#get-your-site-id)

You’ll use your Site ID to initialize the `MessagingInApp` package and send in-app messages from your workspace.

If you’re upgrading from a previous version, my can also set your Site ID as your `migrationSiteId`. This key is used to send remaining tasks to Customer.io when your audience updates your app.

1.  Go to and select **Workspace Settings** in the upper-right corner of the Customer.io app and go to [**API and Webhook Credentials**](https://fly.customer.io/workspaces/last/settings/api_credentials).
    
2.  Copy the **Site ID** for the set of credentials that you want to send your in-app messages from. If you don’t have a set of credentials, click **Create Tracking API Key**.
    
    [![find your site ID](https://docs.customer.io/images/cdp-js-site-id.png)](#64d2b27827ffddb00dc77b851a7a6854-lightbox)
    
3.  You’ll use this key to initialize the `MessagingInApp` package.
    
    ```kotlin
    val builder = CustomerIOConfigBuilder(
        applicationContext = this,
        cdpApiKey = "your_cdp_api_key"
    ).migrationSiteId("your_site_id")
        .addCustomerIOModule(
            ModuleMessagingInApp(
                config = MessagingInAppModuleConfig.Builder(
                    siteId = "your_site_id",
                    region = Region.US // Replace with Region.EU if your Customer.io account is in the EU.
                ).setEventListener(InAppMessageEventListener()).build()
            )
        )
        .addCustomerIOModule(ModuleMessagingPushFCM())
    
    CustomerIO.initialize(builder.build())
    ```
    

## Securing your credentials[](#securing-your-credentials)

To simplify things, code samples in our documentation sometimes show API keys directly in your code. But you don’t have to hard-code your keys in your app. You can use environment variables, management tools that handle secrets, or other methods to keep your keys secure if you’re concerned about security.

To be clear, the keys that you’ll use to initialize the SDK don’t provide read access to data in Customer.io; they only write data to Customer.io. A bad actor who found your credentials can’t use your keys to read data from our servers.