GitHub project

Authentication

To use the SDK, you need a public API key (beginning with pk_) to send data to Customer.io. If you upgrade from an earlier SDK version, or use in-app messaging with an SDK version before 5.1.0, you also need your Site ID.

To get your SDK keys and send data to the right places, set up a data in integration in Customer.io to represent your app.

If you haven’t already set up your app as an integration in Customer.io, set up your integration first.

Which key goes in your app

Your app uses a public key, which starts with pk_. Public keys are safe to include in your app. Private keys start with sk_ and have much broader access to your workspace, so keep them in your backend systems where your users can’t get to them. See public and private keys.

Credentials you’ll need

  1. Public API key: This key starts with pk_ and is shown in code samples as cdpApiKey. It lets your app send data to Customer.io, and you need it to initialize the SDK. Customer.io creates one when you set up your integration. You can also create one for an existing integration on the API Credentials page.
  2. Site ID: If you’re upgrading from version 2.x or earlier, you set your previous Site ID as the migrationSiteId. In SDK versions before 5.1.0, you also need it to initialize the CioMessagingInApp package. In 5.1.0 and later, the SDK uses your public key for in-app messages instead.

Set up a new iOS integration in Customer.io

If you don’t already have a public key, set up a new data in integration in Customer.io. The integration represents your app and the stream of data that you send to Customer.io.

  1. Go to Integrations and click Add integration.

  2. Select iOS.

    set up your iOS source
  3. Enter a Name for your integration, like “My iOS App”.

  4. Click the Copy and paste code tab. Customer.io shows a code sample with the credentials you need. The sample includes cdpApiKey, your public key, which initializes the SDK and sends data to Customer.io. If you use in-app messaging, it also includes siteId, which initializes CioMessagingInApp.

    The integration setup screen, with a name for your integration and a code sample that includes your public key

    Copy the code—or at least the cdpApiKey—into your app. If you use in-app messaging with an SDK version before 5.1.0, copy the siteId too.

    SWIFT
    CustomerIO.initialize(
     withConfig: SDKConfigBuilder(cdpApiKey: "YOUR_CDP_API_KEY")
         .region(.US)
         .build()
    )
    // Before iOS SDK 4.12.0, use MessagingInAppConfigBuilder(siteId: "YOUR_SITE_ID", region: .US), and use .EU if your account is in our EU data center.
    MessagingInApp.initialize(
     withConfig: MessagingInAppConfigBuilder(siteId: "YOUR_SITE_ID")
         .build()
    )
    
  5. Click Test connection to check that Customer.io receives data from your app, and then click Complete setup. If you aren’t ready to test your app yet, click Save for later.

Get credentials from an existing iOS integration

Use this section if you’ve already set up an iOS integration and need to copy your credentials again.

Get your public key

Use your public key to initialize the SDK and send data to Customer.io. You can find this key on your mobile app’s integration card in Customer.io, or under Account Settings > API Credentials.

  1. Go to Integrations.
  2. Select your iOS integration in the Overview tab. If you don’t see an iOS integration, you’ll need to set it up.
    the connections page, showing an ios source connected to a journeys destination
  3. Go to Settings and find your public key. It starts with pk_. Copy this key into your initialization call.
    The API keys section of your integration's Settings tab, showing your public key
    SWIFT
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
         ...
    
         let config = SDKConfigBuilder(cdpApiKey: "YOUR_CDP_API_KEY")
             .autoTrackDeviceAttributes(true)
    
         CustomerIO.initialize(withConfig: config.build())
     }
    

Find your Site ID manually

You only need your Site ID if you use in-app messaging with an SDK version before 5.1.0, or if you’re setting migrationSiteId while upgrading from version 2.x or earlier.

  1. Go to and select Workspace Settings in the upper-right corner of the Customer.io app. Then go to API and Webhook 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

In SDK versions before 5.1.0, use this value in MessagingInAppConfigBuilder(siteId: "YOUR_SITE_ID"). Before 4.12.0, also pass region: .US, or region: .EU if your account is in our EU data center. In 5.1.0 and later, the SDK uses your public key, so you can use MessagingInAppConfigBuilder() instead. If you’re upgrading from version 2.x or earlier, use the Site ID from your previous SDK setup as migrationSiteId.

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.

Updated October 30, 2026