Skip to main content
Complete guide to using the SnackBase REST API with practical examples.

Getting Started

Base URL

API Version

All endpoints are prefixed with /api/v1:
All record operations use /api/v1/records/{collection}, NOT /api/v1/{collection}. The records_router must be registered LAST in FastAPI to avoid capturing specific routes.

Interactive Documentation

Common Headers

Authentication

1. Register New Account

Create a new account with the first admin user. Endpoint: POST /api/v1/auth/register Authentication: None (public endpoint) Request:
Request (Single-Tenant Mode):
Response (201 Created):
Registration no longer returns tokens immediately. Email verification is REQUIRED before login.
Password Strength Requirements:
  • Minimum 12 characters
  • At least one uppercase letter (A-Z)
  • At least one lowercase letter (a-z)
  • At least one digit (0-9)
  • At least one special character: !@#$%^&*()_+\-=\[\]{};':\"\\|,.<>\/?~

2. Login

Authenticate with email, password, and account identifier. Endpoint: POST /api/v1/auth/login Authentication: None (public endpoint) Request:
Response (200 OK):
Account Identifier Options:
  • Account slug: "acme"
  • Account ID: "AB1234"
Single-Tenant Mode: The account field is optional. If omitted, the default singleton account is used.

3. Refresh Token

Get a new access token using a refresh token. Endpoint: POST /api/v1/auth/refresh Request:

4. Get Current User

Get information about the authenticated user. Endpoint: GET /api/v1/auth/me Authentication: Required

Records (CRUD)

IMPORTANT: All record operations use /api/v1/records/&lcub;collection&rcub;.

Create Record

Endpoint: `POST /api/v1/records/{collection}“

List Records

Endpoint: GET /api/v1/records/&lcub;collection&rcub;
Response:

Get Single Record

Endpoint: GET /api/v1/records/&lcub;collection&rcub;/&lcub;id&rcub;

Update Record (Full)

Endpoint: PUT /api/v1/records/&lcub;collection&rcub;/&lcub;id&rcub;

Update Record (Partial)

Endpoint: PATCH /api/v1/records/&lcub;collection&rcub;/&lcub;id&rcub;

Delete Record

Endpoint: DELETE /api/v1/records/&lcub;collection&rcub;/&lcub;id&rcub;

Collections

All collection endpoints require Superadmin access.

Create Collection

Endpoint: POST /api/v1/collections/
Field Types:

Roles & Permissions

Create Role

Endpoint: POST /api/v1/roles

Update Collection Rules

Endpoint: PUT /api/v1/collections/{collection_name}/rules

Permission Rule Syntax

Permission Structure:

Users

All users endpoints require Superadmin access.

Create User

Endpoint: POST /api/v1/users

List Users

Endpoint: GET /api/v1/users

OAuth Authentication

SnackBase supports OAuth 2.0 authentication for popular providers.

Supported Providers

  • google - Google OAuth 2.0
  • github - GitHub OAuth App
  • microsoft - Microsoft Azure AD
  • apple - Sign in with Apple

Initiate OAuth Flow

Endpoint: POST /api/v1/auth/oauth/&lcub;provider_name&rcub;/authorize
Response:

SAML Authentication

SnackBase supports SAML 2.0 for enterprise single sign-on (SSO).

Supported Providers

  • azure - Microsoft Azure AD
  • okta - Okta Identity Cloud
  • generic - Any SAML 2.0 compliant IdP

Initiate SAML SSO

Endpoint: GET /api/v1/auth/saml/sso
Response: Redirects to the Identity Provider’s login page

Download SAML Metadata

Endpoint: GET /api/v1/auth/saml/metadata

Error Handling

HTTP Status Codes

Error Response Format

Validation Error Response

Best Practices

1. Always Use HTTPS in Production

2. Store Tokens Securely

3. Handle Token Expiration

4. Use Pagination for Large Datasets

5. Use Field Limiting

6. Remember Route Registration Order

The records_router MUST be registered LAST in your FastAPI app to prevent capturing specific routes.