# Organizations

> Manage your organization settings and review the org-level audit endpoints. Create, get, update, and delete organizations plus a paginated audit log listing.

Source: https://zop.dev/developer-docs/administration/organizations

---

Manage your organization settings and review audit logs of all actions taken.

## Organizations

### List Organizations

### GET /organisations

List all organizations the current user belongs to.

### Create Organization

### POST /organisations

Create a new organization.

```bash title="Request"
curl -X POST https://zopnight.com/api/organisations \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Corp"
  }'
```

```json title="Response"
{
  "data": {
    "id": "org_acme001",
    "name": "Acme Corp",
    "createdBy": "founder@acme.com",
    "createdAt": "2025-01-05T08:00:00Z",
    "updatedAt": "2025-01-05T08:00:00Z"
  }
}
```

### Get Current Organization

### GET /organisation

Get details of the currently selected organization.

### Update Organization

### PUT /organisation

Update the current organization

### Delete Organization

### DELETE /organisation

Delete the current organization. This removes all associated data including users, teams, and resources.

## Audit Logs

Track all actions performed within the organization. Audit logs are immutable and retained for compliance and troubleshooting purposes.

### List Audit Logs

### GET /audit-logs

List audit log entries. Supports filtering by action, user email, product scope, and pagination.

  Query parameters: `?action=schedule.created&email=admin@company.com&include=cost,scheduling&page=1&limit=50`

  #### Product scopes

  Audit events are tagged with the product that produced them. Use the `include` parameter (comma-separated, repeatable) to scope the query to one or more product surfaces.

  | Scope | Covers |
  |---|---|
  | `platform` | Auth, users, teams, roles, organizations, cloud accounts |
  | `scheduling` | Schedules, resource groups, overrides, schedule executions |
  | `cost` | Reports, recommendations, anomalies, budgets, billing upgrade |
  | `provisioning` | Deployment Spaces, provisioning jobs, Helm components |
  | `deployment` | Deploy service activity |

```bash title="Request"
curl -X GET "https://zopnight.com/api/audit-logs?page=1&limit=10" \
  -H "Authorization: Bearer <token>"
```

```json title="Response"
{
  "data": [
    {
      "id": "log_001",
      "action": "schedule.created",
      "email": "admin@company.com",
      "resourceUID": "sch_abc123",
      "details": "Created schedule 'Business Hours'",
      "createdAt": "2025-03-15T10:30:00Z"
    },
    {
      "id": "log_002",
      "action": "team.member.added",
      "email": "admin@company.com",
      "resourceUID": "team_abc123",
      "details": "Added engineer@company.com to team 'Platform Engineering'",
      "createdAt": "2025-03-15T10:15:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 248
  }
}
```

## Organization Object

| Field | Type | Description |
|---|---|---|
| `id` | string | Unique organization ID |
| `name` | string | Organization display name |
| `createdBy` | string | Email of the creator |
| `createdAt` | string | ISO 8601 creation timestamp |
| `updatedAt` | string | ISO 8601 last update timestamp |

## Audit Log Object

| Field | Type | Description |
|---|---|---|
| `id` | string | Unique audit log entry ID |
| `action` | string | Action that was performed (e.g., schedule.created) |
| `email` | string | Email of the user who performed the action |
| `resourceUID` | string | UID of the affected resource, if applicable |
| `details` | string | Human-readable description of the action |
| `createdAt` | string | ISO 8601 timestamp of when the action occurred |
