LogoLogo
  • Introduction
    • 👋Overview
    • 🤷Target Audience
    • ✨Features
  • Getting started
    • 🖥️System Requirements
    • 📦Installation
    • ⚙️Configuration
    • 🔧Setup Routine
  • Fundementals
    • 🎎Roles
    • 🌏Countries and time zones
    • ♻️Scheduletask concept
    • 💰Payment Service Provider
    • ✏️Administration
      • 🔵Sales
        • 👥Customers
        • 📥Invoices
        • 📋Plans
        • 🧊Modules
      • 🟢System
        • 🎛️System settings
        • ⛓️API Settings
        • 🌐Languages
        • 🪙Currencies
        • 🏳️Countries
        • 📂Mappings
        • 💬Translations
        • 🪧Widgets
    • 🖱️User guide
      • 🔐Customer rights
      • 🔗Customer Navigation
      • 📃Edit profile
      • 🔑Reset password
      • 🏨Edit company
      • ⚡Manage users
      • 👔Manage tenants
      • 📨View invoices
      • 💸Add payment method
      • 🪧Manage plans
      • 📦Manage modules
      • 🔔Notifications
  • Development
    • 🛠️Local development
    • 📂Folder structure
      • 🗄️Application.cfc
    • 💡Develop with saaster
      • 🎇General services
        • 💼Mappings and rigths management
        • ↩️Redirects
        • 👤Customer specific sessions
        • 〽️Global variable "getCustomerData"
      • 🌐Global functions
        • ⚙️getTrans()
        • ⚙️getAlert()
        • ⚙️logWrite()
        • ⚙️getTime()
      • 🧊Developing the main application
      • 📦Developing modules
  • API
    • ⚒️API: Get started
    • 📂Resources
      • 📄authenticate
      • 📄getCurrentModules
      • 📄getCurrentPlan
      • 📄getPlanFeatureSetting
Powered by GitBook
On this page
  1. API

API: Get started

Get started using the saaster API

PreviousDeveloping modulesNextResources

Last updated 1 year ago

The API of saaster provides the oppurtunity to use the functionality of saaster in other application. To use the API of saaster you need to create one. Follow this guide for this process:

We have chosen to use custom headers for passing additional parameters like the customerID and language etc. This approach offers a number of benefits when compared to using path parameters or query parameters. By using headers, we can add new parameters to the API without modifying the endpoint itself, making it more flexible for different use cases. Additionally, custom headers are not visible in the URL, ensuring that sensitive information such as user IDs or authentication tokens can be passed securely without being exposed in the URL. This approach also keeps the URL clean and easy to read, making it easier to understand the purpose of the endpoint.

First steps

In order to use the saaster API, you need to follow these steps:

  1. Generate an access token. Example:

    curl -X GET \
       http://localhost/api/authenticate \
       -H 'Accept: application/json' \
       -H 'apiID: 1' \
       -H 'apiKey: 1c1932d0-81da-4ad0-93bd-5ca03002f17e' \
  2. Use the access token to create a request to the saaster API. The example below fetches the current plan of a customer:

    curl -X GET \
       http://localhost/api/getPlanFeatureSetting \
       -H 'Accept: application/json' \
       -H 'Authorization: Bearer {access-token}' \
       -H 'customerID: 1' \

    Make sure to replace {access-token} with the token you received in Step 1.

CFML example:

// Change values to your API
apiID = 1
apiKey = "YourOwnKey"

// Authenticate with API and get token
cfhttp(method="get", charset="utf-8", url="http://localhost/api/authenticate", result="getToken") {
    cfhttpparam(name="Content-Type", type="header", value="application/json");
    
    // Custom saaster related header variables
    cfhttpparam(name="apiID", type="header", value="#apiID#");
    cfhttpparam(name="apiKey", type="header", value="#apiKey#");
}

token = DeserializeJSON(getToken.filecontent).token;

cfhttp(method="get", charset="utf-8", url="http://localhost/api/getPlanFeatureSetting", result="getPlanFeatureSettings") {
    
    cfhttpparam(name="Authorization", type="header", value="Bearer #token#");
    cfhttpparam(name="Content-Type", type="header", value="application/json");

    // Custom saaster related header variables
    cfhttpparam(name="settingVariable", type="header", value="YourVariableName");
    cfhttpparam(name="planID", type="header", value="1");
    cfhttpparam(name="language", type="header", value="en");
}

dump( var=getPlanFeatureSettings.filecontent, label="getPlanFeatureSettings");
⚒️
⛓️API Settings