---
title: "Quickstart: your first API call"
---

Get a token, list your subscriptions, and read one — end to end, against the demo environment.

:::note
Base URLs: `https://api.saasify.ai` (production). Test against
`https://api-demo.saasify.ai` (demo). See [Environments](/developers/environments).
:::

:::note[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](/developers/authentication). 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](/developers/authentication) for the full details.

:::code-group
```bash title="cURL"
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'])")
```
```python title="Python"
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}"}
```
```javascript title="Node"
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}` };
```
```csharp title="C#"
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](/developers/conventions): the result is inside `Data`, and you must check `Status` even on an HTTP 200.

:::code-group
```bash title="cURL"
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}'
```
```python title="Python"
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)
```
```javascript title="Node"
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);
```
```csharp title="C#"
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");
```
:::

:::tip
Paging and sorting parameters (`PageSize`, `StartIndex`, `SortColumn`, and so on) vary by endpoint — see [Pagination](/developers/conventions#pagination) and the operation's entry in the [API reference](/developers/api-reference).
:::

## 3. Read one subscription

Take a subscription ID from the list and read its detail with `GET /api/subscriptions/{subscriptionId}`.

:::code-group
```bash title="cURL"
curl -s https://api-demo.saasify.ai/api/subscriptions/SUBSCRIPTION_ID \
  -H "Authorization: Bearer $TOKEN"
```
```python title="Python"
sub_id = "SUBSCRIPTION_ID"
detail = requests.get(f"{BASE}/api/subscriptions/{sub_id}", headers=headers).json()
print(detail["Data"])
```
```javascript title="Node"
const subId = "SUBSCRIPTION_ID";
const detail = await (await fetch(`${BASE}/api/subscriptions/${subId}`,
  { headers })).json();
console.log(detail.Data);
```
```csharp title="C#"
var subId = "SUBSCRIPTION_ID";
var detailResp = await client.GetAsync($"/api/subscriptions/{subId}");
Console.WriteLine(await detailResp.Content.ReadAsStringAsync());
```
:::

## Next steps

::::cards
:::card[Report usage]{href="/developers/metering"}
Post pay-as-you-go usage from your app.
:::
:::card[Conventions]{href="/developers/conventions"}
Envelope, errors, pagination, IDs.
:::
:::card[API reference]{href="/developers/api-reference"}
Every operation, try-it on demo.
:::
:::card[Rate limits]{href="/developers/rate-limits"}
Poll gently and back off.
:::
::::
