Skip to content

Organizations API

Manage organizations, members, invitations, roles, and audit logs.

Endpoints Summary

Organization Management

MethodEndpointDescription
GET/api/orgsList your organizations
POST/api/orgsCreate an organization
GET/api/orgs/:orgIdGet organization details
PUT/api/orgs/:orgIdUpdate organization
DELETE/api/orgs/:orgIdDelete organization

Member Management

MethodEndpointDescription
GET/api/orgs/:orgId/membersList members
PUT/api/orgs/:orgId/members/:userIdUpdate member role
DELETE/api/orgs/:orgId/members/:userIdRemove member
POST/api/orgs/:orgId/members/:userId/moveMove member to another org
POST/api/orgs/:orgId/transfer-ownershipTransfer ownership
POST/api/orgs/:orgId/leaveLeave organization

Invitations

MethodEndpointDescription
POST/api/orgs/:orgId/invitations/emailInvite by email
POST/api/orgs/:orgId/invitations/linkGenerate invite link
GET/api/orgs/:orgId/invitationsList invitations
DELETE/api/orgs/:orgId/invitations/:idRevoke invitation

Audit Logs

MethodEndpointDescription
GET/api/orgs/:orgId/audit-logsList audit logs
GET/api/orgs/:orgId/audit-logs/exportExport audit logs (CSV)

Custom Roles Team+

MethodEndpointDescription
GET/api/orgs/:orgId/rolesList custom roles
POST/api/orgs/:orgId/rolesCreate a custom role
PATCH/api/orgs/:orgId/roles/:roleIdUpdate a custom role
DELETE/api/orgs/:orgId/roles/:roleIdDelete a custom role

Authentication

All endpoints require a Bearer token in the Authorization header.

Authorization: Bearer <your-api-token>

List Organizations

GET /api/orgs

Returns all organizations you belong to.

Example:

bash
curl -X GET "https://api.controlinfra.com/api/orgs" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "organizations": [
    {
      "_id": "663e1a2b3c4d5e6f7a8b9c0d",
      "name": "Acme Corp",
      "role": "owner",
      "memberCount": 8,
      "plan": "team",
      "createdAt": "2024-06-01T00:00:00Z"
    }
  ]
}

Create an Organization

POST /api/orgs

Request Body:

FieldTypeRequiredDescription
namestringYesOrganization name

Example:

bash
curl -X POST "https://api.controlinfra.com/api/orgs" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Corp"
  }'

Response: 201 Created

json
{
  "_id": "663e1a2b3c4d5e6f7a8b9c0d",
  "name": "Acme Corp",
  "role": "owner",
  "plan": "free",
  "createdAt": "2025-01-15T10:00:00Z"
}

Get Organization Details

GET /api/orgs/:orgId

Example:

bash
curl -X GET "https://api.controlinfra.com/api/orgs/663e1a2b3c4d5e6f7a8b9c0d" \
  -H "Authorization: Bearer YOUR_TOKEN"

Update Organization

PUT /api/orgs/:orgId

Requires Owner or Admin role.

Request Body:

FieldTypeDescription
namestringOrganization name

Example:

bash
curl -X PUT "https://api.controlinfra.com/api/orgs/663e1a2b3c4d5e6f7a8b9c0d" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Corporation"
  }'

Delete Organization

DELETE /api/orgs/:orgId

Requires Owner role. Permanently deletes the organization and all associated data.

DANGER

This action is irreversible. All repositories, scans, drifts, and settings are permanently deleted.

Example:

bash
curl -X DELETE "https://api.controlinfra.com/api/orgs/663e1a2b3c4d5e6f7a8b9c0d" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response: 204 No Content


List Members

GET /api/orgs/:orgId/members

Example:

bash
curl -X GET "https://api.controlinfra.com/api/orgs/663e1a2b.../members" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "members": [
    {
      "userId": "660a1b2c...",
      "username": "johndoe",
      "email": "john@acme.com",
      "role": "owner",
      "joinedAt": "2024-06-01T00:00:00Z"
    },
    {
      "userId": "660a1b2d...",
      "username": "janedoe",
      "email": "jane@acme.com",
      "role": "admin",
      "joinedAt": "2024-07-15T00:00:00Z"
    }
  ]
}

Update Member Role

PUT /api/orgs/:orgId/members/:userId

Requires Owner or Admin role.

Request Body:

FieldTypeRequiredDescription
rolestringYesNew role: admin, member, viewer, or a custom role ID

Example:

bash
curl -X PUT "https://api.controlinfra.com/api/orgs/663e1a2b.../members/660a1b2d..." \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "admin"
  }'

Remove Member

DELETE /api/orgs/:orgId/members/:userId

Requires Owner or Admin role. Cannot remove the owner.

Example:

bash
curl -X DELETE "https://api.controlinfra.com/api/orgs/663e1a2b.../members/660a1b2d..." \
  -H "Authorization: Bearer YOUR_TOKEN"

Response: 204 No Content


Move Member

POST /api/orgs/:orgId/members/:userId/move

Move a member from this organization to another. Requires Owner or Admin role in both organizations.

Request Body:

FieldTypeRequiredDescription
targetOrgIdstringYesTarget organization ID
rolestringNoRole in the target org (default: member)

Example:

bash
curl -X POST "https://api.controlinfra.com/api/orgs/663e1a2b.../members/660a1b2d.../move" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "targetOrgId": "663e1a2c...",
    "role": "member"
  }'

Transfer Ownership

POST /api/orgs/:orgId/transfer-ownership

Requires Owner role.

Request Body:

FieldTypeRequiredDescription
newOwnerIdstringYesUser ID of the new owner (must be a current member)

Example:

bash
curl -X POST "https://api.controlinfra.com/api/orgs/663e1a2b.../transfer-ownership" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "newOwnerId": "660a1b2d..."
  }'

Leave Organization

POST /api/orgs/:orgId/leave

Leave the organization. Owners must transfer ownership before leaving.

Example:

bash
curl -X POST "https://api.controlinfra.com/api/orgs/663e1a2b.../leave" \
  -H "Authorization: Bearer YOUR_TOKEN"

Invite by Email

POST /api/orgs/:orgId/invitations/email

Request Body:

FieldTypeRequiredDescription
emailstringYesEmail address
rolestringNoRole to assign (default: member)

Example:

bash
curl -X POST "https://api.controlinfra.com/api/orgs/663e1a2b.../invitations/email" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "newuser@acme.com",
    "role": "member"
  }'

Response: 201 Created

json
{
  "_id": "667a1b2c...",
  "email": "newuser@acme.com",
  "role": "member",
  "status": "pending",
  "expiresAt": "2025-01-22T10:00:00Z"
}

POST /api/orgs/:orgId/invitations/link

Request Body:

FieldTypeRequiredDescription
rolestringNoDefault role for users joining via link (default: member)

Example:

bash
curl -X POST "https://api.controlinfra.com/api/orgs/663e1a2b.../invitations/link" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "viewer"
  }'

Response: 201 Created

json
{
  "_id": "667a1b2c...",
  "link": "https://console.controlinfra.com/join/abc123def456",
  "role": "viewer",
  "expiresAt": "2025-01-22T10:00:00Z"
}

List Invitations

GET /api/orgs/:orgId/invitations

Example:

bash
curl -X GET "https://api.controlinfra.com/api/orgs/663e1a2b.../invitations" \
  -H "Authorization: Bearer YOUR_TOKEN"

Revoke Invitation

DELETE /api/orgs/:orgId/invitations/:id

Example:

bash
curl -X DELETE "https://api.controlinfra.com/api/orgs/663e1a2b.../invitations/667a1b2c..." \
  -H "Authorization: Bearer YOUR_TOKEN"

Response: 204 No Content


List Audit Logs

GET /api/orgs/:orgId/audit-logs

Query Parameters:

ParameterTypeDescription
actionstringFilter by action type
actorIdstringFilter by actor user ID
fromstringStart date (ISO 8601)
tostringEnd date (ISO 8601)
pagenumberPage number (default: 1)
limitnumberItems per page (default: 50)

Example:

bash
curl -X GET "https://api.controlinfra.com/api/orgs/663e1a2b.../audit-logs?action=member.invited&limit=20" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "logs": [
    {
      "_id": "668a1b2c...",
      "action": "member.invited",
      "actor": {
        "userId": "660a1b2c...",
        "username": "johndoe"
      },
      "target": {
        "email": "newuser@acme.com"
      },
      "metadata": {
        "role": "member"
      },
      "ip": "203.0.113.42",
      "timestamp": "2025-01-15T10:00:00Z"
    }
  ],
  "total": 156,
  "page": 1,
  "pages": 4
}

Export Audit Logs Team+

GET /api/orgs/:orgId/audit-logs/export

Returns audit logs as a CSV file download.

Query Parameters: Same as List Audit Logs.

Example:

bash
curl -X GET "https://api.controlinfra.com/api/orgs/663e1a2b.../audit-logs/export?from=2025-01-01" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -o audit-logs.csv

List Custom Roles Team+

GET /api/orgs/:orgId/roles

Example:

bash
curl -X GET "https://api.controlinfra.com/api/orgs/663e1a2b.../roles" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "roles": [
    {
      "_id": "669a1b2c...",
      "name": "DevOps Lead",
      "description": "Full access to scans and guardrails, read-only members",
      "permissions": [
        "repositories:read",
        "repositories:write",
        "scans:read",
        "scans:write",
        "guardrails:read",
        "guardrails:write",
        "members:read"
      ],
      "memberCount": 3,
      "createdAt": "2025-01-01T00:00:00Z"
    }
  ]
}

Create a Custom Role Team+

POST /api/orgs/:orgId/roles

Request Body:

FieldTypeRequiredDescription
namestringYesRole name
descriptionstringNoRole description
permissionsstring[]YesArray of permission slugs

Available Permissions:

PermissionDescription
repositories:readView repositories
repositories:writeCreate, edit, delete repositories
scans:readView scan results
scans:writeTrigger and configure scans
drifts:readView drift reports
drifts:writeResolve, ignore drifts
guardrails:readView guardrails
guardrails:writeCreate, edit, deploy guardrails
members:readView member list
members:writeInvite, edit roles, remove members
settings:readView organization settings
settings:writeEdit organization settings
billing:readView billing information
billing:writeManage subscription
audit:readView audit logs

Example:

bash
curl -X POST "https://api.controlinfra.com/api/orgs/663e1a2b.../roles" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "DevOps Lead",
    "description": "Full access to scans and guardrails, read-only members",
    "permissions": [
      "repositories:read",
      "repositories:write",
      "scans:read",
      "scans:write",
      "guardrails:read",
      "guardrails:write",
      "members:read"
    ]
  }'

Response: 201 Created


Update a Custom Role Team+

PATCH /api/orgs/:orgId/roles/:roleId

Example:

bash
curl -X PATCH "https://api.controlinfra.com/api/orgs/663e1a2b.../roles/669a1b2c..." \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "permissions": [
      "repositories:read",
      "repositories:write",
      "scans:read",
      "scans:write",
      "guardrails:read",
      "guardrails:write",
      "members:read",
      "members:write"
    ]
  }'

Delete a Custom Role Team+

DELETE /api/orgs/:orgId/roles/:roleId

Members with this role are reassigned to the built-in Member role.

Example:

bash
curl -X DELETE "https://api.controlinfra.com/api/orgs/663e1a2b.../roles/669a1b2c..." \
  -H "Authorization: Bearer YOUR_TOKEN"

Response: 204 No Content