Paytrim API Auth Documentation

This API allows you to obtain an OAuth 2.0 access token using the client credentials flow.
Paytrim uses Azure Entra as the Authentication provider. We will provide you with credentials to obtain a token. Include the token in the header as 'Bearer token' on every request to api.paytrim.com.

Endpoint

POST https://login.microsoftonline.com/common/oauth2/v2.0/token
Important Note About Tokens:

Request Parameters

Example Request

cURL
Java
Kotlin
C#
JavaScript
curl -X POST 'https://login.microsoftonline.com/common/oauth2/v2.0/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=11111111-1111-1111-1111-111111111111' \
--data-urlencode 'client_secret=your-client-secret' \
--data-urlencode 'scope=https://graph.microsoft.com/.default'
            
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class AuthExample {
    public static void main(String[] args) throws Exception {
        URL url = new URL("https://login.microsoftonline.com/common/oauth2/v2.0/token");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        connection.setDoOutput(true);

        String params = "grant_type=client_credentials" +
                        "&client_id=11111111-1111-1111-1111-111111111111" +
                        "&client_secret=your-client-secret" +
                        "&scope=https://graph.microsoft.com/.default";

        try (OutputStream os = connection.getOutputStream()) {
            byte[] input = params.getBytes(StandardCharsets.UTF_8);
            os.write(input, 0, input.length);
        }

        int responseCode = connection.getResponseCode();
        System.out.println("Response Code: " + responseCode);
    }
}
            
import java.io.OutputStream
import java.net.HttpURLConnection
import java.net.URL
import java.nio.charset.StandardCharsets

fun main() {
    val url = URL("https://login.microsoftonline.com/common/oauth2/v2.0/token")
    val connection = url.openConnection() as HttpURLConnection
    connection.requestMethod = "POST"
    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
    connection.doOutput = true

    val params = "grant_type=client_credentials" +
                 "&client_id=11111111-1111-1111-1111-111111111111" +
                 "&client_secret=your-client-secret" +
                 "&scope=https://graph.microsoft.com/.default"

    connection.outputStream.use { os: OutputStream ->
        val input = params.toByteArray(StandardCharsets.UTF_8)
        os.write(input, 0, input.size)
    }

    val responseCode = connection.responseCode
    println("Response Code: $responseCode")
}
            
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        var request = new HttpRequestMessage(HttpMethod.Post, "https://login.microsoftonline.com/common/oauth2/v2.0/token");

        var content = new StringContent("grant_type=client_credentials&client_id=11111111-1111-1111-1111-111111111111&client_secret=your-client-secret&scope=https://graph.microsoft.com/.default", Encoding.UTF8, "application/x-www-form-urlencoded");
        request.Content = content;

        var response = await client.SendAsync(request);
        var responseString = await response.Content.ReadAsStringAsync();

        Console.WriteLine(responseString);
    }
}
            
const fetch = require('node-fetch');

const url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
const params = new URLSearchParams();
params.append('grant_type', 'client_credentials');
params.append('client_id', '11111111-1111-1111-1111-111111111111');
params.append('client_secret', 'your-client-secret');
params.append('scope', 'https://graph.microsoft.com/.default');

fetch(url, {
    method: 'POST',
    body: params,
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
            

Response

{
    "token_type": "Bearer",
    "expires_in": 3599,
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGci..."
}
        

Download JSON File

This is an OpenAPI JSON file that defines the structure and details of the Auth API, including endpoints, request parameters, and responses.

Download auth.json