### Create Feature Flag using cURL Source: https://posthog.com/docs/api/feature-flags/index Example of how to create a new feature flag using cURL. This requires your PostHog personal API key and the project ID. The request body includes essential flag details like the key. ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl -H 'Content-Type: application/json'\ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/\ -d key="string" ``` -------------------------------- ### Create Feature Flags Bulk Keys (cURL) Source: https://posthog.com/docs/api/feature-flags/index Retrieves feature flag keys by their IDs. This endpoint accepts a list of feature flag IDs and returns a mapping of each ID to its corresponding key. It requires the project ID and uses a GET request. Authentication is handled via a Bearer token. ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/bulk/ ``` -------------------------------- ### GET /api/projects/:project_id/feature_flags/local_evaluation Source: https://posthog.com/docs/api/feature-flags/index Retrieves feature flag local evaluation settings for a project. This is useful for clientside or server-side evaluation logic. ```APIDOC ## GET /api/projects/:project_id/feature_flags/local_evaluation ### Description Retrieves feature flag local evaluation settings for a project. This is useful for clientside or server-side evaluation logic. ### Method GET ### Endpoint /api/projects/:project_id/feature_flags/local_evaluation/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/. ### Required API key scopes `feature_flag:read` ### Response #### Success Response (200) No response body. #### Response Example (No response body) ``` -------------------------------- ### GET /api/projects/:project_id/feature_flags/activity Source: https://posthog.com/docs/api/feature-flags/index Retrieves the activity log for feature flags within a project. This provides insights into changes and usage patterns of feature flags. ```APIDOC ## GET /api/projects/:project_id/feature_flags/activity ### Description Retrieves the activity log for feature flags within a project. This provides insights into changes and usage patterns of feature flags. ### Method GET ### Endpoint `/api/projects/:project_id/feature_flags/activity/` ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. ### Response #### Success Response (200) No response body. ``` -------------------------------- ### GET /api/projects/:project_id/feature_flags/:id/remote_config Source: https://posthog.com/docs/api/feature-flags/index Retrieves the remote configuration for a specific feature flag. This allows clients to fetch the latest configuration for a flag. ```APIDOC ## GET /api/projects/:project_id/feature_flags/:id/remote_config ### Description Retrieves the remote configuration for a specific feature flag. This allows clients to fetch the latest configuration for a flag. ### Method GET ### Endpoint `/api/projects/:project_id/feature_flags/:id/remote_config/` ### Parameters #### Path Parameters - **id** (integer) - Required - A unique integer value identifying this feature flag. - **project_id** (string) - Required - Project ID of the project you're trying to access. ### Response #### Success Response (200) No response body. ``` -------------------------------- ### GET /api/projects/:project_id/feature_flags/:id Source: https://posthog.com/docs/api/feature-flags/index Retrieves a specific feature flag and its associated details. This endpoint is useful for inspecting the configuration of a feature flag, including its name, key, rollout percentage, and associated metadata. ```APIDOC ## GET /api/projects/:project_id/feature_flags/:id ### Description Retrieves a feature flag and its details like `name`, `key`, `variants`, `rollout_percentage`, and more. To evaluate and determine the value of a flag for a given user, use the `flags` endpoint instead. ### Method GET ### Endpoint `/api/projects/:project_id/feature_flags/:id` ### Parameters #### Path Parameters - **id** (integer) - Required - A unique integer value identifying this feature flag. - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to `/api/projects/`. ### Request Example ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/:id/ ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the feature flag. - **name** (string) - The display name of the feature flag. - **key** (string) - A unique key used to reference the feature flag. - **filters** (object) - Filtering conditions for the feature flag. - **deleted** (boolean) - Indicates if the feature flag has been deleted. - **active** (boolean) - Indicates if the feature flag is currently active. - **created_by** (object) - Information about the user who created the feature flag. - **created_at** (string) - Timestamp of when the feature flag was created. - **updated_at** (string) - Timestamp of when the feature flag was last updated. - **version** (integer) - The current version of the feature flag configuration. - **last_modified_by** (object) - Information about the user who last modified the feature flag. - **is_simple_flag** (boolean) - Indicates if this is a simple feature flag. - **rollout_percentage** (integer) - The percentage of users for whom the feature flag is rolled out. - **ensure_experience_continuity** (boolean) - Ensures continuity of user experience when flag settings change. - **experiment_set** (string) - Identifier for the experiment set associated with this flag. - **surveys** (object) - Survey configurations related to the feature flag. - **features** (object) - Feature configurations associated with the flag. - **rollback_conditions** (any) - Conditions under which a rollback will occur. - **performed_rollback** (boolean) - Indicates if a rollback has been performed. - **can_edit** (boolean) - Indicates if the current user can edit this feature flag. - **tags** (array) - List of tags associated with the feature flag. - **evaluation_tags** (array) - List of tags related to flag evaluation. - **usage_dashboard** (integer) - Identifier for the usage dashboard. - **analytics_dashboards** (array) - List of associated analytics dashboards. - **has_enriched_analytics** (boolean) - Indicates if enriched analytics are available for this flag. - **user_access_level** (string) - The access level for users to this feature flag. - **creation_context** (string) - The context in which the flag was created. - **is_remote_configuration** (boolean) - Indicates if the flag configuration is remote. - **has_encrypted_payloads** (boolean) - Indicates if the flag payloads are encrypted. - **status** (string) - The current status of the feature flag. - **evaluation_runtime** (string) - The runtime environment for flag evaluation. - **last_called_at** (string) - Timestamp of the last time the flag was evaluated. - **_create_in_folder** (string) - Internal field indicating the folder for creation. - **_should_create_usage_dashboard** (boolean) - Internal flag to determine if a usage dashboard should be created. #### Response Example ```json { "id": 0, "name": "string", "key": "string", "filters": { "property1": null, "property2": null }, "deleted": true, "active": true, "created_by": { "id": 0, "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f", "distinct_id": "string", "first_name": "string", "last_name": "string", "email": "user@example.com", "is_email_verified": true, "hedgehog_config": { "property1": null, "property2": null }, "role_at_organization": "engineering" }, "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z", "version": 0, "last_modified_by": { "id": 0, "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f", "distinct_id": "string", "first_name": "string", "last_name": "string", "email": "user@example.com", "is_email_verified": true, "hedgehog_config": { "property1": null, "property2": null }, "role_at_organization": "engineering" }, "is_simple_flag": true, "rollout_percentage": 0, "ensure_experience_continuity": true, "experiment_set": "string", "surveys": { "property1": null, "property2": null }, "features": { "property1": null, "property2": null }, "rollback_conditions": null, "performed_rollback": true, "can_edit": true, "tags": [ null ], "evaluation_tags": [ null ], "usage_dashboard": 0, "analytics_dashboards": [ 0 ], "has_enriched_analytics": true, "user_access_level": "string", "creation_context": "feature_flags", "is_remote_configuration": true, "has_encrypted_payloads": true, "status": "string", "evaluation_runtime": "server", "last_called_at": "2019-08-24T14:15:22Z", "_create_in_folder": "string", "_should_create_usage_dashboard": true } ``` ``` -------------------------------- ### GET /api/projects/:project_id/feature_flags/evaluation_reasons Source: https://posthog.com/docs/api/feature-flags/index Retrieves the reasons for feature flag evaluations within a specific project. This endpoint helps in understanding why a particular feature flag was evaluated in a certain way. ```APIDOC ## GET /api/projects/:project_id/feature_flags/evaluation_reasons ### Description Retrieves the reasons for feature flag evaluations within a specific project. This endpoint helps in understanding why a particular feature flag was evaluated in a certain way. ### Method GET ### Endpoint /api/projects/:project_id/feature_flags/evaluation_reasons/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/. ### Response #### Success Response (200) No response body. #### Response Example (No response body) ``` -------------------------------- ### GET /api/projects/:project_id/feature_flags/my_flags Source: https://posthog.com/docs/api/feature-flags/index Retrieves the feature flags that are assigned to the current user or context within a project. This endpoint is typically used to fetch flags relevant for a specific user session. ```APIDOC ## GET /api/projects/:project_id/feature_flags/my_flags ### Description Retrieves the feature flags that are assigned to the current user or context within a project. This endpoint is typically used to fetch flags relevant for a specific user session. ### Method GET ### Endpoint /api/projects/:project_id/feature_flags/my_flags/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/. ### Response #### Success Response (200) No response body. #### Response Example (No response body) ``` -------------------------------- ### GET /api/projects/:project_id/feature_flags/:id/activity Source: https://posthog.com/docs/api/feature-flags/index Retrieves the activity log for a specific feature flag within a project. This endpoint allows you to track changes and events related to a particular feature flag. ```APIDOC ## Retrieve feature flags activity ### Description Retrieves the activity log for a specific feature flag within a project. This endpoint allows you to track changes and events related to a particular feature flag. ### Method GET ### Endpoint `/api/projects/:project_id/feature_flags/:id/activity` ### Parameters #### Path Parameters - **id** (integer) - Required - A unique integer value identifying this feature flag. - **project_id** (string) - Required - Project ID of the project you're trying to access. ### Response #### Success Response (200) - No response body is returned for this request. Activity details are typically accessed through other means or logged events. ``` -------------------------------- ### GET /api/projects/:project_id/feature_flags/:id/status Source: https://posthog.com/docs/api/feature-flags/index Retrieves the current status of a specific feature flag. This endpoint is useful for checking if a flag is active or inactive. ```APIDOC ## GET /api/projects/:project_id/feature_flags/:id/status ### Description Retrieves the current status of a specific feature flag. This endpoint is useful for checking if a flag is active or inactive. ### Method GET ### Endpoint `/api/projects/:project_id/feature_flags/:id/status/` ### Parameters #### Path Parameters - **id** (integer) - Required - A unique integer value identifying this feature flag. - **project_id** (string) - Required - Project ID of the project you're trying to access. ### Response #### Success Response (200) No response body. ``` -------------------------------- ### Retrieve Feature Flags Activity (cURL) Source: https://posthog.com/docs/api/feature-flags/index Retrieves the activity log for feature flags within a project. This endpoint requires `activity_log:read` scope and uses a GET request. Authentication is performed using a Bearer token. A successful request returns a 200 status code and no response body. ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/activity/ ``` -------------------------------- ### Retrieve Feature Flags Status (cURL) Source: https://posthog.com/docs/api/feature-flags/index Retrieves the status of a specific feature flag. This operation requires the `feature_flag:read` scope and utilizes a GET request. Authentication is handled via a Bearer token. A successful request returns a 200 status code with no response body. ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/:id/status/ ``` -------------------------------- ### Retrieve Feature Flags Remote Config (cURL) Source: https://posthog.com/docs/api/feature-flags/index Retrieves the remote configuration for a specific feature flag. This requires read access to feature flags (`feature_flag:read` scope) and uses a GET request. Authentication is done via a Bearer token. The response typically indicates a successful operation with a 200 status code and no response body. ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/:id/remote_config/ ``` -------------------------------- ### Delete Feature Flag using cURL Source: https://posthog.com/docs/api/feature-flags/index This example shows how to hard delete a feature flag using a cURL command. Note that direct hard deletion is not permitted; instead, this operation patches the 'deleted' property to true. It requires a personal API key for authorization and includes the project and flag IDs in the request. ```shell export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl -X DELETE \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/:id/ ``` -------------------------------- ### List Feature Flags (cURL) Source: https://posthog.com/docs/api/feature-flags/index This snippet demonstrates how to list all feature flags for a given project using a cURL command. It requires an API key for authorization and specifies the project ID in the URL. The response will contain details about each feature flag. ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/ ``` -------------------------------- ### List all feature flags Source: https://posthog.com/docs/api/feature-flags/index This endpoint returns a list of feature flags and their details like `name`, `key`, `variants`, `rollout_percentage`, and more. Use the `flags` endpoint to evaluate and determine the value of flags for a given user. ```APIDOC ## List all feature flags This endpoint returns a list of feature flags and their details like `name`, `key`, `variants`, `rollout_percentage`, and more. To evaluate and determine the value of flags for a given user, use the `flags` endpoint instead. #### Required API key scopes `feature_flag:read` * * * #### Path parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/. * * * #### Query parameters - **active** (string) - Optional - One of: `"STALE"``"false"``"true"` - **created_by_id** (string) - Optional - The User ID which initially created the feature flag. - **evaluation_runtime** (string) - Optional - One of: `"both"``"client"``"server"` - Filter feature flags by their evaluation runtime. - **excluded_properties** (string) - Optional - JSON-encoded list of feature flag keys to exclude from the results. - **limit** (integer) - Optional - Number of results to return per page. - **offset** (integer) - Optional - The initial index from which to return the results. - **search** (string) - Optional - Search by feature flag key or name. Case insensitive. - **tags** (string) - Optional - JSON-encoded list of tag names to filter feature flags by. - **type** (string) - Optional - One of: `"boolean"``"experiment"``"multivariant"` * * * #### Response Show response body #### Example request `GET ``/api/projects/:project_id/feature_flags` cURL ``` export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/ ``` #### Example response ``` -------------------------------- ### Create Feature Flags Bulk Keys Source: https://posthog.com/docs/api/feature-flags/index Retrieves feature flag keys by their IDs. This endpoint accepts a list of feature flag IDs and returns a mapping of each ID to its corresponding key. ```APIDOC ## Create Feature Flags Bulk Keys ### Description Retrieves feature flag keys by their IDs. Accepts a list of feature flag IDs and returns a mapping of ID to key. ### Method GET ### Endpoint `/api/projects/:project_id/feature_flags/bulk_keys/` ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. ### Response #### Success Response (200) - **key** (string) - The key of the feature flag. - **id** (integer) - The ID of the feature flag. ``` -------------------------------- ### POST /api/projects/:project_id/feature_flags/bulk_keys Source: https://posthog.com/docs/api/feature-flags/index Creates feature flags in bulk using their keys. This endpoint is useful for batch operations when you have multiple feature flags to create. ```APIDOC ## POST /api/projects/:project_id/feature_flags/bulk_keys ### Description Creates feature flags in bulk using their keys. This endpoint is useful for batch operations when you have multiple feature flags to create. ### Method POST ### Endpoint /api/projects/:project_id/feature_flags/bulk_keys/ ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. #### Request Body - **name** (string) - Optional - Contains the description for the flag (field name `name` is kept for backwards-compatibility). - **key** (string) - Required - The unique key for the feature flag. - **filters** (object) - Optional - Filtering options for the feature flag. - **deleted** (boolean) - Optional - Indicates if the flag is deleted. - **active** (boolean) - Optional - Indicates if the flag is active. - **created_at** (string) - Optional - Timestamp of creation. - **version** (integer) - Optional - The version of the feature flag. Defaults to `0`. - **ensure_experience_continuity** (boolean) - Optional - Ensures continuity of user experience. - **rollback_conditions** (object) - Optional - Conditions for rolling back the flag. - **performed_rollback** (boolean) - Optional - Indicates if a rollback was performed. - **tags** (array) - Optional - Tags associated with the feature flag. - **evaluation_tags** (array) - Optional - Evaluation tags for the feature flag. - **analytics_dashboards** (array) - Optional - Dashboards linked to the feature flag's analytics. - **has_enriched_analytics** (boolean) - Optional - Indicates if the flag has enriched analytics. - **creation_context** (string) - Optional - Indicates the origin product of the feature flag. Choices: 'feature_flags', 'experiments', 'surveys', 'early_access_features', 'web_experiments'. - **is_remote_configuration** (boolean) - Optional - Indicates if the flag is remote configured. - **has_encrypted_payloads** (boolean) - Optional - Indicates if the flag has encrypted payloads. - **evaluation_runtime** (string) - Optional - Specifies where this feature flag should be evaluated. Choices: 'server', 'client', 'all'. - **last_called_at** (string) - Optional - Last time this feature flag was called. - **_create_in_folder** (string) - Optional - Internal field for folder creation. - **_should_create_usage_dashboard** (boolean) - Optional - Indicates whether to create a usage dashboard. Defaults to `true`. ### Request Example ```json { "name": "Example Flag", "key": "my-feature-flag", "active": true, "filters": {}, "creation_context": "feature_flags" } ``` ### Response #### Success Response (200) No response body. #### Response Example (No response body) ``` -------------------------------- ### Create Feature Flag Source: https://posthog.com/docs/api/feature-flags/index Creates a new feature flag within a specified PostHog project. Requires the `feature_flag:write` scope. ```APIDOC ## POST /api/projects/:project_id/feature_flags ### Description Creates a new feature flag within a specified PostHog project. ### Method POST ### Endpoint `/api/projects/:project_id/feature_flags/` ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. #### Request Body - **name** (string) - Description for the flag (for backwards-compatibility). - **key** (string) - Required - Unique key for the feature flag. - **filters** (object) - Filtering conditions for the flag. - **deleted** (boolean) - Indicates if the flag is deleted. - **active** (boolean) - Indicates if the flag is active. - **created_at** (string) - Timestamp of creation. - **version** (integer) - Version of the flag. Default: 0. - **ensure_experience_continuity** (boolean) - Ensures continuity of user experience. - **rollback_conditions** (any) - Conditions for rollback. - **performed_rollback** (boolean) - Indicates if a rollback was performed. - **tags** (array) - Associated tags. - **evaluation_tags** (array) - Tags used for evaluation. - **analytics_dashboards** (array) - Associated analytics dashboards. - **has_enriched_analytics** (boolean) - Indicates if analytics are enriched. - **creation_context** (string) - Indicates the origin product of the feature flag. Choices: 'feature_flags', 'experiments', 'surveys', 'early_access_features', 'web_experiments'. - **is_remote_configuration** (boolean) - Indicates if the configuration is remote. - **has_encrypted_payloads** (boolean) - Indicates if payloads are encrypted. - **evaluation_runtime** (string) - Specifies where this feature flag should be evaluated. Choices: 'server', 'client', 'all'. - **last_called_at** (string) - Last time this feature flag was called. - **_create_in_folder** (string) - Folder to create the flag in. - **_should_create_usage_dashboard** (boolean) - Whether to create a usage dashboard. Default: true. ### Request Example ```json { "key": "string", "name": "Example Flag Name" } ``` ### Response #### Success Response (200) - **id** (integer) - Unique identifier for the feature flag. - **name** (string) - Name of the feature flag. - **key** (string) - Unique key for the feature flag. - **filters** (object) - Filtering conditions for the flag. - **deleted** (boolean) - Indicates if the flag is deleted. - **active** (boolean) - Indicates if the flag is active. - **created_by** (object) - Information about the user who created the flag. - **created_at** (string) - Timestamp of creation. - **updated_at** (string) - Timestamp of last update. - **version** (integer) - Version of the flag. - **last_modified_by** (object) - Information about the user who last modified the flag. - **is_simple_flag** (boolean) - Indicates if it's a simple flag. - **rollout_percentage** (integer) - Percentage of users for rollout. - **ensure_experience_continuity** (boolean) - Ensures continuity of user experience. - **experiment_set** (string) - Associated experiment set. - **surveys** (object) - Associated surveys. - **features** (object) - Associated features. - **rollback_conditions** (any) - Conditions for rollback. - **performed_rollback** (boolean) - Indicates if a rollback was performed. - **can_edit** (boolean) - Indicates if the current user can edit the flag. - **tags** (array) - Associated tags. - **evaluation_tags** (array) - Tags used for evaluation. - **usage_dashboard** (integer) - ID of the usage dashboard. - **analytics_dashboards** (array) - Associated analytics dashboards. - **has_enriched_analytics** (boolean) - Indicates if analytics are enriched. - **user_access_level** (string) - Access level of the user. - **creation_context** (string) - Indicates the origin product of the feature flag. - **is_remote_configuration** (boolean) - Indicates if the configuration is remote. - **has_encrypted_payloads** (boolean) - Indicates if payloads are encrypted. - **status** (string) - Current status of the flag. - **evaluation_runtime** (string) - Specifies where this feature flag should be evaluated. - **last_called_at** (string) - Last time this feature flag was called. - **_create_in_folder** (string) - Folder to create the flag in. - **_should_create_usage_dashboard** (boolean) - Whether to create a usage dashboard. #### Response Example ```json { "id": 0, "name": "string", "key": "string", "filters": {}, "deleted": true, "active": true, "created_by": { "id": 0, "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f", "distinct_id": "string", "first_name": "string", "last_name": "string", "email": "user@example.com", "is_email_verified": true, "hedgehog_config": {}, "role_at_organization": "engineering" }, "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z", "version": 0, "last_modified_by": { "id": 0, "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f", "distinct_id": "string", "first_name": "string", "last_name": "string", "email": "user@example.com", "is_email_verified": true, "hedgehog_config": {}, "role_at_organization": "engineering" }, "is_simple_flag": true, "rollout_percentage": 0, "ensure_experience_continuity": true, "experiment_set": "string", "surveys": {}, "features": {}, "rollback_conditions": null, "performed_rollback": true, "can_edit": true, "tags": [ null ], "evaluation_tags": [ null ], "usage_dashboard": 0, "analytics_dashboards": [ 0 ], "has_enriched_analytics": true, "user_access_level": "string", "creation_context": "feature_flags", "is_remote_configuration": true, "has_encrypted_payloads": true, "status": "string", "evaluation_runtime": "server", "last_called_at": "2019-08-24T14:15:22Z", "_create_in_folder": "string", "_should_create_usage_dashboard": true } ``` ``` -------------------------------- ### POST /api/projects/:project_id/feature_flags Source: https://posthog.com/docs/api/feature-flags/index Creates a new feature flag within the specified project. This endpoint allows for defining the initial properties of a feature flag, such as its name, key, and rollout configuration. ```APIDOC ## POST /api/projects/:project_id/feature_flags ### Description Creates a new feature flag. The response will include the newly created feature flag's details, such as its ID, name, key, and other configuration properties. ### Method POST ### Endpoint `/api/projects/:project_id/feature_flags` ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. To find the ID of the project, make a call to `/api/projects/`. #### Request Body - **name** (string) - Required - The display name of the feature flag. - **key** (string) - Required - A unique key to identify the feature flag. - **rollout_percentage** (integer) - Optional - The percentage of users for whom the feature flag should be active. Defaults to 0. - **active** (boolean) - Optional - Whether the feature flag is active. Defaults to false. - **ensure_experience_continuity** (boolean) - Optional - Ensures continuity of user experience when flag settings change. Defaults to true. - **creation_context** (string) - Optional - The context in which the flag was created. Example: `feature_flags`. ### Request Example ```json { "name": "New Feature Flag", "key": "new-feature-key", "rollout_percentage": 50, "active": true } ``` ### Response #### Success Response (201) - **id** (integer) - The unique identifier for the newly created feature flag. - **name** (string) - The display name of the feature flag. - **key** (string) - A unique key to identify the feature flag. - **filters** (object) - Filtering conditions for the feature flag (initially empty or default). - **deleted** (boolean) - Indicates if the feature flag has been deleted (will be false on creation). - **active** (boolean) - Indicates if the feature flag is currently active. - **created_by** (object) - Information about the user who created the feature flag. - **created_at** (string) - Timestamp of when the feature flag was created. - **updated_at** (string) - Timestamp of when the feature flag was last updated. - **version** (integer) - The current version of the feature flag configuration. - **last_modified_by** (object) - Information about the user who last modified the feature flag. - **is_simple_flag** (boolean) - Indicates if this is a simple feature flag. - **rollout_percentage** (integer) - The percentage of users for whom the feature flag is rolled out. - **ensure_experience_continuity** (boolean) - Ensures continuity of user experience when flag settings change. - **experiment_set** (string) - Identifier for the experiment set associated with this flag. - **surveys** (object) - Survey configurations related to the feature flag. - **features** (object) - Feature configurations associated with the flag. - **rollback_conditions** (any) - Conditions under which a rollback will occur. - **performed_rollback** (boolean) - Indicates if a rollback has been performed. - **can_edit** (boolean) - Indicates if the current user can edit this feature flag. - **tags** (array) - List of tags associated with the feature flag. - **evaluation_tags** (array) - List of tags related to flag evaluation. - **usage_dashboard** (integer) - Identifier for the usage dashboard. - **analytics_dashboards** (array) - List of associated analytics dashboards. - **has_enriched_analytics** (boolean) - Indicates if enriched analytics are available for this flag. - **user_access_level** (string) - The access level for users to this feature flag. - **creation_context** (string) - The context in which the flag was created. - **is_remote_configuration** (boolean) - Indicates if the flag configuration is remote. - **has_encrypted_payloads** (boolean) - Indicates if the flag payloads are encrypted. - **status** (string) - The current status of the feature flag. - **evaluation_runtime** (string) - The runtime environment for flag evaluation. - **last_called_at** (string) - Timestamp of the last time the flag was evaluated. - **_create_in_folder** (string) - Internal field indicating the folder for creation. - **_should_create_usage_dashboard** (boolean) - Internal flag to determine if a usage dashboard should be created. #### Response Example ```json { "id": 1, "name": "New Feature Flag", "key": "new-feature-key", "filters": { "property1": null, "property2": null }, "deleted": false, "active": true, "created_by": { "id": 1, "uuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "distinct_id": "user123", "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "is_email_verified": true, "hedgehog_config": { "property1": null, "property2": null }, "role_at_organization": "developer" }, "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z", "version": 1, "last_modified_by": { "id": 1, "uuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "distinct_id": "user123", "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "is_email_verified": true, "hedgehog_config": { "property1": null, "property2": null }, "role_at_organization": "developer" }, "is_simple_flag": true, "rollout_percentage": 50, "ensure_experience_continuity": true, "experiment_set": "", "surveys": {}, "features": {}, "rollback_conditions": null, "performed_rollback": false, "can_edit": true, "tags": [], "evaluation_tags": [], "usage_dashboard": 0, "analytics_dashboards": [], "has_enriched_analytics": false, "user_access_level": "view", "creation_context": "feature_flags", "is_remote_configuration": false, "has_encrypted_payloads": false, "status": "active", "evaluation_runtime": "server", "last_called_at": null, "_create_in_folder": "", "_should_create_usage_dashboard": false } ``` ``` -------------------------------- ### Create Static Cohort for Feature Flag (cURL) Source: https://posthog.com/docs/api/feature-flags/index This snippet demonstrates how to create a static cohort for a specific feature flag using cURL. It requires the project ID, feature flag ID, and a key. The request includes authentication headers and specifies JSON content type. ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H 'Content-Type: application/json'\ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/:id/create_static_cohort_for_flag/\ -d key="string" ``` -------------------------------- ### Create Feature Flags Dashboard (cURL) Source: https://posthog.com/docs/api/feature-flags/index This snippet shows how to create a dashboard for a feature flag using cURL. It requires the project ID, feature flag ID, and a key. The request includes authentication headers and specifies JSON content type. ```bash export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H 'Content-Type: application/json'\ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/:id/dashboard/\ -d key="string" ``` -------------------------------- ### POST /api/projects/:project_id/feature_flags/:id/create_static_cohort_for_flag Source: https://posthog.com/docs/api/feature-flags/index This endpoint creates a static cohort for a specific feature flag within a project. It requires the project ID and the feature flag ID as path parameters. ```APIDOC ## POST /api/projects/:project_id/feature_flags/:id/create_static_cohort_for_flag ### Description Creates a static cohort for a specific feature flag. ### Method POST ### Endpoint `/api/projects/:project_id/feature_flags/:id/create_static_cohort_for_flag` ### Parameters #### Path Parameters - **id** (integer) - Required - A unique integer value identifying this feature flag. - **project_id** (string) - Required - Project ID of the project you're trying to access. #### Request Body - **key** (string) - Required - The key of the feature flag. ### Request Example ```json { "key": "string" } ``` ### Response #### Success Response (200) No response body. #### Response Example (No response body) ``` -------------------------------- ### POST /api/projects/:project_id/feature_flags/user_blast_radius Source: https://posthog.com/docs/api/feature-flags/index Creates a feature flag with specified properties, including its key, filters, and other configuration details. This endpoint is used for creating new feature flags. ```APIDOC ## POST /api/projects/:project_id/feature_flags/user_blast_radius ### Description Creates a feature flag with specified properties, including its key, filters, and other configuration details. This endpoint is used for creating new feature flags. ### Method POST ### Endpoint /api/projects/:project_id/feature_flags/user_blast_radius ### Parameters #### Path Parameters - **project_id** (string) - Required - Project ID of the project you're trying to access. #### Request Body - **name** (string) - Optional - Contains the description for the flag (field name `name` is kept for backwards-compatibility). - **key** (string) - Required - The unique key for the feature flag. - **filters** (object) - Optional - Filtering options for the feature flag. - **deleted** (boolean) - Optional - Indicates if the flag is deleted. - **active** (boolean) - Optional - Indicates if the flag is active. - **created_at** (string) - Optional - Timestamp of creation. - **version** (integer) - Optional - The version of the feature flag. Defaults to `0`. - **ensure_experience_continuity** (boolean) - Optional - Ensures continuity of user experience. - **rollback_conditions** (object) - Optional - Conditions for rolling back the flag. - **performed_rollback** (boolean) - Optional - Indicates if a rollback was performed. - **tags** (array) - Optional - Tags associated with the feature flag. - **evaluation_tags** (array) - Optional - Evaluation tags for the feature flag. - **analytics_dashboards** (array) - Optional - Dashboards linked to the feature flag's analytics. - **has_enriched_analytics** (boolean) - Optional - Indicates if the flag has enriched analytics. - **creation_context** (string) - Optional - Indicates the origin product of the feature flag. Choices: 'feature_flags', 'experiments', 'surveys', 'early_access_features', 'web_experiments'. - **is_remote_configuration** (boolean) - Optional - Indicates if the flag is remote configured. - **has_encrypted_payloads** (boolean) - Optional - Indicates if the flag has encrypted payloads. - **evaluation_runtime** (string) - Optional - Specifies where this feature flag should be evaluated. Choices: 'server', 'client', 'all'. - **last_called_at** (string) - Optional - Last time this feature flag was called. - **_create_in_folder** (string) - Optional - Internal field for folder creation. - **_should_create_usage_dashboard** (boolean) - Optional - Indicates whether to create a usage dashboard. Defaults to `true`. ### Response #### Success Response (200) No response body. #### Response Example (No response body) ``` -------------------------------- ### Retrieve Feature Flag Activity using cURL Source: https://posthog.com/docs/api/feature-flags/index This code snippet illustrates how to retrieve the activity log for a specific feature flag using a cURL command. It requires a PostHog personal API key for authentication and specifies the project and flag IDs in the URL. The activity log provides historical data related to the flag. ```shell export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/:id/activity/ ``` -------------------------------- ### Feature Flags API Source: https://posthog.com/docs/api/feature-flags/index This section details the various endpoints available for managing feature flags within a PostHog project. ```APIDOC ## Feature flags Create, read, update and delete feature flags. See docs for more information on feature flags. If you're looking to use feature flags on your application, you can either use our JavaScript Library or our dedicated endpoint to check if feature flags are enabled for a given user. ### Endpoints `GET`| `/api/projects/:project_id/feature_flags/` `POST`| `/api/projects/:project_id/feature_flags/` `GET`| `/api/projects/:project_id/feature_flags/:id/` `PATCH`| `/api/projects/:project_id/feature_flags/:id/` `DELETE`| `/api/projects/:project_id/feature_flags/:id/` `GET`| `/api/projects/:project_id/feature_flags/:id/activity/` `POST`| `/api/projects/:project_id/feature_flags/:id/create_static_cohort_for_flag/` `POST`| `/api/projects/:project_id/feature_flags/:id/dashboard/` `POST`| `/api/projects/:project_id/feature_flags/:id/enrich_usage_dashboard/` `GET`| `/api/projects/:project_id/feature_flags/:id/remote_config/` `GET`| `/api/projects/:project_id/feature_flags/:id/status/` `GET`| `/api/projects/:project_id/feature_flags/activity/` `POST`| `/api/projects/:project_id/feature_flags/bulk_keys/` `GET`| `/api/projects/:project_id/feature_flags/evaluation_reasons/` `GET`| `/api/projects/:project_id/feature_flags/local_evaluation/` `GET`| `/api/projects/:project_id/feature_flags/my_flags/` `POST`| `/api/projects/:project_id/feature_flags/user_blast_radius/` ``` -------------------------------- ### Retrieve Feature Flag Details (cURL) Source: https://posthog.com/docs/api/feature-flags/index This snippet demonstrates how to retrieve the details of a specific feature flag using cURL. It requires your PostHog Personal API Key and the project and flag IDs. The response includes comprehensive information about the flag's configuration and status. ```shell export POSTHOG_PERSONAL_API_KEY=[your personal api key] curl \ -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \ /api/projects/:project_id/feature_flags/:id/ ```