Before writing APEX code, please install the ShipAutomate package here. (sandbox install).

Bulk Domestic Shipments

// collect record ids
Id shippingPrefId = 'a05A000000JyQyQ';
Id contactId = '003A000000GMEY5';

zkusps__ShippingPreference__c shipmatePref = [
SELECT zkusps__companyName__c, zkusps__shippingCity__c,
  zkusps__shippingSenderEmailDefault__c, zkusps__shippingSenderPhoneDefault__c,
  zkusps__shippingState__c, zkusps__shippingStreet__c, zkusps__shippingPostalCode__c,
  zkusps__shippingSenderNameDefault__c,
  zkusps__labelImageTypeDefault__c, zkusps__preference__c
FROM zkusps__ShippingPreference__c
WHERE Id = :shippingPrefId];

// 1. zkusps__BulkShipment__c object
zkusps__BulkShipment__c bulkShipment = new zkusps__BulkShipment__c (
zkusps__BillingPreference__c = shipmatePref.zkusps__preference__c
);
insert bulkShipment;

// Get Contact
Contact con = [
SELECT MailingCity, Account.Name, MailingCountry,
 Email, FirstName, LastName,
Phone, MailingState, MailingStreet,
  MailingPostalCode
FROM Contact
WHERE Id = :contactId];

// 2. zkusps__QueuedShipment__c object
zkusps__QueuedShipment__c queuedShipment = new zkusps__QueuedShipment__c (
zkusps__BulkShipment__c = bulkShipment.Id,
zkusps__LabelImageType__c = 'PNG',
zkusps__ServiceType__c = 'Domestic: Priority',
zkusps__PackagingType__c = 'Regional Rate Box A',

// sender info
zkusps__SenderName__c = shipmatePref.zkusps__shippingSenderNameDefault__c,
zkusps__SenderCity__c = shipmatePref.zkusps__shippingCity__c,
zkusps__SenderCompany__c = shipmatePref.zkusps__companyName__c,
zkusps__SenderEmail__c = shipmatePref.zkusps__shippingSenderEmailDefault__c,
zkusps__SenderPhone__c = shipmatePref.zkusps__shippingSenderPhoneDefault__c,
zkusps__SenderState__c = shipmatePref.zkusps__shippingState__c,
zkusps__SenderStreet__c = shipmatePref.zkusps__shippingStreet__c,
zkusps__SenderPostalCode__c = shipmatePref.zkusps__shippingPostalCode__c,

// recipient info
zkusps__RecipientName__c = con.FirstName + ' ' + con.LastName,
zkusps__RecipientCity__c = con.MailingCity,
zkusps__RecipientCompany__c = con.Account.Name,
zkusps__RecipientCountry__c = con.MailingCountry,
zkusps__RecipientEmail__c = con.Email,
zkusps__RecipientPhone__c = '2125551234',
zkusps__RecipientState__c = con.MailingState,
zkusps__RecipientStreet__c = con.MailingStreet,
zkusps__RecipientPostalCode__c = con.MailingPostalCode,
zkusps__Contact__c = con.Id

);
insert queuedShipment;
// 3. zkusps__QueuedPackage__c object
zkusps__QueuedPackage__c queuedPackage = new zkusps__QueuedPackage__c (
zkusps__DeclaredValue__c = 1,
zkusps__WeightPounds__c = 0,
zkusps__WeightOunces__c = 2,
zkusps__Height__c = 1,
zkusps__Length__c = 1,
zkusps__Width__c = 1,
zkusps__QueuedShipment__c = queuedShipment.Id          
);
insert queuedPackage;

// validation
// String batchId = zkusps.BulkShipmentInterface.validateBulkShipment(bulkShipment.Id);
String batchId = zkusps.BulkShipmentInterface.processBulkShipment(bulkShipment.Id);
System.debug('BATCH ID :' + batchId);
Did this answer your question?