Get a token, list your subscriptions, and read one — end to end, against the demo environment.
Base URLs: https://api.saasify.ai (production). Test against
https://api-demo.saasify.ai (demo). See Environments.
Before you start
You need: a SaaSify user with a local password in the demo environment, and a role that can read subscriptions. Use a dedicated service user. If your tenant enforces SSO, create a local service user first.
This walkthrough uses https://api-demo.saasify.ai. Swap in https://api.saasify.ai when you go live.
1. Get a token
Exchange your username and password for a bearer token at POST /api/token. See Authentication for the full details.
TOKEN=$(curl -s -X POST https://api-demo.saasify.ai/api/token \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "grant_type=password" \
--data-urlencode "username=service-user@example.com" \
--data-urlencode "password=YOUR_PASSWORD" \
| python3 -c "import sys,json;print(json.load(sys.stdin)['access_token'])")import requests
BASE = "https://api-demo.saasify.ai"
tok = requests.post(f"{BASE}/api/token", data={
"grant_type": "password",
"username": "service-user@example.com",
"password": "YOUR_PASSWORD",
})
tok.raise_for_status()
token = tok.json()["access_token"]
headers = {"Authorization": f"Bearer {token}"}const BASE = "https://api-demo.saasify.ai";
const tok = await fetch(`${BASE}/api/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "password",
username: "service-user@example.com",
password: "YOUR_PASSWORD",
}),
});
const { access_token: token } = await tok.json();
const headers = { Authorization: `Bearer ${token}` };const string BASE = "https://api-demo.saasify.ai";
using var client = new HttpClient { BaseAddress = new Uri(BASE) };
var tokResp = await client.PostAsync("/api/token",
new FormUrlEncodedContent(new Dictionary<string, string>
{
["grant_type"] = "password",
["username"] = "service-user@example.com",
["password"] = "YOUR_PASSWORD",
}));
tokResp.EnsureSuccessStatusCode();
using var tokDoc = System.Text.Json.JsonDocument.Parse(
await tokResp.Content.ReadAsStringAsync());
var token = tokDoc.RootElement.GetProperty("access_token").GetString();
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);2. List subscriptions
Send the token to POST /api/subscriptions/list. Remember the SaaSify envelope: the result is inside Data, and you must check Status even on an HTTP 200.
curl -s -X POST https://api-demo.saasify.ai/api/subscriptions/list \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"PageSize": 10, "StartIndex": 1}'resp = requests.post(f"{BASE}/api/subscriptions/list",
headers=headers,
json={"PageSize": 10, "StartIndex": 1})
payload = resp.json()
if payload["Status"] != "SUCCESS":
raise RuntimeError(payload.get("ErrorMessage"))
subscriptions = payload["Data"]
print(subscriptions)const listResp = await fetch(`${BASE}/api/subscriptions/list`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ PageSize: 10, StartIndex: 1 }),
});
const payload = await listResp.json();
if (payload.Status !== "SUCCESS") throw new Error(payload.ErrorMessage);
const subscriptions = payload.Data;
console.log(subscriptions);var listResp = await client.PostAsync("/api/subscriptions/list",
new StringContent("{\"PageSize\":10,\"StartIndex\":1}",
System.Text.Encoding.UTF8, "application/json"));
using var listDoc = System.Text.Json.JsonDocument.Parse(
await listResp.Content.ReadAsStringAsync());
if (listDoc.RootElement.GetProperty("Status").GetString() != "SUCCESS")
throw new Exception(listDoc.RootElement.GetProperty("ErrorMessage").GetString());
var data = listDoc.RootElement.GetProperty("Data");3. Read one subscription
Take a subscription ID from the list and read its detail with GET /api/subscriptions/{subscriptionId}.
curl -s https://api-demo.saasify.ai/api/subscriptions/SUBSCRIPTION_ID \
-H "Authorization: Bearer $TOKEN"sub_id = "SUBSCRIPTION_ID"
detail = requests.get(f"{BASE}/api/subscriptions/{sub_id}", headers=headers).json()
print(detail["Data"])const subId = "SUBSCRIPTION_ID";
const detail = await (await fetch(`${BASE}/api/subscriptions/${subId}`,
{ headers })).json();
console.log(detail.Data);var subId = "SUBSCRIPTION_ID";
var detailResp = await client.GetAsync($"/api/subscriptions/{subId}");
Console.WriteLine(await detailResp.Content.ReadAsStringAsync());