Skip to main content
Planned feature: The endpoints described on this page are part of the planned API design and are not yet implemented in the current codebase.
The planned Organizations API will allow you to create and retrieve organizations within your multi-tenant platform. Organizations will serve as the top-level container for users, roles, and resources.

Authentication

All organization endpoints require authentication using a JWT bearer token in the Authorization header:
Authorization: Bearer YOUR_JWT_TOKEN

Get organizations

This endpoint returns all organizations accessible to the authenticated user based on their permissions.
GET /api/organizations
Retrieves a list of organizations. You can filter, sort, and paginate the results using query parameters.

Query parameters

page
integer
default:"1"
The page number for pagination
limit
integer
default:"20"
Number of organizations to return per page (maximum 100)
sort
string
default:"createdAt"
Field to sort by. Options: name, createdAt, updatedAt
order
string
default:"desc"
Sort order. Options: asc, desc
Search organizations by name or domain
status
string
Filter by organization status. Options: active, suspended, archived

Response

data
array
Array of organization objects
pagination
object
Pagination metadata

Example request

curl -X GET "https://api.orgstack.io/api/organizations?page=1&limit=10&status=active" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json"

Example response

200 - Success
{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Acme Corporation",
      "slug": "acme-corp",
      "domain": "acme.com",
      "status": "active",
      "settings": {
        "allowPublicSignup": true,
        "requireEmailVerification": true,
        "defaultRole": "member"
      },
      "metadata": {
        "industry": "Technology",
        "size": "enterprise"
      },
      "createdAt": "2024-01-15T08:30:00.000Z",
      "updatedAt": "2024-02-20T14:22:00.000Z"
    },
    {
      "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
      "name": "TechStart Inc",
      "slug": "techstart",
      "domain": "techstart.io",
      "status": "active",
      "settings": {
        "allowPublicSignup": false,
        "requireEmailVerification": true,
        "defaultRole": "viewer"
      },
      "metadata": {
        "industry": "SaaS",
        "size": "startup"
      },
      "createdAt": "2024-02-10T10:15:00.000Z",
      "updatedAt": "2024-02-28T16:45:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 2,
    "totalPages": 1
  }
}
401 - Unauthorized
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing authentication token"
  }
}
403 - Forbidden
{
  "error": {
    "code": "FORBIDDEN",
    "message": "You do not have permission to access organizations"
  }
}

Create organization

Only users with admin privileges can create new organizations. The authenticated user will automatically become the owner of the newly created organization.
POST /api/organizations
Creates a new organization in the system. The organization slug must be unique across the platform.

Request body

name
string
required
Organization name (2-100 characters)
slug
string
required
URL-friendly identifier (3-50 characters, lowercase letters, numbers, and hyphens only)
domain
string
Primary domain for the organization (must be a valid domain)
settings
object
Organization settings and configuration
metadata
object
Custom metadata as key-value pairs (optional)

Response

Returns the created organization object with all fields populated, including generated id, createdAt, and updatedAt timestamps.
id
string
required
Unique identifier for the organization (UUID)
name
string
required
Organization name
slug
string
required
URL-friendly identifier
domain
string
Primary domain
status
string
required
Organization status (default: active)
settings
object
Organization settings
metadata
object
Custom metadata
createdAt
string
required
ISO 8601 timestamp when created
updatedAt
string
required
ISO 8601 timestamp when last updated

Example request

curl -X POST "https://api.orgstack.io/api/organizations" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "GlobalTech Solutions",
    "slug": "globaltech",
    "domain": "globaltech.com",
    "settings": {
      "allowPublicSignup": true,
      "requireEmailVerification": true,
      "defaultRole": "member"
    },
    "metadata": {
      "industry": "Consulting",
      "region": "North America"
    }
  }'

Example response

201 - Created
{
  "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "name": "GlobalTech Solutions",
  "slug": "globaltech",
  "domain": "globaltech.com",
  "status": "active",
  "settings": {
    "allowPublicSignup": true,
    "requireEmailVerification": true,
    "defaultRole": "member"
  },
  "metadata": {
    "industry": "Consulting",
    "region": "North America"
  },
  "createdAt": "2026-03-01T10:30:00.000Z",
  "updatedAt": "2026-03-01T10:30:00.000Z"
}
400 - Bad request
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request body",
    "details": [
      {
        "field": "slug",
        "message": "Slug must be 3-50 characters and contain only lowercase letters, numbers, and hyphens"
      }
    ]
  }
}
401 - Unauthorized
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing authentication token"
  }
}
403 - Forbidden
{
  "error": {
    "code": "FORBIDDEN",
    "message": "You do not have permission to create organizations"
  }
}
409 - Conflict
{
  "error": {
    "code": "CONFLICT",
    "message": "An organization with this slug already exists"
  }
}

Error codes

The Organizations API may return the following error codes:
CodeDescription
UNAUTHORIZEDMissing or invalid authentication token
FORBIDDENInsufficient permissions to perform the action
VALIDATION_ERRORRequest body validation failed
CONFLICTResource conflict (e.g., duplicate slug)
NOT_FOUNDOrganization not found
RATE_LIMIT_EXCEEDEDToo many requests, please retry later
INTERNAL_ERRORUnexpected server error

Build docs developers (and LLMs) love