top of page
  • Writer's pictureForceLocker

How to get login Token for REST and SOAP SFMC API calls

Updated: May 7, 2023

For the execution of any API operation on SFMC, the calling system needs to be authenticated by SFMC.





There are two ways to authenticate for API calls

  1. Using Username and Password

  2. Using Login Token

I don't prefer a username and password because:

  1. It is not a good practice to expose or keep a username and password in the code. Anyone who has access to the code can possibly copy and use the credentials

  2. Most implementation has SSO where authentication is done on ADFS / SSO server. Thus users don't need Username and password to log in. Thus don't know the username or password

Thus mostly we use Login and Refresh tokens for API access. Today we will see how to get a login token. We will use PostMan for this blog


Prerequisites :

You will need to set up an install app in SFMC with the right permission. From the app, make a note of the Client Id and Client Secret keys

This link provides salesforce documentation on the installed app.


Once you have the client app details, you can setup PostMan to get a login Token :


  1. The URL end point of the web request :

It's a post request. The hidden part would be your tenant Id . The service router is v2/token as seen above


2. Next you need to have the right request headers :




These are mostly standard for SFMC


3. The final part is your payload :


You need to replace the client id noted from the install app with "client_id" tag. And client secret values from the install app to "client_secret" variable.


Thats it. Now execute the request and your will get the token and other related info. Below is the response from login request

There is one bonus giveaway.


Suppose you are doing multiple soap or rest calls. you will need to replace the token value from the above API call in those. I wanted to ease it a bit. So that you don't need to copy values anymore.


In PostMan -- Environment, create a new variable by the name "Token". The below images shows some sample Postman variables :


Suppose the last variable in the above image was "Token".


Now in the login Token Api call, we will update the environment variable Token. Once updated we can use it programmatically in any soap or rest call like {{Token}}


In the Login API request, under the Test section insert the following code :


when the login API finishes, the Test section will be executed. This action will update the environment variable "Token"


That's it. Enjoy SFMC.

31 views0 comments
bottom of page