Draftbase

Draftbase API Reference

Every endpoint below maps directly to a resource in the Draftbase content model: templates define the schema, entries hold the content, and media handles uploads. Each route documents its request body, response shape, and status codes, generated straight from the live OpenAPI spec so it never drifts from the deployed API. Prefer calling these endpoints through a typed client instead of raw fetch calls? The SDK wraps every route here with full TypeScript types.

@draftbase/sdk on GitHub
GET/billing/subscription

Get the active org's subscription

Returns the org's plan, billing status, and usage against plan limits.

Request

Terminal
curl -X GET "https://api.draftbase.co/billing/subscription" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Responses

200OK

The request succeeded.

Response
{
  "planKey": "hobby",
  "status": "active",
  "currentPeriodEnd": "string",
  "plan": {
    "key": "hobby",
    "name": "string",
    "priceMonthly": 0,
    "limits": {
      "maxMembers": 0,
      "maxEntries": 0,
      "maxMediaFiles": 0,
      "maxStorageBytes": 0,
      "maxEnvironments": 0,
      "monthlyAiTokens": 0
    },
    "features": [
      "string"
    ]
  },
  "usage": {
    "members": 0,
    "entries": 0,
    "mediaFiles": 0,
    "storageBytes": 0,
    "environments": 0,
    "aiTokens": 0
  }
}

Any endpoint can also return 401 (missing or invalid credentials), 403 (suspended org, insufficient role, or blocked IP), and 429 (100 requests per minute per IP; delivery routes add a 300 per minute per-org cap).

Error codes

Every error response carries a stable `code` alongside the human-readable `error` message. Switch on `code` — the message wording can change at any time, the code cannot.

CodeStatusMeaning
MISSING_ORG_HEADER400Missing x-org-id header
VALIDATION_FAILED400Request validation failed
INVALID_TOKEN400Invalid or expired token
INVALID_2FA_CODE400Invalid code
TWO_FACTOR_NOT_ENABLED4002FA is not enabled
TWO_FACTOR_SETUP_REQUIRED400Start setup before enabling 2FA
INCORRECT_PASSWORD400Current password is incorrect
PASSWORD_REQUIRED400Set a password before unlinking Google
DUPLICATE_FIELD_KEYS400Duplicate field keys
DUPLICATE_PROP_NAMES400Duplicate prop names
INVALID_NAME400Name must contain at least one letter or digit
UNKNOWN_ENVIRONMENT400Unknown environment
MAIN_ENVIRONMENT_IMMUTABLE400The main environment cannot be modified this way
SAME_ENVIRONMENT400Source and target environments must differ
PLAN_LIMIT_EXCEEDED400Plan limit exceeded
ALREADY_PUBLISHED400Entry is already published
PUBLISH_AT_IN_PAST400publishAt must be in the future
INVITE_NOT_PENDING400Invite is not pending
STORAGE_KEY_MISMATCH400storageKey does not belong to this org/environment
SELF_DISABLE_FORBIDDEN400Cannot disable your own account
RETRY_NOT_ALLOWED400Only failed deliveries can be retried
IDP_EMAIL_MISSING400Identity provider did not return an email
IDP_EMAIL_UNVERIFIED400Identity provider did not verify this email
UNAUTHORIZED401Unauthorized
INVALID_CREDENTIALS401Invalid email or password
MISSING_REFRESH_TOKEN401Missing refresh token
INVALID_REFRESH_TOKEN401Invalid or expired refresh token
INVALID_CHALLENGE401Invalid or expired challenge
FORBIDDEN403Forbidden
ORG_SUSPENDED403Org is suspended
IP_NOT_ALLOWED403Request IP is not on the org's allowlist
NOT_ORG_MEMBER403Not a member of this org
INSUFFICIENT_ROLE403Insufficient role
ENVIRONMENT_FORBIDDEN403Not allowed to access this environment
OWNER_IMMUTABLE403The org owner cannot be changed or removed
PLAN_FEATURE_REQUIRED403This feature is not included in the org's plan
EMAIL_NOT_VERIFIED403Email address is not verified
NOT_INVITED403This account is not invited to this org
NO_ORG403User does not belong to an org
NOT_FOUND404Not found
REVISION_NOT_FOUND404Revision not found
SNAPSHOT_NOT_FOUND404Snapshot not found
SSO_CONNECTION_NOT_FOUND404SSO connection not found
ENVIRONMENT_NOT_FOUND404Environment not found
ALREADY_EXISTS409Already exists
EMAIL_IN_USE409Email already in use
ALREADY_MEMBER409Already a member
ALREADY_INVITED409Already invited
ENTRY_MODIFIED409Entry was modified by another request
STILL_REFERENCED409Still referenced by other content
TEMPLATE_HAS_ENTRIES409Template still has entries
AI_UNAVAILABLE502AI service is unavailable
RATE_LIMITED429Rate limit exceeded
INTERNAL_ERROR500Internal server error