Account Management
Self-Hosting Only: Account management endpoints are only available for users self-hosting Scheduler0. These endpoints require Basic Authentication (username and password from your Scheduler0 configuration) and are designed for infrastructure administrators who need granular control over team access and resource usage.
Overview
Accounts are the main entities that own projects, jobs, credentials, and other resources in Scheduler0. When self-hosting, you can create and manage multiple accounts, each with their own resources and execution limits.
Authentication
All account management endpoints require Basic Authentication:
# Using curl with Basic Auth
curl -u username:password "https://your-scheduler0-instance.com/api/v1/accounts/1"
Or with explicit headers:
curl -X GET "https://your-scheduler0-instance.com/api/v1/accounts/1" \
-H "Authorization: Basic $(echo -n 'username:password' | base64)"
Account Structure
{
"id": 1,
"name": "My Account",
"features": [
{
"accountId": 1,
"featureId": 1,
"feature": "IncreasedNumberOfJobExecutions100KPerMonth"
}
],
"dateCreated": "2024-01-15T10:30:00Z",
"dateModified": null
}
Fields
- id: Unique identifier for the account (integer)
- name: Human-readable name for the account (string)
- features: Array of features enabled for this account
- dateCreated: Timestamp when the account was created (RFC3339 format)
- dateModified: Timestamp when the account was last modified (RFC3339 format, optional)
Creating Accounts
Create a new account in your self-hosted Scheduler0 instance.
Endpoint: POST /api/v1/accounts
Request Body:
{
"name": "My Account"
}
Example:
curl -X POST "https://your-scheduler0-instance.com/api/v1/accounts" \
-u username:password \
-H "Content-Type: application/json" \
-d '{
"name": "My Account"
}'
Response:
{
"success": true,
"data": {
"id": 1,
"name": "My Account",
"features": [],
"dateCreated": "2024-01-15T10:30:00Z",
"dateModified": null
}
}
Node.js Client Example
const client = Client.newBasicAuthClient(
"https://your-scheduler0-instance.com",
"v1",
"username",
"password"
);
const account = await client.createAccount({
name: "My Account"
});
console.log(`Created account with ID: ${account.data.id}`);
Go Client Example
client, err := scheduler0_go_client.NewBasicAuthClient(
"https://your-scheduler0-instance.com",
"v1",
"username",
"password",
)
if err != nil {
log.Fatal(err)
}
account, err := client.CreateAccount(scheduler0_go_client.AccountCreateRequestBody{
Name: "My Account",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Created account with ID: %d\n", account.Data.ID)
Python Client Example
from scheduler0 import Client
client = Client.new_basic_auth_client(
"https://your-scheduler0-instance.com",
"v1",
"username",
"password"
)
account = client.create_account({
"name": "My Account"
})
print(f"Created account with ID: {account['data']['id']}")
Getting Account Details
Retrieve details for a specific account.
Endpoint: GET /api/v1/accounts/{id}
Example:
curl -X GET "https://your-scheduler0-instance.com/api/v1/accounts/1" \
-u username:password
Response:
{
"success": true,
"data": {
"id": 1,
"name": "My Account",
"features": [
{
"accountId": 1,
"featureId": 1,
"feature": "IncreasedNumberOfJobExecutions100KPerMonth"
}
],
"dateCreated": "2024-01-15T10:30:00Z",
"dateModified": null
}
}
Execution Count Management
Each account has an execution count that tracks how many job executions have been used. This is useful for monitoring usage and managing resource limits.
Getting Execution Count
Get the current execution count and reset information for an account.
Endpoint: GET /api/v1/accounts/{id}/execution-count
Example:
curl -X GET "https://your-scheduler0-instance.com/api/v1/accounts/1/execution-count" \
-u username:password
Response:
{
"success": true,
"data": {
"id": 1,
"accountId": 1,
"executionCount": 50000,
"dateCreated": "2024-01-15T10:30:00Z",
"dateModified": "2024-01-20T15:45:00Z",
"nextResetDate": "2024-02-01T00:00:00Z"
}
}
Response Fields:
- id: Unique identifier for the execution count record (integer)
- accountId: ID of the account (integer)
- executionCount: Current execution count for the account (integer)
- dateCreated: When the execution count record was created (RFC3339 format)
- dateModified: When the execution count record was last modified (RFC3339 format)
- nextResetDate: Date when the execution count will be reset (RFC3339 format)
Node.js Client Example
const executionCount = await client.getAccountExecutionCount("1");
console.log(`Current execution count: ${executionCount.data.executionCount}`);
console.log(`Next reset date: ${executionCount.data.nextResetDate}`);
Go Client Example
executionCount, err := client.GetAccountExecutionCount("1")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Current execution count: %d\n", executionCount.Data.ExecutionCount)
fmt.Printf("Next reset date: %s\n", executionCount.Data.NextResetDate)
Python Client Example
execution_count = client.get_account_execution_count("1")
print(f"Current execution count: {execution_count['data']['executionCount']}")
print(f"Next reset date: {execution_count['data']['nextResetDate']}")
Increasing Execution Count
Increase the execution count for an account by a specified amount. This is useful for manually adding execution credits or adjusting limits.
Endpoint: PUT /api/v1/accounts/{id}/execution-count
Request Body:
{
"count": 10000
}
Example:
curl -X PUT "https://your-scheduler0-instance.com/api/v1/accounts/1/execution-count" \
-u username:password \
-H "Content-Type: application/json" \
-d '{
"count": 10000
}'
Response:
{
"success": true,
"data": {
"newExecutionCount": 60000
}
}
Response Fields:
- newExecutionCount: The new execution count after the increase (integer)
Node.js Client Example
const result = await client.increaseAccountExecutionCount("1", 10000);
console.log(`New execution count: ${result.data.newExecutionCount}`);
Go Client Example
result, err := client.IncreaseAccountExecutionCount("1", 10000)
if err != nil {
log.Fatal(err)
}
fmt.Printf("New execution count: %d\n", result.Data.NewExecutionCount)
Python Client Example
result = client.increase_account_execution_count("1", 10000)
print(f"New execution count: {result['data']['newExecutionCount']}")
Feature Management
Accounts can have features enabled that provide additional capabilities or increased limits. Features are managed separately and can be added or removed from accounts.
Adding a Feature to an Account
Endpoint: PUT /api/v1/accounts/{id}/feature
Request Body:
{
"featureId": 1
}
Example:
curl -X PUT "https://your-scheduler0-instance.com/api/v1/accounts/1/feature" \
-u username:password \
-H "Content-Type: application/json" \
-d '{
"featureId": 1
}'
Removing a Feature from an Account
Endpoint: DELETE /api/v1/accounts/{id}/feature
Request Body:
{
"featureId": 1
}
Example:
curl -X DELETE "https://your-scheduler0-instance.com/api/v1/accounts/1/feature" \
-u username:password \
-H "Content-Type: application/json" \
-d '{
"featureId": 1
}'
Adding All Features to an Account
Endpoint: PUT /api/v1/accounts/{id}/features/all
Example:
curl -X PUT "https://your-scheduler0-instance.com/api/v1/accounts/1/features/all" \
-u username:password
Removing All Features from an Account
Endpoint: DELETE /api/v1/accounts/{id}/features/all
Example:
curl -X DELETE "https://your-scheduler0-instance.com/api/v1/accounts/1/features/all" \
-u username:password
Common Use Cases
Monitoring Account Usage
Regularly check execution counts to monitor account usage:
// Check execution count weekly
const executionCount = await client.getAccountExecutionCount("1");
const usage = executionCount.data.executionCount;
const limit = 100000; // Your account limit
if (usage > limit * 0.8) {
console.warn(`Account ${accountId} is at ${(usage/limit*100).toFixed(1)}% capacity`);
}
Adding Execution Credits
Manually add execution credits when needed:
// Add 50,000 execution credits
const result = await client.increaseAccountExecutionCount("1", 50000);
console.log(`Added credits. New total: ${result.data.newExecutionCount}`);
Account Provisioning
Create and configure new accounts with features:
// Create account
const account = await client.createAccount({ name: "New Team Account" });
// Add premium features
await client.addFeatureToAccount(account.data.id.toString(), { featureId: 1 });
// Set initial execution count (if needed)
await client.increaseAccountExecutionCount(account.data.id.toString(), 100000);
Notes
- Self-Hosting Only: All account management endpoints are only available when self-hosting Scheduler0
- Basic Authentication Required: These endpoints require Basic Authentication, not API Key + Secret
- Execution Count Reset: Execution counts typically reset monthly, but the exact reset date is shown in the
nextResetDatefield - Feature Effects: Some features (like
IncreasedNumberOfJobExecutions100KPerMonth) automatically add execution credits when enabled