# AsleepConfig # Initialize Config ### Asleep.initAsleepConfig() ```swift let apiKey: String = "YOUR_API_KEY" let userId: String? let baseUrl: URL? let callbackUrl: URL? let service: String? let delegate: AsleepConfigDelegate = self Asleep.initAsleepConfig(apiKey: apiKey, userId: userId, baseUrl: baseUrl, callbackUrl: callbackUrl, service: service, delegate: self) ``` | Property Name | Type | Description | | :------------ | :------------------- | :------------------------------------------------------------------------------- | | apiKey | String | Enter the value obtained from the [Generate API key](dashboard-generate-api-key) | | userId | String? | When there is no initial userId, enter nil, and later input the received userId. | | baseUrl | URL? | Enter the proxy server address. If nil, default base url is used. | | callbackUrl | URL? | Enter the URL of the server to receive sleep session analysis results. | | service | Service? | Enter the app name | | delegate | AsleepConfigDelegate | Delegate to receive results and errors | ### AsleepConfigDelegate ```swift protocol AsleepConfigDelegate { func userDidJoin(userId: String, config: Asleep.Config) func didFailUserJoin(error: Asleep.AsleepError) func userDidDelete(userId: String) } ``` 1. If success, userDidJoin() is called. | Property Name | Type | Description | | :------------ | :------------ | :---------------- | | userId | String | generated userId | | config | Asleep.Config | genearated config | 2. If failure, didFailUserJoin() is called. | Property Name | Type | Description | | :------------ | :----------------- | :----------------------------- | | error | Asleep.AsleepError | [Error Codes](ios-error-codes) | 3. userDidDelete()\ If success, all user data including the userId will be deleted. | Property Name | Type | Description | | :------------ | :----- | :------------- | | userId | String | Deleted userId | *** # Delete User ### Asleep.deleteUser() ```swift var config: Asleep.Config? if let config { Asleep.deleteUser(config: config) } ``` | Property Name | Type | Description | | :------------ | :------------ | :------------------------------- | | config | Asleep.Config | Enter the Asleep.Config instance |