> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.conversive.ai/api-sdk-docs/salesforce-sdk/create-conversive-account/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.conversive.ai/_mcp/server. # Create a Conversive Account > Provision a new Conversive account from Salesforce and inspect the detailed job payload returned by the SDK. Use `createConversiveAccount()` during onboarding when the org is not yet linked to an existing Conversive account. ## What this API does If successful, this method: * provisions a new Conversive account * returns a response wrapper with status information * includes a detailed `value` payload * sends an email to the **logged-in user’s email address** with the API key That API key is then used in `upsertEnvironmentSettings()`. ## Method signature ```apex public static ConversiveAPI.ConversiveAPIResponse createConversiveAccount() ``` ## Inputs This API takes **no input parameters**. ## Response type ```apex public class ConversiveAPIResponse { public String response; // SUCCESS / ERROR public String responseMessage; // Human-readable message public Object value; // Result returned from account creation } ``` ## Response fields | Field | Type | Description | | ----------------- | -------- | ----------------------------------------------------------------------- | | `response` | `String` | Indicates success or failure | | `responseMessage` | `String` | Human-readable outcome | | `value` | `Object` | Serialized JSON payload containing detailed account creation job output | ## `value` payload structure The Confluence page documents the `value` field as serialized JSON with these fields: | Field | Description | | ------------------ | -------------------------------------------------------------------------- | | `jobType` | Job type executed. For this API, the documented value is `CREATE_ACCOUNT`. | | `success` | Whether account creation succeeded at the service level | | `statusCode` | HTTP or service status code | | `responseCode` | Platform-specific response code | | `message` | Human-readable service message | | `accountId` | Newly created Conversive account ID | | `userId` | User ID associated with the created account | | `accessToken` | Access token, if returned | | `refreshToken` | Refresh token, if returned | | `resendAccessCode` | Resend or access code reference, if returned | | `rawBody` | Raw response body returned by the platform | ## Example ```apex try { ConversiveAPI.ConversiveAPIResponse resp = ConversiveAPI.createConversiveAccount(); System.debug('response = ' + resp.response); System.debug('responseMessage = ' + resp.responseMessage); System.debug('value = ' + resp.value); } catch (Exception e) { System.debug('ERROR = ' + e.getMessage()); System.debug('STACK = ' + e.getStackTraceString()); } ``` ## Example success response ```apex response = 'SUCCESS' responseMessage = 'Conversive account created successfully' ``` ### Example `value` payload ```json { "jobType": "CREATE_ACCOUNT", "success": true, "statusCode": 200, "responseCode": "SUCCESS", "message": "Account created successfully", "accountId": 12345, "userId": 67890, "accessToken": "sample-access-token", "refreshToken": "sample-refresh-token", "resendAccessCode": "ABC123", "rawBody": "{...}" } ``` ## Example error response ```apex response = 'ERROR' responseMessage = 'Unable to create Conversive account' ``` ## Error handling guidance ### Documented error behavior The page documents the following error pattern: * `response = 'ERROR'` * `responseMessage` explains the failure * `value` may still contain diagnostic fields such as: * `statusCode` * `responseCode` * `message` * `rawBody` ### What a developer should do * inspect both `responseMessage` and `value` * log the raw `value` payload during troubleshooting * confirm the logged-in user has a valid email address * check the inbox of the logged-in user for the API key email after success ## Recommended onboarding flow #### Deploy the SDK Make sure metadata is deployed and the org is ready for setup. #### Call createConversiveAccount() Run this only if the org is not already linked to a Conversive account. #### Check the user’s email The API key is delivered to the logged-in user’s email address. #### Save environment settings Call `upsertEnvironmentSettings()` with the received API key and the correct endpoint. #### Verify setup Call `getConversiveBalance()` or `getConversivePlanDetails()` to confirm the environment is working. ## Best practices * call this method once per org onboarding flow * do not call it repeatedly if the account already exists * keep the returned `value` payload for diagnostics * configure the environment immediately after receiving the API key > Provision a new Conversive account from Salesforce and inspect the detailed job payload returned by the SDK.