# Organizations API

Teams, members, and shared workspaces

Team collaboration and organization management. Create organizations for team workspaces, invite members via email, assign roles with different permission levels (owner, admin, member), and manage team subscriptions. Organizations can own projects and share resources across team members.

## Available Endpoints

| Method   | Endpoint                                                                                                                                  | Description                  |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| `GET`    | [`/api/user/organizations/{organizationId}/audit-logs`](#get-apiuserorganizations{organizationId}auditlogs)                               | Get audit logs               |
| `GET`    | [`/api/user/organizations/{organizationId}/audit-logs/export`](#get-apiuserorganizations{organizationId}auditlogsexport)                  | Export audit logs            |
| `GET`    | [`/api/user/organizations/{organizationId}/audit-logs/actions`](#get-apiuserorganizations{organizationId}auditlogsactions)                | List available audit actions |
| `GET`    | [`/api/user/organizations`](#get-apiuserorganizations)                                                                                    | List organizations           |
| `POST`   | [`/api/user/organizations`](#post-apiuserorganizations)                                                                                   | Create organization          |
| `GET`    | [`/api/user/organizations/{organizationId}`](#get-apiuserorganizations{organizationId})                                                   | Get organization             |
| `PUT`    | [`/api/user/organizations/{organizationId}`](#put-apiuserorganizations{organizationId})                                                   | Update organization          |
| `GET`    | [`/api/user/organizations/{organizationId}/members`](#get-apiuserorganizations{organizationId}members)                                    | List members                 |
| `PUT`    | [`/api/user/organizations/{organizationId}/members/{memberId}/role`](#put-apiuserorganizations{organizationId}members{memberId}role)      | Update member role           |
| `DELETE` | [`/api/user/organizations/{organizationId}/members/{memberId}`](#delete-apiuserorganizations{organizationId}members{memberId})            | Remove member                |
| `GET`    | [`/api/user/organizations/{organizationId}/my-membership`](#get-apiuserorganizations{organizationId}mymembership)                         | Get my membership            |
| `GET`    | [`/api/user/organizations/{organizationId}/invites`](#get-apiuserorganizations{organizationId}invites)                                    | List organization invites    |
| `POST`   | [`/api/user/organizations/{organizationId}/invites`](#post-apiuserorganizations{organizationId}invites)                                   | Send invitations             |
| `DELETE` | [`/api/user/organizations/{organizationId}/invites/{memberId}`](#delete-apiuserorganizations{organizationId}invites{memberId})            | Cancel invitation            |
| `POST`   | [`/api/user/organizations/{organizationId}/invites/{memberId}/resend`](#post-apiuserorganizations{organizationId}invites{memberId}resend) | Resend invitation            |
| `POST`   | [`/api/user/invites/{token}/accept`](#post-apiuserinvites{token}accept)                                                                   | Accept invitation            |
| `GET`    | [`/api/user/organizations/{organizationId}/settings/billing`](#get-apiuserorganizations{organizationId}settingsbilling)                   | Get billing settings         |
| `PUT`    | [`/api/user/organizations/{organizationId}/settings/billing`](#put-apiuserorganizations{organizationId}settingsbilling)                   | Update billing settings      |
| `GET`    | [`/api/user/organizations/{organizationId}/mfa`](#get-apiuserorganizations{organizationId}mfa)                                            | Get MFA settings             |
| `PUT`    | [`/api/user/organizations/{organizationId}/mfa`](#put-apiuserorganizations{organizationId}mfa)                                            | Update MFA settings          |
| `GET`    | [`/api/user/organizations/{organizationId}/mfa/compliance`](#get-apiuserorganizations{organizationId}mfacompliance)                       | Get MFA compliance status    |
| `GET`    | [`/api/user/organizations/{organizationId}/settings/sso`](#get-apiuserorganizations{organizationId}settingssso)                           | Get SSO configuration        |
| `PUT`    | [`/api/user/organizations/{organizationId}/settings/sso`](#put-apiuserorganizations{organizationId}settingssso)                           | Update SSO configuration     |
| `DELETE` | [`/api/user/organizations/{organizationId}/settings/sso`](#delete-apiuserorganizations{organizationId}settingssso)                        | Disable SSO                  |
| `POST`   | [`/api/user/organizations/{organizationId}/settings/sso/test`](#post-apiuserorganizations{organizationId}settingsssotest)                 | Test SSO configuration       |
| `GET`    | [`/api/user/organizations/{organizationId}/domains`](#get-apiuserorganizations{organizationId}domains)                                    | List organization domains    |
| `POST`   | [`/api/user/organizations/{organizationId}/domains`](#post-apiuserorganizations{organizationId}domains)                                   | Add domain for verification  |
| `GET`    | [`/api/user/organizations/{organizationId}/domains/{domainId}`](#get-apiuserorganizations{organizationId}domains{domainId})               | Get domain                   |
| `DELETE` | [`/api/user/organizations/{organizationId}/domains/{domainId}`](#delete-apiuserorganizations{organizationId}domains{domainId})            | Remove domain                |
| `POST`   | [`/api/user/organizations/{organizationId}/domains/{domainId}/verify`](#post-apiuserorganizations{organizationId}domains{domainId}verify) | Verify domain ownership      |
| `GET`    | [`/api/user/organizations/{organizationId}/settings/security`](#get-apiuserorganizations{organizationId}settingssecurity)                 | Get security settings        |
| `PUT`    | [`/api/user/organizations/{organizationId}/settings/security`](#put-apiuserorganizations{organizationId}settingssecurity)                 | Update security settings     |

## Endpoints

### GET /api/user/organizations/{organizationId}/audit-logs

Get audit logs

Get audit logs for the organization.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Query parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `offset` | number \| null | no | Number of items to skip | `0` |
| `limit` | number | no | Number of items to return (max 100) | `20` |
| `action` | AuditAction | no | Filter by action type |  |
| `resourceType` | AuditResourceType | no | Filter by resource type |  |
| `resourceId` | string | no | Filter by resource ID | `550e8400-e29b-41d4-a716-446655440000` |
| `userId` | string | no | Filter by user ID | `550e8400-e29b-41d4-a716-446655440000` |
| `startDate` | string | no | Filter logs after this date | `2024-01-01T00:00:00.000Z` |
| `endDate` | string | no | Filter logs before this date | `2024-12-31T23:59:59.000Z` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/audit-logs" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/audit-logs", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Audit logs retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Items fetched successfully",
"data": [
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "organizationId": "550e8400-e29b-41d4-a716-446655440001",
    "userId": "507f1f77bcf86cd799439013",
    "actor": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "email": "user@example.com"
    },
    "action": "member.invited",
    "resourceType": "member",
    "resourceId": "507f1f77bcf86cd799439014",
    "metadata": {},
    "ipAddress": "192.168.1.1",
    "userAgent": "Mozilla/5.0...",
    "auditSessionId": "sess_xxx",
    "traceId": "string"
  }
],
"meta": {
  "total": 100,
  "offset": 0,
  "limit": 10,
  "hasMore": true
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/audit-logs/export

Export audit logs

Export audit logs as CSV or JSON.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Query parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `action` | AuditAction | no | Filter by action type |  |
| `resourceType` | AuditResourceType | no | Filter by resource type |  |
| `userId` | string | no | Filter by user ID | `550e8400-e29b-41d4-a716-446655440000` |
| `startDate` | string | no | Filter logs after this date |  |
| `endDate` | string | no | Filter logs before this date |  |
| `format` | AuditExportFormat | no |  |  |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/audit-logs/export" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/audit-logs/export", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Audit logs exported successfully

```json
[
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-15T10:30:00.000Z",
  "organizationId": "550e8400-e29b-41d4-a716-446655440001",
  "userId": "507f1f77bcf86cd799439013",
  "actor": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "user@example.com"
  },
  "action": "member.invited",
  "resourceType": "member",
  "resourceId": "507f1f77bcf86cd799439014",
  "metadata": {},
  "ipAddress": "192.168.1.1",
  "userAgent": "Mozilla/5.0...",
  "auditSessionId": "sess_xxx",
  "traceId": "string"
}
]
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/audit-logs/actions

List available audit actions

List audit action values that can be used to filter organization audit logs.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/audit-logs/actions" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/audit-logs/actions", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Audit actions fetched successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "actions": [
    "string"
  ]
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations

List organizations

Get all organizations the authenticated user belongs to.

**Auth:** bearer · **Scopes:** `user:read`

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Organizations retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": [
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Acme Corporation",
    "slug": "acme-corp",
    "status": "active",
    "type": "team",
    "workspaceAccess": {
      "plan": "solo",
      "memberCap": 1,
      "membersUsed": 0,
      "entitlements": [
        "api_access"
      ],
      "subscription": {
        "externalSubscriptionId": "sub_xxx",
        "provider": "stripe",
        "status": "active",
        "interval": "monthly",
        "currentPeriodEnd": "2024-12-31T23:59:59.000Z",
        "cancelAt": null,
        "memberCap": 1
      }
    },
    "isPersonal": false
  }
]
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### POST /api/user/organizations

Create organization

Create a new organization. The authenticated user becomes the owner.

**Auth:** bearer · **Scopes:** `user:write`

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `name` | string | yes | Organization name | `Acme Corporation` |
| `slug` | string | no | URL-friendly slug (auto-generated if not provided) | `acme-corp` |

#### Request example

**curl**

```bash
curl -X POST "https://api.indexhog.com/api/user/organizations" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"name":"Acme Corporation","slug":"acme-corp"}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations", {
method: "POST",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "name": "Acme Corporation",
  "slug": "acme-corp"
}),
});

const data = await response.json();
console.log(data);
```

#### Response `201` — Organization created successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "name": "Acme Corporation",
  "slug": "acme-corp",
  "status": "active",
  "type": "team",
  "workspaceAccess": {
    "plan": "solo",
    "memberCap": 1,
    "membersUsed": 0,
    "entitlements": [
      "api_access"
    ],
    "subscription": {
      "externalSubscriptionId": "sub_xxx",
      "provider": "stripe",
      "status": "active",
      "interval": "monthly",
      "currentPeriodEnd": "2024-12-31T23:59:59.000Z",
      "cancelAt": null,
      "memberCap": 1
    }
  },
  "creditBalance": 1500,
  "requireMfa": false,
  "ssoEnabled": false,
  "isPersonal": false,
  "timezone": "Europe/Vilnius"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}

Get organization

Get organization details.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Organization retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "name": "Acme Corporation",
  "slug": "acme-corp",
  "status": "active",
  "type": "team",
  "workspaceAccess": {
    "plan": "solo",
    "memberCap": 1,
    "membersUsed": 0,
    "entitlements": [
      "api_access"
    ],
    "subscription": {
      "externalSubscriptionId": "sub_xxx",
      "provider": "stripe",
      "status": "active",
      "interval": "monthly",
      "currentPeriodEnd": "2024-12-31T23:59:59.000Z",
      "cancelAt": null,
      "memberCap": 1
    }
  },
  "creditBalance": 1500,
  "requireMfa": false,
  "ssoEnabled": false,
  "isPersonal": false,
  "timezone": "Europe/Vilnius"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### PUT /api/user/organizations/{organizationId}

Update organization

Update organization details. Requires owner + admin.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `name` | string | no |  | `Acme Inc` |
| `slug` | string | no |  | `acme-inc` |
| `timezone` | string \| null | no | IANA timezone for issue digests; null clears (no digest) | `America/Los_Angeles` |

#### Request example

**curl**

```bash
curl -X PUT "https://api.indexhog.com/api/user/organizations/{organizationId}" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"name":"Acme Inc","slug":"acme-inc","timezone":"America/Los_Angeles"}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}", {
method: "PUT",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "name": "Acme Inc",
  "slug": "acme-inc",
  "timezone": "America/Los_Angeles"
}),
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Organization updated successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "name": "Acme Corporation",
  "slug": "acme-corp",
  "status": "active",
  "type": "team",
  "workspaceAccess": {
    "plan": "solo",
    "memberCap": 1,
    "membersUsed": 0,
    "entitlements": [
      "api_access"
    ],
    "subscription": {
      "externalSubscriptionId": "sub_xxx",
      "provider": "stripe",
      "status": "active",
      "interval": "monthly",
      "currentPeriodEnd": "2024-12-31T23:59:59.000Z",
      "cancelAt": null,
      "memberCap": 1
    }
  },
  "creditBalance": 1500,
  "requireMfa": false,
  "ssoEnabled": false,
  "isPersonal": false,
  "timezone": "Europe/Vilnius"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/members

List members

Get all members of the organization.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/members" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/members", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Members retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": [
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z",
    "organizationId": "550e8400-e29b-41d4-a716-446655440001",
    "role": "admin",
    "status": "active",
    "invitedAt": "2024-01-01T00:00:00.000Z",
    "joinedAt": "2024-01-02T00:00:00.000Z",
    "user": {
      "id": "507f1f77bcf86cd799439013",
      "email": "john@example.com"
    },
    "invitedBy": {
      "id": "507f1f77bcf86cd799439013",
      "email": "john@example.com"
    },
    "canManageMembers": true,
    "canManageProjects": true,
    "canManageBilling": false
  }
]
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### PUT /api/user/organizations/{organizationId}/members/{memberId}/role

Update member role

Change a member's role. Requires owner + admin.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |
| `memberId` | string | yes | Member/Membership ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `role` | AssignableRole | yes |  |  |

#### Request example

**curl**

```bash
curl -X PUT "https://api.indexhog.com/api/user/organizations/{organizationId}/members/{memberId}/role" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"role":"admin"}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/members/{memberId}/role", {
method: "PUT",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "role": "admin"
}),
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Member role updated successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "organizationId": "550e8400-e29b-41d4-a716-446655440001",
  "role": "admin",
  "status": "active",
  "invitedAt": "2024-01-01T00:00:00.000Z",
  "joinedAt": "2024-01-02T00:00:00.000Z",
  "user": {
    "id": "507f1f77bcf86cd799439013",
    "email": "john@example.com"
  },
  "invitedBy": {
    "id": "507f1f77bcf86cd799439013",
    "email": "john@example.com"
  },
  "canManageMembers": true,
  "canManageProjects": true,
  "canManageBilling": false
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### DELETE /api/user/organizations/{organizationId}/members/{memberId}

Remove member

Remove a member from the organization. Requires owner + admin.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |
| `memberId` | string | yes | Member/Membership ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X DELETE "https://api.indexhog.com/api/user/organizations/{organizationId}/members/{memberId}" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/members/{memberId}", {
method: "DELETE",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Member removed successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/my-membership

Get my membership

Get the authenticated user's membership details in the organization.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/my-membership" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/my-membership", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Membership retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "organizationId": "550e8400-e29b-41d4-a716-446655440001",
  "role": "admin",
  "status": "active",
  "invitedAt": "2024-01-01T00:00:00.000Z",
  "joinedAt": "2024-01-02T00:00:00.000Z",
  "user": {
    "id": "507f1f77bcf86cd799439013",
    "email": "john@example.com"
  },
  "invitedBy": {
    "id": "507f1f77bcf86cd799439013",
    "email": "john@example.com"
  },
  "canManageMembers": true,
  "canManageProjects": true,
  "canManageBilling": false
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/invites

List organization invites

Get all pending invites for the organization.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/invites" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/invites", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Invites retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": [
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z",
    "organizationId": "550e8400-e29b-41d4-a716-446655440001",
    "role": "admin",
    "status": "active",
    "invitedAt": "2024-01-01T00:00:00.000Z",
    "joinedAt": "2024-01-02T00:00:00.000Z",
    "user": {
      "id": "507f1f77bcf86cd799439013",
      "email": "john@example.com"
    },
    "invitedBy": {
      "id": "507f1f77bcf86cd799439013",
      "email": "john@example.com"
    },
    "canManageMembers": true,
    "canManageProjects": true,
    "canManageBilling": false
  }
]
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### POST /api/user/organizations/{organizationId}/invites

Send invitations

Invite new members to the organization.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `emails` | string[] | yes | Email addresses to invite |  |
| `role` | AssignableRole | yes |  |  |

#### Request example

**curl**

```bash
curl -X POST "https://api.indexhog.com/api/user/organizations/{organizationId}/invites" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"emails":["user@example.com"],"role":"member"}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/invites", {
method: "POST",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "emails": [
    "user@example.com"
  ],
  "role": "member"
}),
});

const data = await response.json();
console.log(data);
```

#### Response `201` — Invites sent successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "sent": [
    "user@example.com"
  ],
  "alreadyMembers": [
    "user@example.com"
  ],
  "alreadyInvited": [
    "user@example.com"
  ],
  "invalidEmails": [
    "string"
  ]
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### DELETE /api/user/organizations/{organizationId}/invites/{memberId}

Cancel invitation

Cancel a pending invitation.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |
| `memberId` | string | yes | Member/Membership ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X DELETE "https://api.indexhog.com/api/user/organizations/{organizationId}/invites/{memberId}" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/invites/{memberId}", {
method: "DELETE",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Invite cancelled successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### POST /api/user/organizations/{organizationId}/invites/{memberId}/resend

Resend invitation

Resend an invitation email to a pending member.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |
| `memberId` | string | yes | Member/Membership ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X POST "https://api.indexhog.com/api/user/organizations/{organizationId}/invites/{memberId}/resend" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/invites/{memberId}/resend", {
method: "POST",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Invite resent successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "organizationId": "550e8400-e29b-41d4-a716-446655440001",
  "role": "admin",
  "status": "active",
  "invitedAt": "2024-01-01T00:00:00.000Z",
  "joinedAt": "2024-01-02T00:00:00.000Z",
  "user": {
    "id": "507f1f77bcf86cd799439013",
    "email": "john@example.com"
  },
  "invitedBy": {
    "id": "507f1f77bcf86cd799439013",
    "email": "john@example.com"
  },
  "canManageMembers": true,
  "canManageProjects": true,
  "canManageBilling": false
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### POST /api/user/invites/{token}/accept

Accept invitation

Accept an organization invitation using the invite token.

**Auth:** bearer · **Scopes:** `user:write`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `token` | string | yes | Invitation token |  |

#### Request example

**curl**

```bash
curl -X POST "https://api.indexhog.com/api/user/invites/{token}/accept" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/invites/{token}/accept", {
method: "POST",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `201` — Invitation accepted successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "organizationId": "550e8400-e29b-41d4-a716-446655440001",
  "role": "admin",
  "status": "active",
  "invitedAt": "2024-01-01T00:00:00.000Z",
  "joinedAt": "2024-01-02T00:00:00.000Z",
  "user": {
    "id": "507f1f77bcf86cd799439013",
    "email": "john@example.com"
  },
  "invitedBy": {
    "id": "507f1f77bcf86cd799439013",
    "email": "john@example.com"
  },
  "canManageMembers": true,
  "canManageProjects": true,
  "canManageBilling": false
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/settings/billing

Get billing settings

Get billing settings for the organization. Requires owner.

**Auth:** bearer · **Scopes:** `organization:manage-billing`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/settings/billing" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/settings/billing", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Billing settings retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "billingEmail": "billing@company.com",
  "effectiveEmail": "owner@company.com"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### PUT /api/user/organizations/{organizationId}/settings/billing

Update billing settings

Update billing settings for the organization. Requires owner.

**Auth:** bearer · **Scopes:** `organization:manage-billing`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `billingEmail` | string \| null | yes | Custom billing email, or null to use the current owner email. | `billing@company.com` |

#### Request example

**curl**

```bash
curl -X PUT "https://api.indexhog.com/api/user/organizations/{organizationId}/settings/billing" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"billingEmail":"billing@company.com"}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/settings/billing", {
method: "PUT",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "billingEmail": "billing@company.com"
}),
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Billing settings updated successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "billingEmail": "billing@company.com",
  "effectiveEmail": "owner@company.com"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/mfa

Get MFA settings

Get MFA settings for the organization.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/mfa" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/mfa", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — MFA settings retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "requireMfa": true,
  "gracePeriodDays": 7,
  "gracePeriodEndsAt": "2024-01-15T00:00:00.000Z"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### PUT /api/user/organizations/{organizationId}/mfa

Update MFA settings

Update MFA requirements for the organization. Requires owner + admin.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `requireMfa` | boolean | yes | Whether to require MFA | `true` |
| `gracePeriodDays` | number | no | Grace period in days | `7` |

#### Request example

**curl**

```bash
curl -X PUT "https://api.indexhog.com/api/user/organizations/{organizationId}/mfa" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"requireMfa":true,"gracePeriodDays":7}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/mfa", {
method: "PUT",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "requireMfa": true,
  "gracePeriodDays": 7
}),
});

const data = await response.json();
console.log(data);
```

#### Response `200` — MFA settings updated successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "requireMfa": true,
  "gracePeriodDays": 7,
  "gracePeriodEndsAt": "2024-01-15T00:00:00.000Z"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/mfa/compliance

Get MFA compliance status

Get MFA compliance status across organization members.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/mfa/compliance" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/mfa/compliance", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — MFA compliance status retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "isCompliant": true,
  "compliancePercentage": 85,
  "totalMembers": 10,
  "compliantMembers": 8,
  "nonCompliantMembers": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "userId": "550e8400-e29b-41d4-a716-446655440001",
      "email": "user@example.com"
    }
  ],
  "gracePeriodActive": false,
  "gracePeriodEndsAt": "2024-01-15T00:00:00.000Z"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/settings/sso

Get SSO configuration

Get SSO configuration for the organization.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/settings/sso" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/settings/sso", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — SSO configuration retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "enabled": true,
  "provider": "okta",
  "domain": "acme.com",
  "issuerUrl": "https://acme.okta.com",
  "clientId": "0oa..."
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### PUT /api/user/organizations/{organizationId}/settings/sso

Update SSO configuration

Update organization SSO configuration. Requires owner.

**Auth:** bearer · **Scopes:** `organization:manage-billing`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `provider` | SsoProvider | yes |  |  |
| `issuerUrl` | string | yes | OIDC issuer URL | `https://acme.okta.com` |
| `clientId` | string | yes | OAuth client ID |  |
| `clientSecret` | string | yes | OAuth client secret |  |

#### Request example

**curl**

```bash
curl -X PUT "https://api.indexhog.com/api/user/organizations/{organizationId}/settings/sso" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"provider":"okta","issuerUrl":"https://acme.okta.com","clientId":"string","clientSecret":"string"}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/settings/sso", {
method: "PUT",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "provider": "okta",
  "issuerUrl": "https://acme.okta.com",
  "clientId": "string",
  "clientSecret": "string"
}),
});

const data = await response.json();
console.log(data);
```

#### Response `200` — SSO configuration updated successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "enabled": true,
  "provider": "okta",
  "domain": "acme.com",
  "issuerUrl": "https://acme.okta.com",
  "clientId": "0oa..."
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### DELETE /api/user/organizations/{organizationId}/settings/sso

Disable SSO

Remove SSO configuration from the organization.

**Auth:** bearer · **Scopes:** `organization:manage-billing`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X DELETE "https://api.indexhog.com/api/user/organizations/{organizationId}/settings/sso" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/settings/sso", {
method: "DELETE",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — SSO configuration deleted successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### POST /api/user/organizations/{organizationId}/settings/sso/test

Test SSO configuration

Test the SSO configuration by attempting a connection.

**Auth:** bearer · **Scopes:** `organization:manage-members`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X POST "https://api.indexhog.com/api/user/organizations/{organizationId}/settings/sso/test" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/settings/sso/test", {
method: "POST",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — SSO test completed

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "success": true,
  "connectionSuccessful": true,
  "message": "string",
  "error": "string"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/domains

List organization domains

Get all domains associated with the organization.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/domains" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/domains", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Domains retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "domains": [
    {
      "id": "string",
      "domain": "acme.com",
      "status": "pending",
      "verificationMethod": "dns_txt",
      "dnsRecordName": "_indexhog-verify.acme.com",
      "dnsRecordValue": "abc123...",
      "verifiedAt": "string",
      "lastVerificationAttempt": "string",
      "verificationError": "string",
      "createdAt": "string",
      "organizationId": "550e8400-e29b-41d4-a716-446655440000",
      "updatedAt": "2024-01-15T10:30:00.000Z"
    }
  ]
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### POST /api/user/organizations/{organizationId}/domains

Add domain for verification

Add a new domain to verify. Returns a verification token for DNS TXT record.

**Auth:** bearer · **Scopes:** `organization:manage-billing`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `domain` | string | yes | Domain to add for verification | `acme.com` |

#### Request example

**curl**

```bash
curl -X POST "https://api.indexhog.com/api/user/organizations/{organizationId}/domains" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"domain":"acme.com"}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/domains", {
method: "POST",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "domain": "acme.com"
}),
});

const data = await response.json();
console.log(data);
```

#### Response `201` — Domain added, verification pending

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "string",
  "domain": "acme.com",
  "status": "pending",
  "verificationMethod": "dns_txt",
  "dnsRecordName": "_indexhog-verify.acme.com",
  "dnsRecordValue": "abc123...",
  "verifiedAt": "string",
  "lastVerificationAttempt": "string",
  "verificationError": "string",
  "createdAt": "string",
  "organizationId": "550e8400-e29b-41d4-a716-446655440000",
  "updatedAt": "2024-01-15T10:30:00.000Z"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/domains/{domainId}

Get domain

Get a specific domain for the organization.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |
| `domainId` | string | yes | Domain ID | `550e8400-e29b-41d4-a716-446655440001` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/domains/{domainId}" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/domains/{domainId}", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Domain retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "string",
  "domain": "acme.com",
  "status": "pending",
  "verificationMethod": "dns_txt",
  "dnsRecordName": "_indexhog-verify.acme.com",
  "dnsRecordValue": "abc123...",
  "verifiedAt": "string",
  "lastVerificationAttempt": "string",
  "verificationError": "string",
  "createdAt": "string",
  "organizationId": "550e8400-e29b-41d4-a716-446655440000",
  "updatedAt": "2024-01-15T10:30:00.000Z"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### DELETE /api/user/organizations/{organizationId}/domains/{domainId}

Remove domain

Remove a domain from the organization.

**Auth:** bearer · **Scopes:** `organization:manage-billing`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |
| `domainId` | string | yes | Domain ID | `550e8400-e29b-41d4-a716-446655440001` |

#### Request example

**curl**

```bash
curl -X DELETE "https://api.indexhog.com/api/user/organizations/{organizationId}/domains/{domainId}" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/domains/{domainId}", {
method: "DELETE",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Domain removed successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### POST /api/user/organizations/{organizationId}/domains/{domainId}/verify

Verify domain ownership

Attempt to verify domain ownership by checking DNS TXT record.

**Auth:** bearer · **Scopes:** `organization:manage-billing`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |
| `domainId` | string | yes | Domain ID | `550e8400-e29b-41d4-a716-446655440001` |

#### Request example

**curl**

```bash
curl -X POST "https://api.indexhog.com/api/user/organizations/{organizationId}/domains/{domainId}/verify" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/domains/{domainId}/verify", {
method: "POST",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Verification attempted

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "string",
  "domain": "acme.com",
  "status": "pending",
  "verificationMethod": "dns_txt",
  "dnsRecordName": "_indexhog-verify.acme.com",
  "dnsRecordValue": "abc123...",
  "verifiedAt": "string",
  "lastVerificationAttempt": "string",
  "verificationError": "string",
  "createdAt": "string",
  "organizationId": "550e8400-e29b-41d4-a716-446655440000",
  "updatedAt": "2024-01-15T10:30:00.000Z"
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### GET /api/user/organizations/{organizationId}/settings/security

Get security settings

Get security settings for the organization.

**Auth:** bearer · **Scopes:** `organization:read`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Request example

**curl**

```bash
curl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/settings/security" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/settings/security", {
method: "GET",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Security settings retrieved successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "authRequired": "any",
  "requireMfa": false
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```

### PUT /api/user/organizations/{organizationId}/settings/security

Update security settings

Update security settings for the organization. Requires owner.

**Auth:** bearer · **Scopes:** `organization:manage-security`

#### Path parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `organizationId` | string | yes | Organization ID | `550e8400-e29b-41d4-a716-446655440000` |

#### Body parameters

| Name | Type | Required | Description | Example |
| --- | --- | --- | --- | --- |
| `authRequired` | AuthRequired | no |  |  |
| `requireMfa` | boolean | no | Whether MFA is required for all members | `true` |

#### Request example

**curl**

```bash
curl -X PUT "https://api.indexhog.com/api/user/organizations/{organizationId}/settings/security" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"authRequired":"mfa","requireMfa":true}'
```

**JavaScript**

```javascript
const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/settings/security", {
method: "PUT",
headers: {
  "Authorization": "Bearer YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json",
},
body: JSON.stringify({
  "authRequired": "mfa",
  "requireMfa": true
}),
});

const data = await response.json();
console.log(data);
```

#### Response `200` — Security settings updated successfully

```json
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "authRequired": "any",
  "requireMfa": false
}
}
```

#### Response `401` — Unauthorized - Invalid or missing authentication

```json
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
```

#### Response `403` — Forbidden - Insufficient permissions

```json
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
```