Skip to main content
The Salesmsg API

Learn more about how to do more with the Salesmsg API.

Chris Brisson avatar
Written by Chris Brisson
Updated over 2 months ago

Introducing the Salesmsg API

The Sales Message API is a powerful tool that allows you to access and manipulate the data and add Salesmsg to your custom automations. Our API is built using Postman, and offers improved response times and a wide range of new endpoints. To get more out of Salesmsg, you can use our API to do all sorts of useful things, like adding contacts, applying tags, sending messages, and more.

How to Access the API

Authentication

Our API covers multiple authentication methods:

  • PAT (Personal Access Token) authorization type is to go for in case you want to integrate your personal existing account with Salesmsg in order to extend your app’s functionality. PAT are managed by the user, which means that they are tied to a user account. This makes Personal Access Tokens a good choice for development, as well as automation purposes, when an application does only require a single Salesmessage account to manage organizations.

  • OAuth2 authorization type is to go for in case you want to allow other users to authenticate against Salesmessage in order for your app to use the issued token as well as utilize the Salesmessage’s functionality.

Personal Access Token

From your Settings page, click on the Personal Access Tokens link, then click the Create Token button to generate your unique API token.

After your link has been generated you can start testing your API using our Live API Portal.

OAuth2

If you want to configure OAuth2, go to OAuth Applications and click Create Client. For more details check our API 2.2 documentation.

Endpoints

The Salesmsg API covers all functionality of Salesmsg, including the following:

  • Contacts

  • Conversations

  • Messages

  • Saved replies

  • Broadcasts

  • And More.

All endpoints are covered in API 2.2 documentation.

API Documentation

Salesmsg Public API Usage with PAT and Swagger

This is step-by-step walkthrough of how to use the Salesmsg Public API with a personal access token and Swagger. Follow these instructions to authenticate and perform basic API operations such as retrieving conversations, messages, and sending replies.


1. Generate a Personal Access Token

  1. Login to Salesmsg:

    • Access your Salesmsg account.

  2. Navigate to Token Settings:

    • Go to Settings > Personal Access Token.

  3. Create a Token:

    • Click on Create Token.

    • Provide a name for the token (e.g., API Access Token).

    • Click Create.

  4. Copy the Token:

    • Once the token is generated, copy it for later use.


2. Access Swagger and Authorize

  1. Open Swagger:

    • Navigate to the Swagger UI page (ensure you're using version 2.2).

  2. Authorize with Token:

    • Scroll down to the Authorize button at the top of the page.

    • Paste your personal access token into the provided field.

    • Click Authorize to complete authentication.


3. Perform API Operations

a. Retrieve Conversations

  1. Find the Endpoint:

    • Locate the GET /conversations endpoint in Swagger.

  2. Test the Request:

    • Click Try it out.

    • Specify any filters (e.g., date range for messages sent/received).

    • Click Execute.

  3. View Results:

    • Review the returned data, which includes a list of conversations and their details.

b. Retrieve Messages in a Conversation

  1. Get a Conversation ID:

    • From the retrieved conversations, copy the Conversation ID.

  2. Find the Endpoint:

    • Locate the GET /conversations/{id}/messages endpoint in Swagger.

  3. Test the Request:

    • Click Try it out.

    • Paste the Conversation ID and specify parameters (e.g., the number of messages to retrieve).

    • Click Execute.

  4. View Results:

    • Review the retrieved messages, including details such as status and timestamps.

c. Send a Message

  1. Find the Endpoint:

    • Locate the POST /conversations/{id}/send endpoint in Swagger.

  2. Test the Request:

    • Click Try it out.

    • Paste the Conversation ID.

    • Enter the message content (e.g., Hello, my name is Den).

    • Click Execute.

  3. Confirm Message Sent:

    • Review the response to ensure the message was successfully sent.

d. Verify Messages Sent

  1. Retrieve Recent Messages:

    • Use the GET /conversations/{id}/messages endpoint to confirm the message appears in the conversation timeline.

  2. Execute the Request:

    • Specify the Conversation ID and click Execute.

    • Review the response to confirm the new message is listed.


4. Additional Notes

  • Use filters like date or message count to refine your requests.

  • Always test endpoints in Swagger to verify data before integrating into your application.

  • Store your personal access token securely, as it grants access to your account data.


Salesmsg Public API Usage with OAuth2 and Postman

This guide walks you through using the Salesmsg Public API with OAuth2 authorization tokens in Postman. You'll learn how to retrieve your token, import the API collection, and perform API operations like fetching conversations, retrieving messages, and sending messages.


1. Retrieve OAuth2 Token

  1. Login to Salesmsg:

    • Access your Salesmsg account and log in.

  2. Open Developer Tools:

    • Press F12 to open DevTools in your browser.

  3. Find the Token:

    • Navigate to the Application tab in DevTools.

    • Select Local Storage and locate your application storage.

    • Search for the token key in the stored data.

    • Copy the token value for use in Postman.


2. Import Salesmsg API Collection into Postman

Method 1: From Swagger JSON

  1. Retrieve Swagger JSON URL:

    • Go to Settings > Personal Access Token in Salesmsg.

    • Open the API Documentation in Swagger.

    • Copy the link to the Swagger JSON file.

  2. Import into Postman:

    • Open Postman and click Import.

    • Paste the Swagger JSON URL and click Continue.

    • Adjust settings if necessary (e.g., change folder organization from "Path" to "Text").

    • Click Import to load the collection.

  3. Verify Collection:

    • Ensure all API endpoints are visible in Postman.

Method 2: From Postman Documentation

  1. Access Postman Documentation:

    • Visit the Salesmsg website, scroll to the footer, and click the API link.

    • Scroll to the "Useful Links" section and open the Postman documentation link.

  2. Run in Postman:

    • Click Run in Postman on the documentation page.

    • Choose to open in the desktop or web version of Postman.

    • Select a workspace and click Import.

  3. Verify Collection and Environment:

    • Confirm the collection is imported. If imported via documentation, the environment variables (e.g., base URL, bearer token) are automatically set.


3. Set Environment Variables in Postman

  1. Edit Bearer Token Variable:

    • In Postman, open the imported environment.

    • Locate the Bearer Token variable.

    • Paste the copied token value into the variable field.

    • Save changes and ensure the variable is updated.

  2. Verify Base URL:

    • Confirm the Base URL variable is correct (e.g., the Salesmsg API base URL).


4. Perform API Operations

a. Retrieve Conversations

  1. Select Endpoint:

    • Locate the GET /conversations endpoint in Postman.

  2. Set Parameters:

    • Add filters, such as a date range, to retrieve specific conversations.

  3. Send Request:

    • Click Send to execute the request.

  4. View Results:

    • Review the list of conversations, including IDs and details.

b. Retrieve Messages from a Conversation

  1. Get a Conversation ID:

    • Copy the ID of a specific conversation from the results of the previous step.

  2. Select Endpoint:

    • Use the GET /conversations/{id}/messages endpoint in Postman.

  3. Set Parameters:

    • Input the Conversation ID and specify parameters (e.g., number of messages to retrieve).

  4. Send Request:

    • Click Send and review the retrieved messages.

c. Send a Message

  1. Select Endpoint:

    • Use the POST /conversations/{id}/send endpoint in Postman.

  2. Set Parameters:

    • Enter the Conversation ID.

    • Add the message body in the request payload (e.g., "Hello, how can I help you?").

  3. Send Request:

    • Click Send to execute the request.

  4. Confirm Delivery:

    • Review the response to ensure the message was successfully sent.

d. Verify Sent Messages

  1. Retrieve Recent Messages:

    • Use the GET /conversations/{id}/messages endpoint again to check for the sent message.

  2. Send Request:

    • Ensure the latest message is displayed in the response data.


5. Additional Notes

  • Use Postman's filtering options to refine API requests.

  • Keep your OAuth2 token secure, as it grants access to your account data.

  • Ensure environment variables (e.g., baseURL, bearerToken) are correctly set for seamless API operations.


Refreshing OAuth2 Tokens

To refresh an expired OAuth2 token, send a POST request to the token refresh

endpoint:

https://api.salesmessage.com/pub/v2.2/oauth/token/refresh

Request Body Parameters

Send the following parameters in a JSON object:

Parameter

Description

grant_type

Must be set to refresh_token.

client_id

Your application's client ID.

client_secret

Your application's client secret.

refresh_token

The refresh token obtained during the initial token exchange.

Example Request

POST https://api.salesmessage.com/pub/v2.2/oauth/token/refresh
Content -Type: application/json
{
"grant_type": "refresh_token",
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"refresh_token": "your_refresh_token"
}

Example Response

{
"token_type": "Bearer",
"expires_in": 3600,
"access_token": "new_access_token",
"refresh_token": "new_refresh_token"
}

Important Notes

  1. The refresh_token should be securely stored and only transmitted over secure channels (e.g., HTTPS).

  2. Always validate the response to confirm the token was successfully refreshed.

Refreshing Personal Access Tokens (PAT)

To refresh a PAT, send a POST request to the PAT refresh endpoint:

https://api.salesmessage.com/pub/v2.2/oauth/personal-token/refresh

Headers

Include the following header to authenticate the request:

Authorization: Bearer <existing_PAT>

Example Request

POST https://api.salesmessage.com/pub/v2.2/oauth/personal-token/refresh

Content-Type: application/json
Authorization: Bearer existing_PAT

Example Response

{
"token_type": "Bearer",
"expires_in": 3600,
Refreshing 2"access_token": "new_personal_access_token"
}

Frequently Asked Questions

What API functions are available?

Every functionality that is available on Salesmsg is accessible via our SMS API documentation.

Do I need a subscription to use the API?

Yes, you will need an active subscription with Salesmsg to use the API

What languages are available with the API?

We offer a wide range of languages to implement the Salesmsg API...

  • C# (.net 2.0, 3.5 or later)

  • C++ (cpprest, Qt5, Tizen)

  • Go

  • Java (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured)

  • Kotlin

  • Node.js (ES5, ES6, AngularJS with Google Closure Compiler annotations)

  • PHP

  • PowerShell

  • Python

  • R

  • Ruby

  • Rust (rust, rust-server)

  • Scala (akka, http4s, swagger-async-httpclient)

  • Swift (2.x, 3.x, 4.x, 5.x)

  • Typescript (Angular1.x, Angular2.x, Fetch, jQuery, Node)

  • And More.

What is a Team ID?

A Team ID is your Inbox ID and can be found here:

Annotation on 2024-11-08 at 13-42-34.png

Need Help? ✋🏻

Contact us on live chat or send an email to us at [email protected].

Did this answer your question?