Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    • How to Use Graph API for Outlook-Salesforce Connection
    • Enhancing Performance with File Compression in Apex
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Friday, May 16
    • Home
    • Architecture
    • Salesforce
      • News
      • Apex
      • Integration
      • Books Testimonial
    • Questions
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Integration Posts
    • Downloads
    • About Us
      • Privacy Policy
    SalesforceCodex
    Home»Salesforce»Apex»Automating data synchronization between Salesforce and Amazon Seller

    Automating data synchronization between Salesforce and Amazon Seller

    Dhanik Lal SahniBy Dhanik Lal SahniMay 15, 2023Updated:May 15, 20232 Comments9 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Automating data synchronization between Salesforce and Amazon Seller
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Salesforce has the capability to integrate with all applications that support API handshake. We can integrate with any Enterprise Resource Planning (ERP), Marketing Automation Platforms, E-commerce Platforms, Business Intelligence (BI) and Analytics Tools, Customer Support and Helpdesk Systems, Collaboration and Communication Platforms, Social Media Platforms, Document Management Systems, etc. This post will integrate Salesforce and Amazon Seller to automate data synchronization for e-commerce businesses.

    What is Amazon Seller?

    Amazon Seller is a platform provided by Amazon that allows individuals and businesses to sell their products on Amazon’s marketplace. It enables sellers to create product listings, manage orders, and handle payments for their products. Amazon Seller offers various tools and services that help sellers reach a larger audience, enhance their product listings, and optimize their sales performance.

    Business Requirement

    We need to synchronize Amazon Seller orders within Salesforce CRM so that the company can give better support to customers.

    Solution

    We can integrate the Amazon Seller platform with Salesforce using Amazon Seller Partner API. We will build batch classes to pull orders from the Amazon Seller Platform on a daily basis. This batch class then will create orders within the Salesforce platform objects.

    Limitation of Amazon Seller Partner API

    Amazon Seller Partner API will not provide complete order detail within one API call. We have to call different APIs to get complete order details. So considering this limitation we can design our solution to synchronize orders.

    For this post, we will only get basic order detail from the Amazon Seller platform. We will only pull orders with the amount and customer shipping address.

    Steps for Amazon Seller Partner API Integration

    1. Create Developer Account in Amazon Seller Central
    2. Create a User in Amazon IAM
    3. Create an Inline Policy for Amazon IAM User
    4. Create an Application for external API access
    5. Generate Refresh Token for Application
    6. Create Named Credential and External Credential
    7. Create a custom object to put order detail
    8. Create a Batch Class to sync records

    1. Create Developer Account in Amazon Seller Central

    We need an Amazon seller developer account to use its SP-API. We can register our new Amazon seller account by this link (USA region), and after we pass registration and verification we can request an upgrade to a Developer account by this link.

    Salesforce and Amazon Seller - User -SalesforceCodex

    We should put the correct information while filling out this form.

    The next step is very important as we have to choose all required access for the developer account. Based on the requirement select from available options.

    User Roles in Amazon - SalesforceCodex

    These options can be different for you based on requestor access or services opted by license. You can find details explanations about each of the roles on Github

    As a last step for registration, we have to confirm security control. This will help us in securing data in transit.

    Secuirty control in Amazon IAM - SalesforceCodex

    Based on these detail, Amazon will approve the developer account and then we can proceed with further process.

    2. Create a User in Amazon IAM

    We can access SP-API using users and roles. Role Based authentication is useful when we want to distribute our app to the world and want better control over permissions. User Based authentication is useful when we want to develop the app for our use only. It is important to choose which kind of authentication we need, based on this only we will create an application. While creating an application we have to use user/role’s generated Amazon Resource Names (ARN). For this post, I have selected User Based authentication. So let us create a user using Amazon IAM.

    To create a user in IAM, go to the Management Console’s User page. As required, we need Management Console access to perform this step. You can get this permission from Admin or ask them to perform this step.

    Open the user creation page from Management Console. User creation page URLs can be different based on the region you are in.

    User Page | Amazon Management Console - SalesforceCodex

    Provide the User name and select the option “Provide user access to the AWS Management Console – optional“ for the user as shown in the above image. For the next 2 pages just move without any changes in pages. It will take the default setting for the user and create a user. In the last step “Retrieve password“, the user’s console URL, user name and password will be shown. Copy this information for later use. You can also download user information by hitting the Download .csv file button.

    Once the user is created it will show the user ARN which we will use when the application is created.

    Amazon Resource Names (ARN) - SalesforceCodex

    User Access Key

    Once the user is created, we can create an access key which will be used when accessing data using SP-API. On the user screen, select the Security Credential tab. On this screen, you will get the Access Keys section. Create a new key for API access using a similar to the below page.

    Amazon IAM User Access Key - SalesforceCode

    It will generate an Access key and a Secret access key. Store both information for later use in the named credential in Salesforce.

    3. Create an Inline Policy for Amazon IAM User

    We can manage access in AWS by creating policies and attaching them to IAM identities (users, groups of users, or roles) or AWS resources. AWS evaluates these policies when an IAM principal (user or role) makes a request. Permissions in the policies determine whether the request is allowed or denied.

    We will create an inline policy for the above-created user.

    Amazon IAM Inline Policy - Salesforcecodex

    On the policy creation page, select the JSON tab and put below JSON code to create an inline policy.

    Review policy and give a proper name for policy creation.

    4. Create an Application for external API access

    Create an application for external API access from Apps&Services -> Develop app -> Add new application. This is required Admin user access. so if you don’t have admin access, then you can ask to create who has admin access.

    Amazon Application Creation - SalesforceCodex

    Select SP API and MWS in API Type and put the above-created user’s ARN in the IAM ARN field. Submit for app creation.

    5. Generate a Refresh Token for Application

    Once the application is created we can create a refresh token for created application. This refresh token will be used to get an access token for API calls.

    Amazon Refresh Token - SalesforceCodex

    Store generated an access token for later users. We will use this in API calls from Apex.

    6. Create Named Credential and External Credential

    We are now ready for writing an apex class to call API. We have to call 2 APIs, one for an access token and a second for the actual API call to retrieve order information.

    Let us create two external credentials and two named credentials for API calls.

    1. External Credential and Named Credential for Auth Token API call

    Create an external credential Amazon Auth Token EC with the custom authentication protocol. Create a permission set and assign an external credential. Set content type parameter as application/x-www-form-urlencoded;charset=UTF-8.

    Principals

    Create a Principal with below detail

    • Parameter Name – Named_Principle_PS
    • Sequence Number – 1
    • Identity Type – Named Principal

    Named Credentials

    Create a named credential for this external credential. Here are details for creating named credentials for auth token API calls.

    • Label – Amazon Auth Token
    • Name – AmazonAuthToken
    • URL – https://api.amazon.com/auth/o2/token
    • External Credential-Amazon Auth Token EC
    • Generate Authorization Header – selected
    Named Credential for Amazon Auth Token - SalesforceCodex

    2. External Credential and Named Credential for Order API Call

    Create another external credential for the Order SP-API call. It will be of AWS Signature Version 4 authentication type. Detail about External Credential are here

    1. Name – Amazon SP API EC (AmazonSPAPIEC)
    2. Authentication Protocol – AWS Signature Version 4
    3. Service – execute-api
    4. Region – us-east-1
    5. AWS Account ID -*************** (Put your account ID. You can get it from the top right corner of the page)

    Principals

    Create a Principal with below detail

    • Parameter Name – External Credential PS
    • Sequence Number – 1
    • Access Key – Amazon IAM user access key
    • Access Secret – Amazon IAM user secret access key

    Named Credentials

    Create a named credential for this external credential. Here are details for creating named credentials for order API calls.

    • Label -Amazon SP API
    • Name – AmazonSPAPI
    • URL – https://sellingpartnerapi-na.amazon.com/
    • External Credential- Amazon SP API EC
    • Generate Authorization Header – selected
    Named Credential for Amazon Seller API - SalesforceCodex

    7. Create a custom object to put order detail

    Create a custom object for storing order detail. These orders will be synced from Amazon Seller API. We can create an object with the name – External Order Sync. Below fields need to be created within this object.

    Field LabelField APIType
    Customer EmailCustomerEmail__cEmail
    External IdExternalId__cText(255) (External ID)
    Marketplace IdMarketplaceId__cText(255)
    Order DateOrderDate__cDate/Time
    Order StatusOrderStatus__cPicklist
    Order TotalOrderTotal__cCurrency(16, 2)
    Sync Completed?SyncCompleted__cCheckbox

    8. Create a Batch Class to sync records

    Create a batch class that will run at a specific time frame. We can choose night time around 1 PM when the system is not used by business users. This way it will not impact any running process as well.

    Apex class details that are used to create a batch class

    1. AWSSellerBatchService – Batch class to sync records using an API call. If the number of records is higher then we need to call API once again with the NextToken parameter. This will keep calling API till nextToken is null. A few parameters are mandatory like CreatedAfter, and MarketplaceIds for order API calls.
    2. AWSSellerBatchResponseHandler – This class will handle the Order API response and insert a record in a new custom object. I have stored data in the fields that I have mentioned in the above step.
    3. AWSSellerService – Apex class to get access token from Amazon Seller API.
    4. AWSToken – A wrapper class for the Access token response object.
    5. SPOrderWrapper – A wrapper class for the Order response data.
    6. MetadataHelper – This is a helper class to get metadata information.
    7. ExternalCallout – Apex helper class to call external API. You can refer to the blog Generic Apex class for Calling External System for complete detail about this class.

    I have also used the metadata setting ExternalAPISetting__mdt for storing other required information for API calls like MarketPlaceId. You can create fields and use in code as per your requirement.

    References for Salesforce and Amazon Seller Integration

    Selling Partner API Developer Guide

    Policies and permissions in IAM

    What is Amazon IAM?

    Amazon Seller Central

    Related Posts

    Use Named Credential to Upload File in S3

    Named Entity Recognition using Salesforce Einstein API

    Verify Phone using Flow HTTP Callout

    Generic Apex class for Calling External System

    amazon marketplace amazon seller amazon seller api amazon seller central amazon vendor central apex architecture batch apex batch processing rest api salesforce salesforce apex salesforce api sfdc
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleExport Data from Lightning Web Component to Excel Sheet
    Next Article Book Testimonials – Salesforce Platform Enterprise Architecture, 4th Ed
    Dhanik Lal Sahni
    • Website
    • Facebook
    • X (Twitter)

    With over 18 years of experience in web-based application development, I specialize in Salesforce technology and its ecosystem. My journey has equipped me with expertise in a diverse range of technologies including .NET, .NET Core, MS Dynamics CRM, Azure, Oracle, and SQL Server. I am dedicated to staying at the forefront of technological advancements and continuously researching new developments in the Salesforce realm. My focus remains on leveraging technology to create innovative solutions that drive business success.

    Related Posts

    By Dhanik Lal Sahni6 Mins Read

    Top 10 Salesforce Flow Features of Salesforce Summer ’25

    May 11, 2025
    By Dhanik Lal Sahni6 Mins Read

    Unlock the Power of Vibe Coding in Salesforce

    April 30, 2025
    By Dhanik Lal Sahni5 Mins Read

    How to Implement Dynamic Queueable Chaining in Salesforce Apex

    April 21, 2025
    View 2 Comments

    2 Comments

    1. Ceylan on August 8, 2023 10:33 pm

      Great coding, thank you :). Is ExternalCallout class missing here?

      Reply
      • Dhanik Lal Sahni on August 9, 2023 2:57 pm

        Hello Ceylan, It is available in post Generic Apex class for Calling External System

        Thank You,
        Dhanik

        Reply
    Leave A Reply Cancel Reply

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (110) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) code review tools (3) custom metadata types (5) design principle (9) einstein (3) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (29) Lightning web component (61) lwc (50) named credential (8) news (4) optimize apex (3) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (140) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (110) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) code review tools (3) custom metadata types (5) design principle (9) einstein (3) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (29) Lightning web component (61) lwc (50) named credential (8) news (4) optimize apex (3) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (140) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.