Salesforce APIs are a powerful way to interact with Salesforce data programmatically. One of the simplest ways to connect an external tool like Postman to Salesforce is by using the Username-Password Flow. This article will walk you through the step-by-step process, making it easy to grasp even for beginners. By the end, you’ll know how to connect Postman to Salesforce and use the generated token to call Salesforce APIs.
What Is the Username-Password Flow?
The Username-Password Flow is an authentication method where you provide your Salesforce username, password, and a security token to obtain an access token. This access token is then used to make authorized API requests to Salesforce.
Step-by-Step Guide to Connect Postman to Salesforce Using Username Password Flow
Here’s a simple process to set up Postman and connect it to Salesforce:
Step 1: Create a Connected App in Salesforce
Before connecting Postman, you need to create a Connected App in Salesforce.
- Log in to your Salesforce account.
- Navigate to Setup → App Manager → Click New Connected App.
- Provide a name (e.g., “Postman Integration”).
- Enable OAuth Settings:
- Check the box for Enable OAuth Settings.
- Add a callback URL (e.g.,
http://localhost
). - Select the OAuth Scopes you need (web, API, refresh_token, full_access).
- Save the connected app and note the Consumer Key and Consumer Secret. These will be used in Postman.
Step 2: Set Up Postman to Authenticate with Salesforce
Now let’s configure Postman to authenticate with Salesforce.
2.1 Postman Request Format
- Open Postman and create a new request.
- Set the request type to POST.
- Enter the Salesforce authentication endpoint as the URL:
https://login.salesforce.com/services/oauth2/token
If you’re using a sandbox environment, replacelogin
withtest
:https://test.salesforce.com/services/oauth2/token
- In the Params tab enter the following key-value pairs:
grant_type
:password
client_id
: The Consumer Key from your Salesforce connected app.client_secret
: The Consumer Secret from your Salesforce connected app.username
: Your Salesforce username (e.g.,yourname@company.com
).password
: Your Salesforce password combined with the security token (e.g.,PasswordSecurityToken
).

Example of Body Parameters:
Key | Value |
---|---|
grant_type | password |
client_id | Your Salesforce Consumer Key |
client_secret | Your Salesforce Consumer Secret |
username | Your Salesforce username |
password | Your password + security token |
- Click Send.
Step 3: Use the Generated Token to Call Salesforce APIs
What Happens Next?
If your request is successful, Salesforce will respond with a JSON object containing an access token. Here’s an example response:
{
"access_token": "00Dxx0000001gP7!AQ4AQNt9z...6El",
"instance_url": "https://yourInstance.salesforce.com",
"id": "https://login.salesforce.com/id/00Dxx0000001gP7EAI/005xx000001SvpgAAC",
"token_type": "Bearer",
"issued_at": "1699234739000",
"signature": "kFkKNb9KE6....g=="
}
Save the Access Token:
- Copy the value of
access_token
. - Note the
instance_url
, as you’ll need it to make API calls.
Make an API Call:
- Create a new request in Postman.
- Set the request type to GET (or other types based on your use case).
- Enter the API endpoint using the
instance_url
from the response. For example:https://yourInstance.salesforce.com/services/data/v57.0/sobjects/Account
- Go to the Headers tab and add the following key-value pair:
Authorization
:Bearer <access_token>
Example Header:
Key | Value |
---|---|
Authorization | Bearer 00Dxx0000001gP7!AQ4AQNt9z…6El |
- Click Send to see the response.
Troubleshooting Tips
- Invalid Token: Ensure your username, password, and security token are correct.
- Invalid Client Credentials: Double-check the Consumer Key and Consumer Secret.
- API Not Enabled: Ensure that the connected app has the required OAuth scopes.
- Instance URL Issues: Always use the
instance_url
returned in the authentication response.
Summary
Connecting Postman to Salesforce using the Username-Password Flow is straightforward:
- Set up a connected app in Salesforce.
- Configure Postman with the required authentication details.
- Use the access token to make API calls.
This process allows you to interact with Salesforce APIs effortlessly and is especially helpful for debugging and testing. By mastering these steps, you’re taking a significant step toward becoming proficient in Salesforce API integration.