# Organization Management API

Administer organization members and usage limits, and review enterprise control history.

## List enterprise control change history

`GET /api/v0/organization/enterprise-controls/history`

Returns a paginated list of enterprise control setting changes for the organization, ordered by revision descending. Properties for the `settings` object may be added, removed, or renamed between API versions. Clients should parse it as a generic JSON object.

```bash
curl 'https://api.factory.ai/api/v0/organization/enterprise-controls/history' \
  -H 'Authorization: Bearer $FACTORY_API_KEY'
```

**Parameters**

- `limit` (`string`) - Query parameter. Maximum number of items to return (1-100)
- `cursor` (`string`) - Query parameter. Cursor for pagination

**Response:** `200` - Response for status 200

## Get global user credits limit

`GET /api/v0/organization/usage/limits/global`

Returns the global per-user credits limit for the organization. This limit applies to all users who do not have an individual override.

```bash
curl 'https://api.factory.ai/api/v0/organization/usage/limits/global' \
  -H 'Authorization: Bearer $FACTORY_API_KEY'
```

**Response:** `200` - Response for status 200

## Set global user credits limit

`PUT /api/v0/organization/usage/limits/global`

Set the global per-user credits limit for the organization. This limit applies to all users who do not have an individual override. Pass null to remove the global limit.

```bash
curl -X PUT 'https://api.factory.ai/api/v0/organization/usage/limits/global' \
  -H 'Authorization: Bearer $FACTORY_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Response:** `200` - Response for status 200

## Get user credits limits

`GET /api/v0/organization/usage/limits/users`

Returns the global per-user credits limit and any individual user overrides for the organization.

```bash
curl 'https://api.factory.ai/api/v0/organization/usage/limits/users' \
  -H 'Authorization: Bearer $FACTORY_API_KEY'
```

**Response:** `200` - Response for status 200

## Set user credits limits

`PUT /api/v0/organization/usage/limits/users`

Set individual per-user credits limits for one or more users. Supports bulk updates (up to 100 users per request). Identify each user by email. Pass null for limit to remove an individual override.

```bash
curl -X PUT 'https://api.factory.ai/api/v0/organization/usage/limits/users' \
  -H 'Authorization: Bearer $FACTORY_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Response:** `200` - Response for status 200

## List organization users

`GET /api/v0/organization/users`

Returns a paginated list of users in the Factory organization.

```bash
curl 'https://api.factory.ai/api/v0/organization/users' \
  -H 'Authorization: Bearer $FACTORY_API_KEY'
```

**Parameters**

- `limit` (`string`) - Query parameter. Maximum number of items to return (1-100)
- `cursor` (`string`) - Query parameter. Cursor for pagination

**Response:** `200` - Response for status 200

## Remove a user

`DELETE /api/v0/organization/users`

Removes a user from the organization by email. Works for both active members (deletes membership) and pending invitations (revokes the invite).

```bash
curl -X DELETE 'https://api.factory.ai/api/v0/organization/users' \
  -H 'Authorization: Bearer $FACTORY_API_KEY'
```

**Parameters**

- `email` (`string <email>`, required) - Query parameter. Email address of the user to remove

**Response:** `204` - Response for status 204

## Invite or update a user

`POST /api/v0/organization/users/invite`

Sends an invitation to a user to join the organization. If the user is already a member, updates their role to the specified value. If the user has a pending invite, returns the current status without changes. If the organization has reached its seat limit, returns status "error" with a descriptive error message.

```bash
curl -X POST 'https://api.factory.ai/api/v0/organization/users/invite' \
  -H 'Authorization: Bearer $FACTORY_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Response:** `200` - Response for status 200
