---
schema_version: "1"
id: 26db1169194655eab35ffe6ffebff4cccc98015d217bc128fd79fe05575343fd
title: setContactKey
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud-mobilepush/engagement_sdk/references/flutter/flutter_setContactKey.md
canonical_url: https://developer.salesforce.com/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/flutter_setContactKey.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: e1ae977f452a4215f0848c74c5502998e5a83a61e3055370f118c1e78413f9fd
products:
  - Salesforce Engagement SDK
---
# setContactKey

Sets the contact key for the device to associate it with a specific contact in Marketing Cloud.

## Syntax

```dart
Future<void> setContactKey(String contactKey)
```

## Parameters

- `contactKey` (String) - The unique identifier for the contact

## Returns

- `Future<void>` - Completes when the contact key has been set.

## Example

```dart
try {
  await SfmcSdk.setContactKey('user123@example.com');
  print('Contact key set successfully');
} catch (e) {
  print('Failed to set contact key: $e');
}
```

## Related Methods

- [getContactKey()](https://developer.salesforce.com/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/flutter_getContactKey.md)
