# Organizations API

> Your customers' companies. Each organization has members, verified domains, SSO, audit events and policy that its teams inherit.

Part of the AGNT API reference. AGNT (https://agnt.ai) is the developer platform behind OpenAssistant (https://openassistant.us). Docs index: https://agnt.ai/llms.txt. Web page: https://agnt.ai/reference/api/organizations

Base URL: `https://api.agnt.ai`. Auth: `Authorization: Bearer ak_live_...`.

## GET /organizations

List organizations

Returns the organizations in your account, newest first. A user sees only their own organization.

**Query parameters**

- `page` (integer)
- `perPage` (integer)

**Responses**

- `200`: Orgs
  - `ok` (enum, required) One of: `true`.
  - `organizations` (object[], required)
    - `id` (string): Organization id
    - `account` (string): Your account id
    - `name` (string)
    - `generalInfo` (string): Background about the organization that its users' assistants know
    - `memberCount` (integer)
    - `defaultTeam` (string | null): Team where organization-scoped provisioning places new users
    - `sso` (object): Present once an SSO provider is configured. Admins see the full configuration; other members see enabled, enforced and provider only. The IdP certificate is never returned.
      - `enabled` (boolean)
      - `enforced` (boolean)
      - `provider` (string): saml_generic
      - `configuredAt` (string | null)
      - `saml` (object)
        - `entryPoint` (string)
        - `issuer` (string | null)
        - `signatureAlgorithm` (string)
        - `allowIdpInitiated` (boolean)
        - `spEntityId` (string | null): Set on the first sign-in
        - `acsUrl` (string | null): Set on the first sign-in
        - `sloUrl` (string | null): Set on the first sign-in
        - `attributeMapping` (object)
          - `email` (string)
          - `firstName` (string)
          - `lastName` (string)
          - `groups` (string)
        - `groupFilter` (object)
          - `enabled` (boolean)
          - `allowedGroups` (string[])
          - `requireAll` (boolean)
        - `groupRoleMapping` (object[])
          - `group` (string)
          - `role` (enum) One of: `admin`, `member`.
      - `scim` (object): Present when SCIM is enabled
        - `enabled` (boolean)
        - `endpoint` (string | null)
        - `hasToken` (boolean): Whether a SCIM token has been minted (the token itself is never returned)
        - `tokenCreatedAt` (string | null)
        - `version` (string)
      - `memberSync` (object)
        - `autoProvision` (boolean): Create a user on first SSO sign-in when none exists
    - `createdAt` (string)
    - `updatedAt` (string)
  - `page` (integer)
  - `perPage` (integer)
  - `total` (integer)

```bash
curl 'https://api.agnt.ai/organizations' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "organizations": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "name": "Ava",
      "generalInfo": "generalinfo"
    }
  ]
}
```

## POST /organizations

Create an organization

Creates an organization. Called as a user, that user becomes its owner. Requires an account key or an organization admin.

**Request body** (JSON)

- `name` (string, required)

**Responses**

- `201`: Created
  - `ok` (enum, required) One of: `true`.
  - `organization` (object, required)
    - `id` (string): Organization id
    - `account` (string): Your account id
    - `name` (string)
    - `generalInfo` (string): Background about the organization that its users' assistants know
    - `memberCount` (integer)
    - `defaultTeam` (string | null): Team where organization-scoped provisioning places new users
    - `sso` (object): Present once an SSO provider is configured. Admins see the full configuration; other members see enabled, enforced and provider only. The IdP certificate is never returned.
      - `enabled` (boolean)
      - `enforced` (boolean)
      - `provider` (string): saml_generic
      - `configuredAt` (string | null)
      - `saml` (object)
        - `entryPoint` (string)
        - `issuer` (string | null)
        - `signatureAlgorithm` (string)
        - `allowIdpInitiated` (boolean)
        - `spEntityId` (string | null): Set on the first sign-in
        - `acsUrl` (string | null): Set on the first sign-in
        - `sloUrl` (string | null): Set on the first sign-in
        - `attributeMapping` (object)
          - `email` (string)
          - `firstName` (string)
          - `lastName` (string)
          - `groups` (string)
        - `groupFilter` (object)
          - `enabled` (boolean)
          - `allowedGroups` (string[])
          - `requireAll` (boolean)
        - `groupRoleMapping` (object[])
          - `group` (string)
          - `role` (enum) One of: `admin`, `member`.
      - `scim` (object): Present when SCIM is enabled
        - `enabled` (boolean)
        - `endpoint` (string | null)
        - `hasToken` (boolean): Whether a SCIM token has been minted (the token itself is never returned)
        - `tokenCreatedAt` (string | null)
        - `version` (string)
      - `memberSync` (object)
        - `autoProvision` (boolean): Create a user on first SSO sign-in when none exists
    - `createdAt` (string)
    - `updatedAt` (string)
- `400`: name missing
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `403`: Not an organization admin
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `429`: More than 10 organizations created in a minute

```bash
curl 'https://api.agnt.ai/organizations' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Ava"
}'
```

Example response:

```json
{
  "ok": true,
  "organization": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "name": "Ava",
    "generalInfo": "generalinfo"
  }
}
```

## GET /organizations/{orgId}

Retrieve an organization

Retrieves an organization. Admins also get the full SSO and SCIM configuration; other members see whether SSO is enabled and enforced.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: Organization
  - Same fields as the `201` response of `POST /organizations`.
- `403`: Not a member of this organization
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `404`: Organization not found
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "organization": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "name": "Ava",
    "generalInfo": "generalinfo"
  }
}
```

## PUT /organizations/{orgId}

Update an organization

Updates an organization. Only the fields you send change. `defaultTeam` is the team that organization-scoped provisioning places new users on. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `name` (string)
- `generalInfo` (string): Background about the organization that its users' assistants know
- `defaultTeam` (string | null): Team id
- `defaultAssistant` (string | null): Assistant id

**Responses**

- `200`: Updated
  - Same fields as the `201` response of `POST /organizations`.
- `403`: Not an organization admin
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `404`: Organization not found
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>' \
  -X PUT \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Ava",
  "generalInfo": "generalinfo",
  "defaultTeam": "defaultteam",
  "defaultAssistant": "defaultassistant"
}'
```

Example response:

```json
{
  "ok": true,
  "organization": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "name": "Ava",
    "generalInfo": "generalinfo"
  }
}
```

## DELETE /organizations/{orgId}

Delete an organization

Deletes an organization and its domains. Its users and teams stay in your account, and teams left with no members are deleted. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: Deleted
  - `ok` (enum, required) One of: `true`.
  - `organization` (object, required)
    - `id` (string, required)
    - `deleted` (boolean)
    - `message` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>' \
  -X DELETE \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "organization": {
    "id": "6660c4a1f2e3b7d8a9c01234"
  }
}
```

## GET /organizations/{orgId}/members

List organization members

Returns the organization's users, newest first, with their organization role. `search` matches name and email.

**Path parameters**

- `orgId` (string, required)

**Query parameters**

- `page` (integer)
- `perPage` (integer)
- `search` (string)

**Responses**

- `200`: Members
  - `ok` (enum, required) One of: `true`.
  - `members` (object[], required)
    - `id` (string, required)
    - `email` (string, required)
    - `name` (string | null, required)
    - `avatarUrl` (string | null, required)
    - `organizationRole` (string, required)
    - `createdAt` (string, required)
  - `page` (integer)
  - `perPage` (integer)
  - `total` (integer)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/members' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "members": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "email": "jane@harborview.co",
      "name": "Ava",
      "avatarUrl": "https://harborview.co",
      "organizationRole": "organizationrole",
      "createdAt": "2026-10-15T14:30:00Z"
    }
  ]
}
```

## POST /organizations/{orgId}/members

Add an organization member

Adds a user to the organization by email, creating the user if needed, and places them on the organization's default team when one is set. New users receive an invitation email. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `email` (string, required)

**Responses**

- `201`: Added
  - `ok` (enum, required) One of: `true`.
  - `member` (object, required)
    - `id` (string, required)
    - `email` (string, required)
    - `name` (string | null, required)
    - `organizationRole` (string, required)
    - `createdAt` (string, required)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/members' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "email": "user@example.com"
}'
```

Example response:

```json
{
  "ok": true,
  "member": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "email": "jane@harborview.co",
    "name": "Ava",
    "organizationRole": "organizationrole",
    "createdAt": "2026-10-15T14:30:00Z"
  }
}
```

## DELETE /organizations/{orgId}/members/{userId}

Remove an organization member

Removes a user from the organization and its teams. The organization's only admin cannot be removed; promote another admin first.

**Path parameters**

- `orgId` (string, required)
- `userId` (string, required)

**Responses**

- `200`: Removed
  - `ok` (enum, required) One of: `true`.
  - `member` (object, required)
    - `id` (string, required)
    - `deleted` (boolean)
    - `message` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/members/<userId>' \
  -X DELETE \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "member": {
    "id": "6660c4a1f2e3b7d8a9c01234"
  }
}
```

## GET /organizations/{orgId}/domains

List domains

Returns the organization's domains, verified or not, each with the DNS TXT record that proves ownership. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: Domains
  - `ok` (enum, required) One of: `true`.
  - `domains` (object[], required)
    - `id` (string): Domain id
    - `domain` (string): Lower-cased domain, such as acme.com
    - `source` (enum): manual when added through the API; sso when added by an SSO configuration (these cannot be edited or removed directly) One of: `manual`, `sso`.
    - `verified` (boolean): True once the TXT record has been found
    - `autoJoin` (boolean): Whether people who sign up or are provisioned with this domain join the organization automatically, once verified
    - `txtRecordName` (string): Name of the DNS TXT record to publish, such as _agnt-verification.acme.com
    - `txtRecordValue` (string): Value of that TXT record
    - `verifiedAt` (string | null)
    - `lastCheckedAt` (string | null): Last verification attempt
    - `createdAt` (string)
    - `updatedAt` (string)
- `403`: Not an organization admin
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `404`: Organization not found
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/domains' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "domains": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "domain": "harborview.co",
      "source": "manual",
      "verified": true
    }
  ]
}
```

## POST /organizations/{orgId}/domains

Add a domain

Adds an unverified domain and returns the TXT record (`txtRecordName`, `txtRecordValue`) to publish in DNS. Then verify the domain. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `domain` (string, required): Such as acme.com
- `autoJoin` (boolean): Join people at this domain to the organization automatically, once verified

**Responses**

- `201`: Added
  - `ok` (enum, required) One of: `true`.
  - `domain` (object, required)
    - `id` (string): Domain id
    - `domain` (string): Lower-cased domain, such as acme.com
    - `source` (enum): manual when added through the API; sso when added by an SSO configuration (these cannot be edited or removed directly) One of: `manual`, `sso`.
    - `verified` (boolean): True once the TXT record has been found
    - `autoJoin` (boolean): Whether people who sign up or are provisioned with this domain join the organization automatically, once verified
    - `txtRecordName` (string): Name of the DNS TXT record to publish, such as _agnt-verification.acme.com
    - `txtRecordValue` (string): Value of that TXT record
    - `verifiedAt` (string | null)
    - `lastCheckedAt` (string | null): Last verification attempt
    - `createdAt` (string)
    - `updatedAt` (string)
- `400`: domain missing, or already added to this organization
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `403`: Not an organization admin
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `404`: Organization not found
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/domains' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "domain": "harborview.co"
}'
```

Example response:

```json
{
  "ok": true,
  "domain": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "domain": "harborview.co",
    "source": "manual",
    "verified": true
  }
}
```

## POST /organizations/{orgId}/domains/{domainId}/verify

Verify a domain

Looks up the domain's TXT record and marks the domain verified when the value matches. Until the record is visible in DNS, the call returns `400` and records `lastCheckedAt`; call it again after the record propagates.

**Path parameters**

- `orgId` (string, required)
- `domainId` (string, required)

**Responses**

- `200`: Verified
  - Same fields as the `201` response of `POST /organizations/{orgId}/domains`.
- `400`: TXT record not found yet, DNS lookup failed, or the domain is already verified
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `403`: Not an organization admin
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `404`: Organization or domain not found
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/domains/<domainId>/verify' \
  -X POST \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "domain": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "domain": "harborview.co",
    "source": "manual",
    "verified": true
  }
}
```

## PUT /organizations/{orgId}/domains/{domainId}

Update a domain

Sets `autoJoin`: whether people who sign in with this verified domain join the organization automatically. Domains managed by SSO cannot be changed. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)
- `domainId` (string, required)

**Request body** (JSON)

- `autoJoin` (boolean)

**Responses**

- `200`: Updated
  - Same fields as the `201` response of `POST /organizations/{orgId}/domains`.
- `403`: Not an organization admin, or the domain is managed by SSO
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `404`: Organization or domain not found
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/domains/<domainId>' \
  -X PUT \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "autoJoin": true
}'
```

Example response:

```json
{
  "ok": true,
  "domain": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "domain": "harborview.co",
    "source": "manual",
    "verified": true
  }
}
```

## DELETE /organizations/{orgId}/domains/{domainId}

Remove a domain

Removes a domain from the organization. To remove a domain managed by SSO, disable SSO first. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)
- `domainId` (string, required)

**Responses**

- `200`: Removed
  - `ok` (enum, required) One of: `true`.
  - `domain` (object, required)
    - `id` (string, required)
    - `deleted` (boolean)
    - `message` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/domains/<domainId>' \
  -X DELETE \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "domain": {
    "id": "6660c4a1f2e3b7d8a9c01234"
  }
}
```

## PUT /organizations/{orgId}/sso

Configure SSO

Configures SAML 2.0 sign-in for the organization's verified domains, with `provider: "saml_generic"`. Each object you send (`saml`, `memberSync`) is merged into the stored one, so you can change one field, such as the certificate, on its own. Sign-in works once `saml.entryPoint` and `saml.certificate` are set and `enabled` is `true`. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `enabled` (boolean): Turn SSO sign-in on for the organization's verified domains
- `enforced` (boolean): Users at those domains, and members of the organization, can sign in only through SSO
- `provider` (enum) One of: `saml_generic`.
- `saml` (object): The identity provider's details
  - `entryPoint` (string): The IdP's SSO URL. Required for sign-in.
  - `certificate` (string): The IdP's signing certificate (PEM or base64). Required for sign-in; every response is verified against it. Never returned.
  - `issuer` (string): Optional. The IdP's entity ID, stored for your reference.
  - `signatureAlgorithm` (string): Signature algorithm the IdP uses
  - `allowIdpInitiated` (boolean): Also accept sign-ins started from the IdP's app dashboard. Must be a boolean.
  - `attributeMapping` (object): Assertion attribute names. The defaults are the field names; the email falls back to the NameID.
    - `email` (string)
    - `firstName` (string)
    - `lastName` (string)
    - `groups` (string)
  - `groupFilter` (object): Only users in any of these groups (with requireAll, all of them) may sign in. Case-insensitive.
    - `enabled` (boolean)
    - `allowedGroups` (string[])
    - `requireAll` (boolean)
  - `groupRoleMapping` (object[]): Sets the user's organization role at each sign-in; the first matching group wins.
    - `group` (string)
    - `role` (enum) One of: `admin`, `member`.
- `memberSync` (object)
  - `autoProvision` (boolean): true: a person with no user yet is created on first sign-in. false: only users you have already provisioned can sign in.

**Responses**

- `200`: Updated organization, with the full SSO configuration
  - Same fields as the `201` response of `POST /organizations`.
- `400`: saml.allowIdpInitiated is not a boolean
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `403`: Not an organization admin
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `404`: Organization not found
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/sso' \
  -X PUT \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "enabled": true,
  "enforced": true,
  "provider": "saml_generic",
  "saml": {
    "entryPoint": "https://harborview.okta.com/app/harborview_agnt/exk7q2m9vb4XhR1d5x7/sso/saml",
    "certificate": "MIIDqDCCApCgAwIBAgIGAY...",
    "attributeMapping": {
      "email": "email",
      "firstName": "givenName",
      "lastName": "sn",
      "groups": "groups"
    },
    "groupRoleMapping": [
      {
        "group": "harborview-agnt-admins",
        "role": "admin"
      }
    ]
  },
  "memberSync": {
    "autoProvision": true
  }
}'
```

Example response:

```json
{
  "ok": true,
  "organization": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "name": "Ava",
    "generalInfo": "generalinfo"
  }
}
```

## DELETE /organizations/{orgId}/sso

Disable SSO

Turns SSO off and clears the SSO configuration, including the SCIM token. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: Disabled
  - Same fields as the `201` response of `POST /organizations`.
- `403`: Not an organization admin
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)
- `404`: Organization not found
  - `status` (integer)
  - `error_code` (string)
  - `error` (string)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/sso' \
  -X DELETE \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "organization": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "name": "Ava",
    "generalInfo": "generalinfo"
  }
}
```

## GET /organizations/{orgId}/settings/model-tiers

Retrieve default model tiers

Returns the organization's default model tiers for new chats and tasks. `null` means the organization uses the account default.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: Model tiers
  - `ok` (enum, required) One of: `true`.
  - `defaultModelTiers` (object, required)
    - `chat` (enum, required) One of: `low`, `medium`, `high`, `ultra`, `null`.
    - `task` (enum, required) One of: `low`, `medium`, `high`, `ultra`, `null`.

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/settings/model-tiers' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "defaultModelTiers": {
    "chat": "low",
    "task": "low"
  }
}
```

## PATCH /organizations/{orgId}/settings/model-tiers

Update default model tiers

Sets the organization's default model tiers for new chats and tasks: `low`, `medium`, `high` or `ultra`. `null` uses the account default. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `chat` (enum) One of: `low`, `medium`, `high`, `ultra`, `null`.
- `task` (enum) One of: `low`, `medium`, `high`, `ultra`, `null`.

**Responses**

- `200`: Updated
  - `ok` (enum, required) One of: `true`.
  - `defaultModelTiers` (object, required)
    - `chat` (enum, required) One of: `low`, `medium`, `high`, `ultra`, `null`.
    - `task` (enum, required) One of: `low`, `medium`, `high`, `ultra`, `null`.

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/settings/model-tiers' \
  -X PATCH \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "chat": "low",
  "task": "low"
}'
```

Example response:

```json
{
  "ok": true,
  "defaultModelTiers": {
    "chat": "low",
    "task": "low"
  }
}
```

## GET /organizations/{orgId}/audit-events

List organization audit events

Returns the organization's audit events from the last 30 days, newest first. Filter by actor, action, entity type and time range (`after`, `before`).

**Path parameters**

- `orgId` (string, required)

**Query parameters**

- `page` (integer)
- `perPage` (integer)
- `actor` (string): The actor's email (for actions an assistant took, the assistant's name). Exact match.
- `action` (string)
- `entityType` (string)
- `after` (string)
- `before` (string)

**Responses**

- `200`: Events
  - `ok` (enum, required) One of: `true`.
  - `events` (object[], required)
    - `id` (string, required)
    - `account` (string, required)
    - `organization` (string, required)
    - `actor` (string | null, required)
    - `action` (string, required)
    - `entityType` (string, required)
    - `entityId` (string | null, required)
    - `metadata` (object, required)
    - `createdAt` (string, required)
  - `page` (integer)
  - `perPage` (integer)
  - `total` (integer)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/audit-events' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "events": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "organization": "organization",
      "actor": "actor",
      "action": "action",
      "entityType": "entitytype"
    }
  ]
}
```

## GET /organizations/{orgId}/audit-logging

Retrieve audit export settings

Returns whether audit logging is on for the organization, and the S3 destination for exports.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: Config
  - `ok` (enum, required) One of: `true`.
  - `auditLogging` (object, required)
    - `enabled` (boolean, required)
    - `s3BucketArn` (string | null, required)
    - `s3Prefix` (string, required)
    - `roleArn` (string | null, required)
    - `region` (string | null, required)
    - `lastDeliveredAt` (string | null, required)
    - `deliveryConfigured` (boolean, required)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/audit-logging' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "auditLogging": {
    "enabled": true,
    "s3BucketArn": "s3bucketarn",
    "s3Prefix": "s3prefix",
    "roleArn": "rolearn",
    "region": "region",
    "lastDeliveredAt": "2026-10-15T14:30:00Z"
  }
}
```

## PUT /organizations/{orgId}/audit-logging

Configure audit export

Turns audit logging on or off and sets the S3 bucket, key prefix, IAM role and region that exports are delivered to.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `enabled` (boolean)
- `s3BucketArn` (string | null)
- `s3Prefix` (string)
- `roleArn` (string | null)
- `region` (string | null)

**Responses**

- `200`: Updated
  - Same fields as the `200` response of `GET /organizations/{orgId}/audit-logging`.

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/audit-logging' \
  -X PUT \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "enabled": true,
  "s3BucketArn": "s3bucketarn",
  "s3Prefix": "s3prefix",
  "roleArn": "rolearn"
}'
```

Example response:

```json
{
  "ok": true,
  "auditLogging": {
    "enabled": true,
    "s3BucketArn": "s3bucketarn",
    "s3Prefix": "s3prefix",
    "roleArn": "rolearn",
    "region": "region",
    "lastDeliveredAt": "2026-10-15T14:30:00Z"
  }
}
```

## POST /organizations/{orgId}/audit-logging/deliver

Export audit events

Queues an export of audit events to the organization's S3 bucket and returns the job with `202`. `from` and `to` default to the 30 days before the start of today (UTC). Requires audit logging to be on and an S3 destination to be configured.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `from` (string)
- `to` (string)

**Responses**

- `202`: Job queued
  - `ok` (enum, required) One of: `true`.
  - `deliveryJob` (object, required)
    - `id` (string, required)
    - `organization` (string, required)
    - `requestedBy` (string | null, required)
    - `status` (enum, required) One of: `pending`, `running`, `completed`, `failed`.
    - `from` (string, required)
    - `to` (string, required)
    - `filesCopied` (number, required)
    - `errors` (string[], required)
    - `completedAt` (string | null, required)
    - `createdAt` (string, required)

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/audit-logging/deliver' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "from": "2026-10-15T14:30:00Z",
  "to": "2026-10-15T14:30:00Z"
}'
```

## GET /organizations/{orgId}/audit-logging/deliver/{jobId}

Retrieve an audit export

Retrieves the status of an audit export job. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)
- `jobId` (string, required)

**Responses**

- `200`: Delivery job
  - `ok` (boolean)
  - `deliveryJob` (object)
    - `id` (string)
    - `organization` (string)
    - `requestedBy` (string | null): Email of the admin who requested it
    - `status` (enum) One of: `pending`, `running`, `completed`, `failed`.
    - `from` (string)
    - `to` (string)
    - `filesCopied` (integer)
    - `deliveryErrors` (string[])
    - `completedAt` (string | null)
    - `createdAt` (string)
- `403`: Organization admin role required
- `404`: Organization or job not found

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/audit-logging/deliver/<jobId>' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "deliveryJob": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "organization": "organization",
    "requestedBy": "requestedby",
    "status": "pending"
  }
}
```

## POST /organizations/{orgId}/sso/scim-token

Create a SCIM token

Creates a SCIM bearer token for the organization and returns it once. The previous token stops working. Your identity provider uses it against `https://<your hosted app domain>/api/scim/v2`. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: New token, shown once
  - `ok` (boolean)
  - `scim` (object)
    - `token` (string)
- `403`: Organization admin role required
- `404`: Organization not found

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/sso/scim-token' \
  -X POST \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "scim": {
    "token": "ak_live_…"
  }
}
```

## GET /organizations/{orgId}/settings/resource-permissions

Retrieve organization policy

Returns the organization's approval mode per action type, which action types are locked for teams and users, and whether assistants can hand work to each other. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: Policy
  - `resourcePermissions` (object)
    - `approvalSettings` (object)
      - `matrix` (object | null): Action types: email_as_user (email from the user's mailbox), email_as_assistant (email from the assistant's mailbox), messaging (texts and chat messages), voice_call_as_assistant, voice_call_as_user, calendar, files, drive, contacts, third_party_skills (actions in connected apps), website.
        - `email_as_user` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `email_as_assistant` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `messaging` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `voice_call_as_assistant` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `voice_call_as_user` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `calendar` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `files` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `drive` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `contacts` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `third_party_skills` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `website` (object)
          - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
          - `timeBoxedWindowMin` (number | null)
        - `locked` (string[]): Action types lower levels cannot loosen. Sent inside matrix, next to the cells; replaces the list.
    - `collaboration` (object)
      - `peerDelegation` (boolean): Whether assistants may hand work to the assistants of other users in the organization
      - `peerDelegationLockedByDeveloper` (boolean): True when your account has turned this off for every organization; it cannot be turned on here
- `403`: Organization admin role required
- `404`: Organization not found

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/settings/resource-permissions' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "resourcePermissions": {
    "approvalSettings": {
      "matrix": {
        "email_as_user": {
          "mode": null,
          "timeBoxedWindowMin": null
        },
        "email_as_assistant": {
          "mode": null,
          "timeBoxedWindowMin": null
        },
        "messaging": {
          "mode": null,
          "timeBoxedWindowMin": null
        },
        "voice_call_as_assistant": {
          "mode": null,
          "timeBoxedWindowMin": null
        }
      }
    },
    "collaboration": {
      "peerDelegation": true,
      "peerDelegationLockedByDeveloper": true
    }
  }
}
```

## PATCH /organizations/{orgId}/settings/resource-permissions

Update organization policy

Sets the approval mode per action type, the action types teams and users cannot loosen (`matrix.locked`), and assistant-to-assistant collaboration. Cells you send replace those cells, and `locked` replaces the list. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `matrix` (object): Top-level here (the team endpoint nests it under approvalSettings). Action types: email_as_user (email from the user's mailbox), email_as_assistant (email from the assistant's mailbox), messaging (texts and chat messages), voice_call_as_assistant, voice_call_as_user, calendar, files, drive, contacts, third_party_skills (actions in connected apps), website.
  - `email_as_user` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `email_as_assistant` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `messaging` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `voice_call_as_assistant` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `voice_call_as_user` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `calendar` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `files` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `drive` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `contacts` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `third_party_skills` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `website` (object)
    - `mode` (enum): auto: acts on its own. time-boxed: waits out a window in which the user can stop it. manual: waits for approval. One of: `auto`, `time-boxed`, `manual`, `null`.
    - `timeBoxedWindowMin` (number | null)
  - `locked` (string[]): Action types lower levels cannot loosen. Sent inside matrix, next to the cells; replaces the list.
- `collaboration` (object)
  - `peerDelegation` (boolean): Whether assistants may hand work to the assistants of other users in the organization

**Responses**

- `200`: Updated policy, same shape as GET
  - `resourcePermissions` (object)
- `403`: Organization admin role required
- `404`: Organization not found
- `409`: Your account has turned collaboration off, so it cannot be turned on here

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/settings/resource-permissions' \
  -X PATCH \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "matrix": {
    "email_as_user": {
      "mode": "manual"
    },
    "locked": [
      "email_as_user"
    ]
  }
}'
```

Example response:

```json
{
  "resourcePermissions": {}
}
```

## GET /organizations/{orgId}/library

Retrieve the skill library

Returns which skill tiers the organization allows and which skills are enabled. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Responses**

- `200`: Library
  - `orgLibrary` (object)
    - `allowedTiers` (string[])
    - `enabledSkills` (string[]): Skill ids
- `403`: Organization admin role required
- `404`: Organization not found

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/library' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "orgLibrary": {
    "allowedTiers": [
      "agnt"
    ],
    "enabledSkills": [
      "enabledskill"
    ]
  }
}
```

## PATCH /organizations/{orgId}/library

Update the skill library

Sets which skill tiers the organization allows and which skills are enabled. `bulkEnableTier` enables every listed skill in a tier. Requires an account key or an organization admin.

**Path parameters**

- `orgId` (string, required)

**Request body** (JSON)

- `allowedTiers` (string[])
- `enabledSkills` (string[]): Skill ids; replaces the list
- `bulkEnableTier` (enum) One of: `agnt`, `official`, `community`.

**Responses**

- `200`: Library
  - `orgLibrary` (object)
    - `allowedTiers` (string[])
    - `enabledSkills` (string[])
- `403`: Organization admin role required
- `404`: Organization not found

```bash
curl 'https://api.agnt.ai/organizations/<orgId>/library' \
  -X PATCH \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{
  "allowedTiers": [
    "agnt"
  ],
  "enabledSkills": [
    "enabledskill"
  ],
  "bulkEnableTier": "agnt"
}'
```

Example response:

```json
{
  "orgLibrary": {
    "allowedTiers": [
      "allowedtier"
    ],
    "enabledSkills": [
      "enabledskill"
    ]
  }
}
```

## GET /audit-events

List audit events

Returns the audit trail for your whole account, newest first, with filters and pagination. Requires an account key.

**Query parameters**

- `actor` (string): The actor's email (for actions an assistant took, the assistant's name). Exact match.
- `entityType` (string): Filter by entity type, such as organization or team
- `entityId` (string): Filter by entity id
- `action` (string): Filter by action, such as sso.disabled
- `after` (string): Created at or after this time
- `before` (string): Created at or before this time
- `page` (integer): Page number
- `perPage` (integer): Page size

**Responses**

- `200`: Audit events
  - `ok` (boolean)
  - `events` (object[])
    - `id` (string)
    - `account` (string)
    - `actor` (string | null)
    - `action` (string)
    - `entityType` (string)
    - `entityId` (string | null)
    - `metadata` (object)
    - `createdAt` (string)
  - `page` (integer)
  - `perPage` (integer)
  - `total` (integer)

```bash
curl 'https://api.agnt.ai/audit-events' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "events": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "account": "account",
      "actor": "actor",
      "action": "action"
    }
  ],
  "page": 1,
  "perPage": 20
}
```

## GET /audit-events/{eventId}

Retrieve an audit event

Retrieves one audit event from your account.

**Path parameters**

- `eventId` (string, required)

**Responses**

- `200`: Audit event
  - `ok` (boolean)
  - `event` (object)
    - `id` (string)
    - `account` (string)
    - `actor` (string | null)
    - `action` (string)
    - `entityType` (string)
    - `entityId` (string | null)
    - `metadata` (object)
    - `createdAt` (string)
- `404`: Audit event not found

```bash
curl 'https://api.agnt.ai/audit-events/<eventId>' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "ok": true,
  "event": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "account": "account",
    "actor": "actor",
    "action": "action"
  }
}
```
