> ## Documentation Index
> Fetch the complete documentation index at: https://docs.timbrix.mx/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Organization

> Creates a new organization with the authenticated user as the owner. All authenticated users can create organizations.

Creates a new organization with the authenticated user as the owner.

## Authentication

This endpoint requires authentication via Bearer token:

* **Authorization**: `Bearer <token>`

## Permissions

All authenticated users can create organizations. The user who creates the organization automatically becomes the **owner**.

## Request Body

| Field  | Type   | Required | Description                               |
| ------ | ------ | -------- | ----------------------------------------- |
| `name` | string | Yes      | Organization name (3-100 characters)      |
| `slug` | string | Yes      | URL-friendly identifier (3-50 characters) |
| `logo` | string | No       | URL to organization logo image            |

## Organization Roles

After creation, the organization will have the following role structure:

* **Owner**: Full control (cannot be changed or removed)
* **Admin**: Can manage members and settings
* **Member**: Basic access to organization resources

## Slug Requirements

The organization slug must be:

* Unique across all organizations
* URL-friendly (lowercase letters, numbers, hyphens)
* Between 3-50 characters
* Cannot be changed after creation

The slug is used in URLs: `/org/{slug}/...`

## Example Request

```bash theme={null}
curl -X POST http://localhost:3001/api/organizations \
  -H "Authorization: Bearer <your_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Corp",
    "slug": "acme-corp",
    "logo": "https://example.com/logo.png"
  }'
```

## Example Response

```json theme={null}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Acme Corp",
  "slug": "acme-corp",
  "logo": "https://example.com/logo.png",
  "plan": "free",
  "ownerId": "123e4567-e89b-12d3-a456-426614174000",
  "createdAt": "2025-12-26T10:00:00Z",
  "updatedAt": "2025-12-26T10:00:00Z"
}
```

## Common Errors

### 409 Conflict

The slug is already taken by another organization. Choose a different slug.

```json theme={null}
{
  "statusCode": 409,
  "message": "Organization slug already exists"
}
```

### 400 Bad Request

Invalid input data (e.g., slug too short, invalid characters).

```json theme={null}
{
  "statusCode": 400,
  "message": ["slug must be at least 3 characters long"]
}
```

## Best Practices

* Use descriptive organization names
* Choose slugs that are easy to remember and type
* Slugs are permanent, so choose carefully
* Keep logo images under 2MB for best performance


## OpenAPI

````yaml POST /organizations
openapi: 3.1.0
info:
  title: Timbrix API
  description: >-
    REST API with OAuth2 server for managing organizations, members, and
    webhooks
  version: '1.0'
  contact: {}
servers:
  - url: http://sandbox.mintlify.com
    description: Sandbox environment
  - url: http://localhost:3001/api
    description: Local development
security: []
tags:
  - name: organizations
    description: Organization management endpoints
  - name: oauth
    description: OAuth2 authentication and authorization
  - name: webhooks
    description: Webhook configuration and delivery
  - name: users
    description: User information endpoints
  - name: api-keys
    description: API Keys management and validation
paths:
  /organizations:
    post:
      tags:
        - organizations
      summary: Create a new organization
      description: >-
        Creates a new organization with the authenticated user as the owner. All
        authenticated users can create organizations.
      operationId: OrganizationsController_create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrganizationDto'
      responses:
        '201':
          description: >-
            Organization created successfully. The user becomes the organization
            owner.
        '400':
          description: Invalid input data. Check the validation errors in the response.
        '401':
          description: Authentication required. Provide a valid bearer token.
        '409':
          description: Organization slug already exists. Choose a different slug.
      security:
        - bearer: []
components:
  schemas:
    CreateOrganizationDto:
      type: object
      properties:
        name:
          type: string
          description: Organization name
          example: Acme Corporation
          minLength: 1
          maxLength: 100
        slug:
          type: string
          description: Organization URL slug
          example: acme-corp
          pattern: ^[a-z0-9-]+$
          minLength: 1
          maxLength: 100
        logo:
          type: string
          description: Organization logo URL
          example: https://example.com/logo.png
      required:
        - name
        - slug
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````