Mastering the SuiteCRM V8 API with Postman: A Step-by-Step Guide

Home » Mississauga Digital Agency Blog » Mastering the SuiteCRM V8 API with Postman: A Step-by-Step Guide
SuiteCRM V8 API with Postman

The SuiteCRM V8 API introduces a modern and secure way to interact with SuiteCRM using RESTful principles. In this tutorial, we’ll walk through setting up the V8 API, obtaining access tokens with Postman, and performing core operations like retrieving, adding, and updating leads.

How the V8 API Works

At its core, the SuiteCRM V8 API follows these steps:

  1. Create an API Key: Generate an OAuth2 client in SuiteCRM to define your app’s credentials.
  2. Authenticate and Retrieve Tokens: Use the client_id, client_secret, username, and password to obtain an access_token and a refresh_token.
  3. Use the Access Token: Include the access_token in your API requests to authenticate and interact with SuiteCRM.
  4. Refresh Tokens: When the access_token expires, use the refresh_token to get a new one without logging in again.

This article will guide you through:

  • Setting up the API and generating tokens.
  • Using Postman to perform essential operations, including retrieving, creating, and updating records in SuiteCRM.
    • Get a list of leads.
    • Retrieve a specific lead by ID.
    • Retrieve a specific lead by phone number.
    • Add a new lead.
    • Update an existing lead.

By the end of this guide, you’ll be equipped to leverage SuiteCRM’s V8 API to streamline your workflows and integrate with other systems.

Setting Up the SuiteCRM V8 API

Before you can use the V8 API, you need to configure your SuiteCRM instance:

Step 1: Enable the API

  1. Log into SuiteCRM as an admin.
  2. Navigate to Admin > OAuth2 Clients & Tokens.
  3. Click Create OAuth2 Client and fill out the form:
    • Client Name: YourAppName
    • Client Type: password
    • Client ID: A unique identifier (e.g., yourapp-id).
    • Client Secret: A secure string (e.g., yourapp-secret).
  4. Save the OAuth2 Client.
postman oauth2 client id

Step 2: Verify API Availability

  1. Ensure the /Api endpoint is accessible. For example:
https://yourdomain.com/Api/access_token

You should get a vaild URL but method not allowed.

SuiteCRM API method not allowed

OR ensure that you have a proper .htaccess rule that forwards the legacy to public.

  1. Test the endpoint in your browser. If you encounter issues, verify your .htaccess configuration to ensure proper URL rewriting.

Getting the Access Token

To interact with the API, you first need an access token. Here’s how to retrieve it with Postman:

Step 1: Create a New Request

  1. Open Postman and create a new request.
  2. Set the method to POST and the URL to:
https://yourdomain.com/Api/access_token

Step 2: Configure the Request

  1. In the Headers tab, set:
Content-Type: application/json
  1. Set x-www-form-urlencoded and in the Body tab, select raw and enter:
{
  "grant_type": "client_credentials",
  "client_id": "yourapp-id",
  "client_secret": "yourapp-secret"  
}
v8 api client credentials grant

Step 3: Send the Request

  1. Click Send.
  2. If successful, you’ll receive a response containing the access_token and refresh_token.

Using the Access Token

With the access token in hand, you can now perform API operations. For each request, include the token in the Authorization header like so:

Authorization: Bearer {access_token}

Performing API Operations

Example #1: Getting a List of Leads

Retrieve a paginated list of leads.

Request Details:

  • Method: GET
  • URL
https://yourdomain.com/Api/V8/module/Leads

Again note, for SuiteCRM 8.x you must put /legacy/ in the URL

  • Headers:
Authorization: Bearer {access_token}

Response: The API returns a list of leads in JSON format:

{
  "data": [
    {
      "id": "lead-id-1",
      "type": "Leads",
      "attributes": {
        "first_name": "John",
        "last_name": "Doe",
        "email1": "john.doe@example.com"
      }
    }
  ]
}
SuiteCRM API Leads

Example #2: Get a Specific Lead

Retrieve details for a single lead by ID.

Request Details:

  • Method: GET
  • URL:
https://yourdomain.com/Api/V8/module/Leads/{lead-id}
  • Headers
Authorization: Bearer {access_token}

Response:

{
  "data": {
    "id": "lead-id",
    "type": "Leads",
    "attributes": {
      "first_name": "John",
      "last_name": "Doe",
      "email1": "john.doe@example.com"
    }
  }
}
Suitecrm postman v8 api get lead by id

Example #3: Add a New Lead

Create a new lead in SuiteCRM.

Request Details:

  • Method: POST
  • URL:
https://yourdomain.com/Api/V8/module
  • Headers:
Authorization: Bearer {access_token}
  • Body (raw):
{
  "data": {
    "type": "Leads",
    "attributes": {
      "first_name": "Jane",
      "last_name": "Doe",
      "email1": "jane.doe@example.com",
      "phone_work": "123-456-7890",
      "description": "New lead created via API."
    }
  }
}

Response: The API returns the ID of the new lead:

{
  "data": {
    "id": "new-lead-id",
    "type": "Leads"
  }
}
Suitecrm v8 create lead postman

Example #4 Update an Existing Lead

Update details for an existing lead.

Request Details:

  • Method: PATCH
  • URL:
https://yourdomain.com/Api/V8/module
  • Headers
Authorization: Bearer {access_token}
  • Body
{
  "data": {
    "type": "Leads",
    "id": "lead-id",
    "attributes": {
      "phone_work": "987-654-3210",
      "description": "Updated lead details via API."
    }
  }
}

Response: The API confirms the update:

{
  "data": {
    "id": "lead-id",
    "type": "Leads",
    "attributes": {
      "phone_work": "987-654-3210",
      "description": "Updated lead details via API."
    }
  }
}
Update lead with SuiteCRM V8 API

Example #5: Retrieving a Specific Lead by Phone Number

To look up a lead by phone number, we’ll use the filter parameter in our API request.

API Request

  • Method: GET
  • URL:
https://your-suitecrm-instance/Api/V8/module/Leads?filter[phone_work][eq]=123-123-1234
  • Headers
Authorization: Bearer {{access_token}}
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

Expected Response:

{
  "data": [
    {
      "type": "Leads",
      "id": "abcd1234-5678-90ef-ghij-klmnopqrstuv",
      "attributes": {
        "first_name": "John",
        "last_name": "Doe",
        "phone_work": "123-123-1234",
        "email1": "johndoe@example.com",
        "status": "New"
      }
    }
  ]
}

If a match is found, you’ll get a JSON response containing the lead’s details. Otherwise, you’ll receive an empty data array.

This method allows you to efficiently find a lead by phone number, which is particularly useful when integrating with telephony systems or call tracking tools.

V8 Api Suitecrm get lead by phone number

Reference Table of Endpoints

PurposeMethodURLNotes
Obtain Access TokenPOST/Api/access_tokenRequired for authentication. Use client credentials.
Refresh Access TokenPOST/Api/access_tokenUse refresh token to get a new access token.
Get List of LeadsGET/Api/V8/module/LeadsRetrieves all leads.
Get Specific Lead by IDGET/Api/V8/module/Leads/{LEAD_ID}Retrieves a single lead record by ID.
Get Lead by Phone NumberGET/Api/V8/module/Leads?filter[phone_work]=NUMBERLook up a lead based on their phone number.
Create a LeadPOST/Api/V8/moduleAdds a new lead. Must send attributes in request body.
Update a LeadPATCH/Api/V8/module/Leads/{LEAD_ID}Updates fields in a lead record.
Delete a LeadDELETE/Api/V8/module/Leads/{LEAD_ID}Deletes the lead.
Get List of AccountsGET/Api/V8/module/AccountsRetrieves all accounts.
Get Specific AccountGET/Api/V8/module/Accounts/{ACCOUNT_ID}Retrieves a single account record.
Create an AccountPOST/Api/V8/moduleAdds a new account.
Update an AccountPATCH/Api/V8/module/Accounts/{ACCOUNT_ID}Updates fields in an account record.
Delete an AccountDELETE/Api/V8/module/Accounts/{ACCOUNT_ID}Deletes the account.
Get List of ContactsGET/Api/V8/module/ContactsRetrieves all contacts.
Get Specific ContactGET/Api/V8/module/Contacts/{CONTACT_ID}Retrieves a single contact record.
Create a ContactPOST/Api/V8/moduleAdds a new contact.
Update a ContactPATCH/Api/V8/module/Contacts/{CONTACT_ID}Updates fields in a contact record.
Delete a ContactDELETE/Api/V8/module/Contacts/{CONTACT_ID}Deletes the contact.
Get Related RecordsGET/Api/V8/module/{MODULE}/{ID}/relationships/{RELATED_MODULE}Fetches related records for a given module.
Add Related RecordPOST/Api/V8/module/{MODULE}/{ID}/relationshipsLinks related records.
Remove Related RecordDELETE/Api/V8/module/{MODULE}/{ID}/relationships/{RELATED_MODULE}/{RELATED_ID}Unlinks a related record.
Get List of NotesGET/Api/V8/module/NotesRetrieves all notes.
Get Specific NoteGET/Api/V8/module/Notes/{NOTE_ID}Retrieves a specific note.
Create a NotePOST/Api/V8/moduleAdds a new note. Can be related to another module.
Update a NotePATCH/Api/V8/module/Notes/{NOTE_ID}Updates an existing note.
Delete a NoteDELETE/Api/V8/module/Notes/{NOTE_ID}Deletes a note.
Attach a File to a NotePOST/Api/V8/module/Notes/{NOTE_ID}/fileUploads a file as an attachment to the note.
Get List of DocumentsGET/Api/V8/module/DocumentsRetrieves all documents.
Get Specific DocumentGET/Api/V8/module/Documents/{DOCUMENT_ID}Retrieves a specific document.
Upload a File to DocumentPOST/Api/V8/module/Documents/{DOCUMENT_ID}/fileAttaches a file to a document.

Conclusion

The SuiteCRM V8 API offers a robust way to interact with your CRM, enabling powerful integrations and customizations for SutieCRM Developement. In this guide, you’ve learned how to:

  • Configure the V8 API for your SuiteCRM instance.
  • Use Postman to authenticate and perform API requests.
  • Manage leads through the API with real-world examples.

If you’re looking for help integrating SuiteCRM into your workflows or building custom solutions, contact me for expert SuiteCRM development and consulting.

Stay tuned for the next part of this series, where we’ll explore the SuiteCRM GraphQL API for even more possibilities!

What’s your experience with SuiteCRM’s APIs? Share your thoughts in the comments below.

About the Author