Authenticate as a SaaSify user to get a bearer token, then send that token with every request.
Base URLs: https://api.saasify.ai (production). Test against
https://api-demo.saasify.ai (demo). See Environments.
SaaSify uses the OAuth 2.0 resource-owner password grant. You exchange a SaaSify username and password for an opaque bearer token at POST /api/token, then send Authorization: Bearer <token> on each call. The token carries the user's tenant and role, so there are no separate API keys or scopes to manage today.
Get a token
Send a form-encoded POST to /api/token with grant_type=password and the user's username and password. Add the TenantCode header if the user belongs to more than one tenant (see Multi-tenant users).
curl -X POST https://api-demo.saasify.ai/api/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "TenantCode: YOUR_TENANT_CODE" \
--data-urlencode "grant_type=password" \
--data-urlencode "username=service-user@example.com" \
--data-urlencode "password=YOUR_PASSWORD"import requests
resp = requests.post(
"https://api-demo.saasify.ai/api/token",
headers={"TenantCode": "YOUR_TENANT_CODE"}, # optional
data={
"grant_type": "password",
"username": "service-user@example.com",
"password": "YOUR_PASSWORD",
},
)
resp.raise_for_status()
token = resp.json()["access_token"]const body = new URLSearchParams({
grant_type: "password",
username: "service-user@example.com",
password: "YOUR_PASSWORD",
});
const resp = await fetch("https://api-demo.saasify.ai/api/token", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"TenantCode": "YOUR_TENANT_CODE", // optional
},
body,
});
const { access_token: token } = await resp.json();using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post,
"https://api-demo.saasify.ai/api/token");
request.Headers.Add("TenantCode", "YOUR_TENANT_CODE"); // optional
request.Content = new FormUrlEncodedContent(new Dictionary<string, string>
{
["grant_type"] = "password",
["username"] = "service-user@example.com",
["password"] = "YOUR_PASSWORD",
});
var resp = await client.SendAsync(request);
resp.EnsureSuccessStatusCode();
using var doc = System.Text.Json.JsonDocument.Parse(
await resp.Content.ReadAsStringAsync());
var token = doc.RootElement.GetProperty("access_token").GetString();The response is a standard OAuth token payload:
{
"access_token": "a-long-opaque-token",
"token_type": "bearer",
"expires_in": 86400,
"refresh_token": "another-opaque-token",
"userName": "service-user@example.com",
"isTenantUser": true,
"onBehalfOf": null
}The token is opaque — treat it as a string, do not try to decode it. It is valid for expires_in seconds (24 hours / 1,440 minutes in the current production configuration). Store it and reuse it until it expires rather than requesting a new token on every call.
Send the token
Put the token in an Authorization: Bearer header on every request:
curl https://api-demo.saasify.ai/api/subscriptions/list \
-H "Authorization: Bearer $TOKEN"headers = {"Authorization": f"Bearer {token}"}
r = requests.get("https://api-demo.saasify.ai/api/subscriptions/list", headers=headers)const r = await fetch("https://api-demo.saasify.ai/api/subscriptions/list", {
headers: { Authorization: `Bearer ${token}` },
});client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);The tenant comes from the token, so an authenticated call usually needs only the bearer token — no extra tenant headers.
Refresh a token
When a token expires, exchange the refresh_token for a new one instead of asking the user for their password again. Use the same /api/token endpoint with grant_type=refresh_token:
curl -X POST https://api-demo.saasify.ai/api/token \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "grant_type=refresh_token" \
--data-urlencode "refresh_token=YOUR_REFRESH_TOKEN"The response has the same shape as the password-grant response, with a fresh access_token.
Multi-tenant users {#multi-tenant-users}
If a user belongs to a single tenant, you can omit TenantCode — the tenant is resolved from the user. If the user belongs to more than one tenant, send the TenantCode header to choose which tenant the token (and later requests) act in. You can get a user's tenant code from a Publisher Admin.
SSO-only tenants
SaaSify users who sign in through single sign-on (Okta, Microsoft Entra ID, Google and similar) cannot use the password grant, because they have no SaaSify password. If your tenant enforces SSO for people, you still need one local service user with a password for API access. Create it under Settings → Users as an Add local user, give it an API-appropriate role, and use its credentials with the password grant above.
What does not exist yet
- No API keys and no client-credentials grant. Authentication is always as a user.
- No OAuth scopes. Access is governed by the user's role permissions.
- No per-ISV OAuth app registration and no request signing for your calls.
These are planned. When machine credentials ship, this page will cover them. Until then, the service-user pattern above is the supported approach.