How to clean up unused licenses automatically
Licenses cost money every month, and in larger teams some of them end up with people who left or stopped using Sally. This guide shows how to find those members through the API, take their license away and then reduce the subscription so that you only pay for what is assigned. At the end there is a complete script you can run on a schedule.
You need a token of an owner or admin of the company account, because only they may read the usage and change licenses, exactly as in Sally. Every example works as it stands once SALLY_TOKEN and DIRECTORY_ID are set, see the Quickstart.
Quick navigation
- Find members who don't use their license
- Take a license away
- Check the license statistics
- Reduce the subscription
- Complete clean-up script
- Endpoints at a glance
If a reseller partner manages your company account, the partner books the licenses. The subscription endpoints then answer 409 MANAGED_BY_RESELLER_PARTNER. Taking licenses away from members still works.
1. Find members who don't use their license
GET/v1.0/directories/{directoryId}/memberships/usage returns the same numbers as the Usage tab of the user management in Sally: per member the last sign-in, the transcribed meetings and uploads and the minutes, for the period you choose. It takes these query parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
period | string | last30 | last7, last30, last90, last365 or all. |
page | integer | 1 | Page number, starting at 1. |
pageSize | integer | 25 | Entries per page, at most 100. |
fields | string | Comma-separated list of the fields to return, see Field selection. |
This request loads the usage of the last 90 days:
- cURL
- JavaScript
- Python
curl "https://api.sally.io/v1.0/directories/$DIRECTORY_ID/memberships/usage?period=last90&pageSize=100" \
-H "Authorization: Bearer $SALLY_TOKEN"
const url = new URL(`https://api.sally.io/v1.0/directories/${process.env.DIRECTORY_ID}/memberships/usage`);
url.searchParams.set('period', 'last90');
url.searchParams.set('pageSize', '100');
const response = await fetch(url, {
headers: {Authorization: `Bearer ${process.env.SALLY_TOKEN}`},
});
const usage = await response.json();
import os
import requests
response = requests.get(
f"https://api.sally.io/v1.0/directories/{os.environ['DIRECTORY_ID']}/memberships/usage",
params={"period": "last90", "pageSize": 100},
headers={"Authorization": f"Bearer {os.environ['SALLY_TOKEN']}"},
)
usage = response.json()
{
"page": 1,
"pageSize": 100,
"total": 2,
"hasMore": false,
"period": "last90",
"items": [
{
"userId": "11f967df-7dd1-4719-a9aa-46530940c443",
"roleId": "164531fc-9be4-4de4-a183-89cc85d6a98c",
"licenseId": "f5f084e9-b993-425f-ad36-bfd5dc3f0e65",
"isBlocked": false,
"lastLoginOn": "2026-11-20T08:12:40Z",
"transcribedMeetingsCount": 23,
"transcribedUploadedRecordingsCount": 2,
"transcribedMinutes": 1240,
"usedQuotaMinutes": 610
},
{
"userId": "8a0c2f7e-3b51-4d2a-9c6e-7f14b2d0e935",
"roleId": "164531fc-9be4-4de4-a183-89cc85d6a98c",
"licenseId": "f5f084e9-b993-425f-ad36-bfd5dc3f0e65",
"isBlocked": false,
"lastLoginOn": "2026-07-03T14:55:02Z",
"transcribedMeetingsCount": 0,
"transcribedUploadedRecordingsCount": 0,
"transcribedMinutes": 0,
"usedQuotaMinutes": 0
}
]
}
| Field | Type | Description |
|---|---|---|
userId | string | Id of the member. |
roleId | string | Role in the company account, resolve it via GET /v1.0/roles. |
licenseId | string | null | License of the member, resolve it via GET /v1.0/licenses. |
isBlocked | boolean | Whether the member is blocked. |
lastLoginOn | string | null | Last sign-in to Sally (ISO-8601, UTC), null if the member never signed in. |
transcribedMeetingsCount | number | Recorded meetings with a transcript in the period that the member took part in. |
transcribedUploadedRecordingsCount | number | Uploaded recordings with a transcript in the period. |
transcribedMinutes | number | Minutes of those recordings. A recording counts for every participant, so don't add this up across members. |
usedQuotaMinutes | number | Transcription quota used in the period. Every recording counts once, so this one can be added up. |
Which member counts as inactive is your decision. A rule that works well: no sign-in for 60 days, or never, and no transcribed meeting or upload in the last 90 days. The member list also carries lastLoginOn, see GET/v1.0/directories/{directoryId}/memberships/users, so you can show names next to the ids.
2. Take a license away
PATCH/v1.0/directories/{directoryId}/memberships/{userId} changes the license, role or block of a member, with the same rules as the user management in Sally. To take a license away, set the license None. The member stays in the company account and keeps their data, they just can't record any more. Look up the id of None once with GET/v1.0/licenses.
| Field | Type | Description |
|---|---|---|
licenseId | string | New license. The license None takes the license away. |
roleId | string | New role. Only owners may change roles. |
isBlocked | boolean | Block or unblock the member. |
Send only the fields you want to change:
- cURL
- JavaScript
- Python
curl -X PATCH "https://api.sally.io/v1.0/directories/$DIRECTORY_ID/memberships/$USER_ID" \
-H "Authorization: Bearer $SALLY_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"licenseId\": \"$NONE_LICENSE_ID\"}"
const response = await fetch(
`https://api.sally.io/v1.0/directories/${process.env.DIRECTORY_ID}/memberships/${userId}`,
{
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.SALLY_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({licenseId: noneLicenseId}),
},
);
const membership = await response.json();
response = requests.patch(
f"https://api.sally.io/v1.0/directories/{os.environ['DIRECTORY_ID']}/memberships/{user_id}",
json={"licenseId": none_license_id},
headers={"Authorization": f"Bearer {os.environ['SALLY_TOKEN']}"},
)
membership = response.json()
{
"directoryId": "5daeda15-8fc7-4693-a1e1-13119cceb461",
"userId": "8a0c2f7e-3b51-4d2a-9c6e-7f14b2d0e935",
"roleId": "164531fc-9be4-4de4-a183-89cc85d6a98c",
"licenseId": "0d3e7a91-5c24-4b8f-a6e2-9f1b4c7d2e58",
"isBlocked": false
}
The change appears in the audit log like a change in Sally, marked as made through the Public API. These answers mean something specific:
| Status | code | What to do |
|---|---|---|
400 | There is no free license in the tier you assign. Only relevant when you give a license, not when you take one away. | |
403 | ADMIN_ONLY_MEMBERS | The token belongs to neither an owner nor an admin. |
403 | MEMBER_IS_SCIM_MANAGED | The member is managed through SCIM. Change the license in your identity provider. |
403 | OWNER_PROTECTED | The change would affect an owner. Skip this member. |
404 | USER_NOT_MEMBER | The user is not a member of this company account. |
3. Check the license statistics
A license you take away is free, but you keep paying for it until you reduce the subscription. GET/v1.0/directories/{directoryId}/license-statistics shows per tier how many licenses are available, assigned and free, computed exactly like the Billing page in Sally:
- cURL
- JavaScript
- Python
curl "https://api.sally.io/v1.0/directories/$DIRECTORY_ID/license-statistics" \
-H "Authorization: Bearer $SALLY_TOKEN"
const response = await fetch(
`https://api.sally.io/v1.0/directories/${process.env.DIRECTORY_ID}/license-statistics`,
{headers: {Authorization: `Bearer ${process.env.SALLY_TOKEN}`}},
);
const statistics = await response.json();
response = requests.get(
f"https://api.sally.io/v1.0/directories/{os.environ['DIRECTORY_ID']}/license-statistics",
headers={"Authorization": f"Bearer {os.environ['SALLY_TOKEN']}"},
)
statistics = response.json()
{
"hasIndividualContract": false,
"starter": {
"individualContract": {"totalCount": 0, "assignedCount": 0, "freeCount": 0},
"subscription": {"totalCount": 25, "assignedCount": 21, "freeCount": 4}
},
"pro": {
"individualContract": {"totalCount": 0, "assignedCount": 0, "freeCount": 0},
"subscription": {"totalCount": 3, "assignedCount": 3, "freeCount": 0}
},
"enterprise": {
"individualContract": {"totalCount": 0, "assignedCount": 0, "freeCount": 0},
"subscription": {"totalCount": 0, "assignedCount": 0, "freeCount": 0}
}
}
Every tier is split into two sources. individualContract holds licenses from an individual contract with Sally, subscription those from the online subscription. Assigned licenses fill the individual contract first, so subscription.assignedCount is exactly the lowest number you can reduce the subscription to. In the example, four Starter licenses are free and can go.
4. Reduce the subscription
First load the subscriptions with GET/v1.0/directories/{directoryId}/subscriptions to get the subscriptionId of the running one:
- cURL
- JavaScript
- Python
curl "https://api.sally.io/v1.0/directories/$DIRECTORY_ID/subscriptions" \
-H "Authorization: Bearer $SALLY_TOKEN"
const response = await fetch(
`https://api.sally.io/v1.0/directories/${process.env.DIRECTORY_ID}/subscriptions`,
{headers: {Authorization: `Bearer ${process.env.SALLY_TOKEN}`}},
);
const {items: subscriptions} = await response.json();
response = requests.get(
f"https://api.sally.io/v1.0/directories/{os.environ['DIRECTORY_ID']}/subscriptions",
headers={"Authorization": f"Bearer {os.environ['SALLY_TOKEN']}"},
)
subscriptions = response.json()["items"]
Then send the new target per tier to PATCH/v1.0/directories/{directoryId}/subscriptions/{subscriptionId}. Send only the tiers that change. A reduction needs no acceptTerms, that is only required for an increase:
- cURL
- JavaScript
- Python
curl -X PATCH "https://api.sally.io/v1.0/directories/$DIRECTORY_ID/subscriptions/$SUBSCRIPTION_ID" \
-H "Authorization: Bearer $SALLY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"starterLicensesCount": 21}'
const response = await fetch(
`https://api.sally.io/v1.0/directories/${process.env.DIRECTORY_ID}/subscriptions/${subscriptionId}`,
{
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.SALLY_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({starterLicensesCount: 21}),
},
);
const subscription = await response.json();
response = requests.patch(
f"https://api.sally.io/v1.0/directories/{os.environ['DIRECTORY_ID']}/subscriptions/{subscription_id}",
json={"starterLicensesCount": 21},
headers={"Authorization": f"Bearer {os.environ['SALLY_TOKEN']}"},
)
subscription = response.json()
{
"subscriptionId": "77e63339-474b-468f-a6b0-99e59513cd75",
"billingInterval": "monthly",
"status": "active",
"starterLicensesCount": 25,
"proLicensesCount": 3,
"enterpriseLicensesCount": 0,
"currentPeriodEnd": "2026-12-14T09:30:00Z",
"trialEndsOn": null,
"isCanceled": false,
"scheduledChange": {
"starterLicensesCount": 21,
"proLicensesCount": 3,
"enterpriseLicensesCount": 0,
"effectiveOn": "2026-12-14T09:30:00Z"
}
}
A reduction works like in Sally:
- It takes effect at the end of the current period, without a credit. Until then the old number stays, and the new one shows up in
scheduledChange. During a trial it applies at once. - Never below the assigned licenses. A target below
subscription.assignedCountanswers409 BELOW_ASSIGNED_LICENSESwith the tier and the minimum. Take the licenses away from members first, as in step 2. - A new target replaces the scheduled one. Sending the current number or a higher one removes the scheduled reduction.
Increasing works the same way with acceptTerms: true and is charged right away. All rules, including tier switches and bank confirmation, are listed on PATCH/v1.0/directories/{directoryId}/subscriptions/{subscriptionId}.
5. Complete clean-up script
The script combines the four steps. It finds members without a sign-in for INACTIVE_DAYS days and without any transcribed meeting or upload in the last 90 days, takes their license away and reduces the running subscription to the licenses still assigned. It only reads by default and prints what it would do. Set DRY_RUN=false once the list looks right.
- JavaScript
- Python
// Node 18 or newer: node clean-up-licenses.mjs
const BASE = `https://api.sally.io/v1.0/directories/${process.env.DIRECTORY_ID}`;
const INACTIVE_DAYS = Number(process.env.INACTIVE_DAYS ?? 60);
const DRY_RUN = process.env.DRY_RUN !== 'false';
const headers = {Authorization: `Bearer ${process.env.SALLY_TOKEN}`, 'Content-Type': 'application/json'};
async function call(method, url, body) {
const response = await fetch(url, {method, headers, body: body && JSON.stringify(body)});
const data = response.status === 204 ? null : await response.json();
if (!response.ok) {
const error = new Error(`${method} ${url}: ${response.status} ${data?.code ?? ''} ${data?.message ?? ''}`);
error.code = data?.code;
throw error;
}
return data;
}
// 1. Id of the license "None", which takes a license away
const licenses = await call('GET', 'https://api.sally.io/v1.0/licenses');
const none = licenses.find((license) => license.name.toLowerCase() === 'none');
if (!none) throw new Error('License "None" not found');
// 2. Usage of all members, page by page
const members = [];
for (let page = 1; ; page++) {
const result = await call('GET', `${BASE}/memberships/usage?period=last90&pageSize=100&page=${page}`);
members.push(...result.items);
if (!result.hasMore) break;
}
// 3. Inactive: a license, no sign-in for INACTIVE_DAYS days and nothing transcribed in 90 days
const cutoff = Date.now() - INACTIVE_DAYS * 24 * 60 * 60 * 1000;
const inactive = members.filter(
(m) =>
m.licenseId &&
m.licenseId !== none.licenseId &&
(!m.lastLoginOn || Date.parse(m.lastLoginOn) < cutoff) &&
m.transcribedMeetingsCount + m.transcribedUploadedRecordingsCount === 0,
);
console.log(`${inactive.length} of ${members.length} members are inactive.`);
// 4. Take the licenses away
for (const member of inactive) {
console.log(`${DRY_RUN ? '[dry run] ' : ''}Taking the license away from ${member.userId} (last sign-in ${member.lastLoginOn ?? 'never'})`);
if (DRY_RUN) continue;
try {
await call('PATCH', `${BASE}/memberships/${member.userId}`, {licenseId: none.licenseId});
} catch (error) {
if (['MEMBER_IS_SCIM_MANAGED', 'OWNER_PROTECTED'].includes(error.code)) console.log(` skipped: ${error.code}`);
else throw error;
}
}
// 5. Reduce the running subscription to the licenses still assigned
const statistics = await call('GET', `${BASE}/license-statistics`);
const {items: subscriptions} = await call('GET', `${BASE}/subscriptions`);
const running = subscriptions.find((s) => s.status === 'active' || s.status === 'trialing');
if (!running) {
console.log('No running subscription, nothing to reduce.');
} else {
const change = {};
for (const tier of ['starter', 'pro', 'enterprise']) {
const target = statistics[tier].subscription.assignedCount;
if (target < running[`${tier}LicensesCount`]) change[`${tier}LicensesCount`] = target;
}
if (Object.keys(change).length === 0) {
console.log('The subscription already matches the assigned licenses.');
} else if (DRY_RUN) {
console.log('[dry run] Would reduce the subscription to', change);
} else {
const updated = await call('PATCH', `${BASE}/subscriptions/${running.subscriptionId}`, change);
console.log('Reduction scheduled:', updated.scheduledChange);
}
}
# Python 3.9 or newer: pip install requests, then python clean_up_licenses.py
import os
from datetime import datetime, timedelta, timezone
import requests
BASE = f"https://api.sally.io/v1.0/directories/{os.environ['DIRECTORY_ID']}"
INACTIVE_DAYS = int(os.environ.get("INACTIVE_DAYS", "60"))
DRY_RUN = os.environ.get("DRY_RUN") != "false"
HEADERS = {"Authorization": f"Bearer {os.environ['SALLY_TOKEN']}"}
class SallyError(Exception):
def __init__(self, message, code=None):
super().__init__(message)
self.code = code
def call(method, url, body=None):
response = requests.request(method, url, json=body, headers=HEADERS)
data = None if response.status_code == 204 else response.json()
if not response.ok:
code = (data or {}).get("code")
raise SallyError(f"{method} {url}: {response.status_code} {code or ''} {(data or {}).get('message', '')}", code)
return data
# 1. Id of the license "None", which takes a license away
licenses = call("GET", "https://api.sally.io/v1.0/licenses")
none = next((l for l in licenses if l["name"].lower() == "none"), None)
if none is None:
raise SystemExit('License "None" not found')
# 2. Usage of all members, page by page
members, page = [], 1
while True:
result = call("GET", f"{BASE}/memberships/usage?period=last90&pageSize=100&page={page}")
members += result["items"]
if not result["hasMore"]:
break
page += 1
# 3. Inactive: a license, no sign-in for INACTIVE_DAYS days and nothing transcribed in 90 days
cutoff = datetime.now(timezone.utc) - timedelta(days=INACTIVE_DAYS)
def is_inactive(m):
if not m["licenseId"] or m["licenseId"] == none["licenseId"]:
return False
last = m["lastLoginOn"]
signed_in_recently = last and datetime.fromisoformat(last.replace("Z", "+00:00")) >= cutoff
transcribed = m["transcribedMeetingsCount"] + m["transcribedUploadedRecordingsCount"]
return not signed_in_recently and transcribed == 0
inactive = [m for m in members if is_inactive(m)]
print(f"{len(inactive)} of {len(members)} members are inactive.")
# 4. Take the licenses away
for member in inactive:
prefix = "[dry run] " if DRY_RUN else ""
print(f"{prefix}Taking the license away from {member['userId']} (last sign-in {member['lastLoginOn'] or 'never'})")
if DRY_RUN:
continue
try:
call("PATCH", f"{BASE}/memberships/{member['userId']}", {"licenseId": none["licenseId"]})
except SallyError as error:
if error.code in ("MEMBER_IS_SCIM_MANAGED", "OWNER_PROTECTED"):
print(f" skipped: {error.code}")
else:
raise
# 5. Reduce the running subscription to the licenses still assigned
statistics = call("GET", f"{BASE}/license-statistics")
subscriptions = call("GET", f"{BASE}/subscriptions")["items"]
running = next((s for s in subscriptions if s["status"] in ("active", "trialing")), None)
if running is None:
print("No running subscription, nothing to reduce.")
else:
change = {}
for tier in ("starter", "pro", "enterprise"):
target = statistics[tier]["subscription"]["assignedCount"]
if target < running[f"{tier}LicensesCount"]:
change[f"{tier}LicensesCount"] = target
if not change:
print("The subscription already matches the assigned licenses.")
elif DRY_RUN:
print("[dry run] Would reduce the subscription to", change)
else:
updated = call("PATCH", f"{BASE}/subscriptions/{running['subscriptionId']}", change)
print("Reduction scheduled:", updated["scheduledChange"])
Run the script with DRY_RUN left on first and check the list with the people responsible. Members who are on parental leave or only record a few times a year look inactive too. Once the list fits, schedule it once a month, a few days before the end of the billing period.
6. Endpoints at a glance
- GET
…/memberships/usageReturns the usage per member, as in the „Usage" tab of the user managementTry it - GET
…/memberships/usersLists the users of a directory (paginated, optionally filtered)Try it - PATCH
…/memberships/{userId}Changes the license, role or block of a memberTry it - GET
/v1.0/licensesLists the licenses (resolves `licenseId`)Try it - GET
…/license-statisticsReturns the license statistics of the directoryTry it - GET
…/subscriptionsLists the subscriptions of the directoryTry it - PATCH
…/subscriptions/{subscriptionId}Changes the licenses of a subscriptionTry it - POST
…/subscriptionsStarts a new subscription (returns the checkout link)Try it