Flipswitch

Admin API

REST API for managing feature flags, projects, and environments

Admin API

The Admin API provides endpoints for managing flags, projects, environments, and users.

Authentication

All Admin API endpoints require a valid JWT Bearer token:

curl https://api.flipswitch.dev/api/admin/projects \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Endpoints

User

Get Current User

GET /api/admin/me

Returns the currently authenticated user's profile.

Response:

{
  "id": "user-123",
  "email": "user@example.com",
  "name": "John Doe",
  "organizationId": "org-456"
}

Logout

POST /api/admin/logout

Invalidates the current session.


Projects

List Projects

GET /api/admin/projects

Returns all projects the user has access to.

Response:

[
  {
    "id": 1,
    "key": "my-app",
    "name": "My Application",
    "description": "Main application project",
    "organizationId": "org-456"
  }
]

Create Project

POST /api/admin/projects

Request Body:

{
  "key": "my-app",
  "name": "My Application",
  "description": "Optional description"
}

Project keys must be kebab-case (e.g., my-app, feature-flags).

Get Project

GET /api/admin/projects/{id}

Permission: project:member

Update Project

PUT /api/admin/projects/{id}

Permission: project:admin

Request Body:

{
  "name": "Updated Name",
  "description": "Updated description"
}

Environments

List Environments

GET /api/admin/projects/{projectId}/environments

Permission: project:member

Response:

[
  {
    "id": 1,
    "key": "development",
    "name": "Development",
    "projectId": 1
  },
  {
    "id": 2,
    "key": "production",
    "name": "Production",
    "projectId": 1
  }
]

Create Environment

POST /api/admin/projects/{projectId}/environments

Permission: project:admin

Request Body:

{
  "key": "staging",
  "name": "Staging"
}

Flags

List Flags

GET /api/admin/projects/{projectId}/flags

Permission: project:member

Response:

[
  {
    "id": 1,
    "key": "dark-mode",
    "name": "Dark Mode",
    "type": "boolean",
    "defaultValue": false,
    "description": "Enable dark mode theme"
  }
]

Create Flag

POST /api/admin/projects/{projectId}/flags

Permission: project:admin

Request Body:

{
  "key": "dark-mode",
  "name": "Dark Mode",
  "type": "boolean",
  "defaultValue": false,
  "description": "Enable dark mode theme"
}

Flag Types:

TypeExample Values
booleantrue, false
string"variant-a", "blue"
number100, 3.14
object{"key": "value"}

Update Flag

PUT /api/admin/projects/{projectId}/flags/{flagId}

Permission: project:admin

Get Flag Rules

GET /api/admin/projects/{projectId}/flags/{flagId}/environments/{envId}/rules

Permission: project:member

Response:

{
  "enabled": true,
  "defaultVariant": "off",
  "rules": [
    {
      "id": 1,
      "priority": 1,
      "conditions": [
        {
          "attribute": "email",
          "operator": "ENDS_WITH",
          "value": "@company.com"
        }
      ],
      "variant": "on"
    }
  ],
  "percentageRollout": null
}

Update Flag Rules

PUT /api/admin/projects/{projectId}/flags/{flagId}/environments/{envId}/rules

Permission: project:admin

Request Body:

{
  "enabled": true,
  "defaultVariant": "off",
  "rules": [
    {
      "priority": 1,
      "conditions": [
        {
          "attribute": "email",
          "operator": "ENDS_WITH",
          "value": "@company.com"
        }
      ],
      "variant": "on"
    }
  ]
}

Segments

List Segments

GET /api/admin/projects/{projectId}/segments

Permission: project:member

Create Segment

POST /api/admin/projects/{projectId}/segments

Permission: project:admin

Request Body:

{
  "key": "beta-users",
  "name": "Beta Users",
  "conditions": [
    {
      "attribute": "email",
      "operator": "ENDS_WITH",
      "value": "@beta.company.com"
    }
  ]
}

API Keys

List API Keys

GET /api/admin/projects/{projectId}/environments/{envId}/api-keys

Permission: project:member

Response:

[
  {
    "id": 1,
    "name": "Production Key",
    "prefix": "sk_live_",
    "createdAt": "2024-01-15T10:30:00Z"
  }
]

Full API key values are only shown once when created. Store them securely.

Create API Key

POST /api/admin/projects/{projectId}/environments/{envId}/api-keys

Permission: project:admin

Request Body:

{
  "name": "Production Key"
}

Response:

{
  "id": 1,
  "name": "Production Key",
  "key": "sk_live_abc123xyz789",
  "createdAt": "2024-01-15T10:30:00Z"
}

Audit Log

Get Audit Log

GET /api/admin/projects/{projectId}/audit-log

Permission: project:member

Query Parameters:

ParameterTypeDescription
limitnumberMax entries to return (default: 50)
offsetnumberPagination offset
flagIdnumberFilter by flag
userIdstringFilter by user

Response:

[
  {
    "id": 1,
    "action": "FLAG_UPDATED",
    "userId": "user-123",
    "userName": "John Doe",
    "resourceType": "flag",
    "resourceId": "1",
    "details": {
      "flagKey": "dark-mode",
      "changes": ["enabled: false -> true"]
    },
    "timestamp": "2024-01-15T10:30:00Z"
  }
]

Permissions

ScopeAdminMember
OrganizationManage projects, groups, invitationsView projects
ProjectManage flags, environments, segmentsView flags and rules
EnvironmentManage flag rules, API keysView flag rules