> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.conversive.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.conversive.ai/_mcp/server.

# Salesforce SDK Deployment

> Deploy the Conversive Salesforce SDK from source, configure the org, and validate the installation with post-deployment API checks.

This page covers the full deployment sequence for the Conversive Salesforce SDK, including metadata deployment, org configuration, and the recommended post-deployment API validation flow.

## Deployment prerequisites

Before starting deployment, make sure:

* Salesforce CLI is installed
* The target org is authenticated
* The Git repository is cloned locally
* The deploying user has permission to deploy metadata
* The target org supports the required API version and metadata used by the SDK

## Deploy the source

### Recommended deployment command

```bash
sf project deploy start --source-dir force-app --target-org <your-org-alias>
```

Replace `<your-org-alias>` with the alias of the Salesforce org where the SDK should be deployed.

## Metadata to deploy

Deploy the full SDK metadata from the repository, including:

* Apex classes
* Apex triggers
* Custom objects
* Custom fields
* Permission sets
* Lightning or Classic layouts
* Tabs
* Remote Site Settings
* Custom settings or custom metadata used for environment configuration

## Post-deployment setup

Complete the following steps after metadata deployment.

#### Assign the required permission set

Assign the **Conversive Access** permission set to every user who needs to access the SDK.

1. Go to **Setup**
2. Search for **Permission Sets**
3. Open **Conversive Access**
4. Click **Manage Assignments**
5. Click **Add Assignments**
6. Select the required users
7. Click **Assign**

#### Update the Remote Site Setting

Update the **Conversive\_Staging\_API** Remote Site Setting so Salesforce can call the correct Conversive endpoint.

1. Go to **Setup**
2. Search for **Remote Site Settings**
3. Open **Conversive\_Staging\_API**
4. Update the URL with the correct endpoint
5. Save the record

#### Set up the environment configuration

Create or update the `Conversive_Integration_Details__c` record so the SDK has the required environment values.

Required fields:

* `Integration Name`
* `API Key`
* `Endpoint Path`

```apex
try {
    ConversiveAPI.EnvironmentSettingsResponse resp =
        ConversiveAPI.upsertEnvironmentSettings(
            'Default',
            'your-api-key',
            'https://api.beconversive.com'
        );

    System.debug('Response = ' + resp.response);
    System.debug('Message = ' + resp.responseMessage);
    System.debug('Value = ' + resp.value);
} catch (Exception e) {
    System.debug('ERROR = ' + e.getMessage());
    System.debug('STACK = ' + e.getStackTraceString());
}
```

#### Ensure sender IDs exist

Verify that valid sender records exist in `Sender_Id__c`.

> **Warning**
>
> Without valid sender IDs, outbound messaging APIs may fail.

## Post-deployment API validation

After setup is complete, validate the org with the same functional flow your deployment guide recommends.

### 1. Create a Conversive account

Run this once during onboarding if the org is not already linked to a Conversive account.

```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());
}
```

### 2. Confirm balance is available

```apex
ConversiveAPI.BalanceResponse resp =
    ConversiveAPI.getConversiveBalance();

System.debug('response = ' + resp.response);
System.debug('responseMessage = ' + resp.responseMessage);
System.debug('SMSCredits = ' + resp.SMSCredits);
System.debug('MMSCredits = ' + resp.MMSCredits);
```

### 3. Confirm plan details are available

```apex
try {
    ConversiveAPI.PlanResponse resp =
        ConversiveAPI.getConversivePlanDetails();

    System.debug('response = ' + resp.response);
    System.debug('responseMessage = ' + resp.responseMessage);
    System.debug('planDetails = ' + resp.planDetails);
} catch (Exception e) {
    System.debug('ERROR = ' + e.getMessage());
    System.debug('STACK = ' + e.getStackTraceString());
}
```

### 4. Validate plain or bulk SMS

```apex
Contact con1 = new Contact(
    LastName = 'Test Contact 1',
    MobilePhone = '9876543210'
);

Contact con2 = new Contact(
    LastName = 'Test Contact 2',
    MobilePhone = '9876543211'
);

insert new List<Contact>{ con1, con2 };

Sender_Id__c senderRec = new Sender_Id__c();
senderRec.Label__c = 'Test Sender';
senderRec.Phone__c = '9330909119';
insert senderRec;

ConversiveAPI.MessageResponse resp =
    ConversiveAPI.sendBulkSMS(
        new List<Id>{ con1.Id, con2.Id },
        'Hello, this is bulk text SMS test.',
        new List<String>{ 'MobilePhone', 'Phone' },
        senderRec.Id
    );

System.debug('response = ' + resp.response);
System.debug('responseMessage = ' + resp.responseMessage);
```

### 5. Validate MMS with text

```apex
Contact con = new Contact(
    LastName = 'Test Contact',
    MobilePhone = '9876543210'
);
insert con;

Sender_Id__c senderRec = new Sender_Id__c();
senderRec.Label__c = 'Test Sender';
senderRec.Phone__c = '9330909119';
insert senderRec;

ConversiveAPI.MessageResponse resp =
    ConversiveAPI.sendBulkMMS(
        new List<Id>{ con.Id },
        'Hello, this is MMS with text test.',
        new List<String>{ 'https://images.unsplash.com/photo-1516387938699-a93567ec168e' },
        new List<String>{ 'MobilePhone', 'Phone' },
        senderRec.Id
    );
```

### 6. Validate MMS without text

```apex
ConversiveAPI.MessageResponse resp =
    ConversiveAPI.sendBulkMMS(
        new List<Id>{ con.Id },
        '',
        new List<String>{ 'https://images.unsplash.com/photo-1516387938699-a93567ec168e' },
        new List<String>{ 'MobilePhone', 'Phone' },
        senderRec.Id
    );
```

## Verification checklist

### Functional verification

Confirm the following flows work successfully:

* Account creation
* Balance API
* Plan details API
* Message status API
* Plain text SMS
* Bulk text messaging
* MMS with text
* MMS without text
* Settings update REST endpoints

### Technical verification

Also verify the following:

* Permission set assignment completed successfully
* The Remote Site Setting contains the correct endpoint
* The integration settings record was created or updated successfully
* SDK methods can be executed through Execute Anonymous
* Apex tests pass successfully

## Recommended test sequence

1. Deploy metadata
2. Assign the permission set
3. Update the Remote Site Setting
4. Configure integration settings
5. Verify sender IDs exist
6. Run Execute Anonymous tests for individual APIs
7. Run Apex tests
8. Validate end-to-end messaging scenarios

> **Check**
>
> A deployment is complete when metadata is deployed successfully, the environment is configured correctly, sender records are available, the APIs execute without errors, Apex tests pass, and SMS and MMS validation scenarios complete successfully.