Skip to main content

flags

Creates, updates, deletes, gets or lists a flags resource.

Overview

Nameflags
TypeResource
Idvercel.feature_flags.flags

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstring
owner_idstring (wire: ownerId)
project_idstring (wire: projectId)
type_namestring (flag) (wire: typeName)
created_atnumber (wire: createdAt)
created_bystring (wire: createdBy)
descriptionstring
environmentsobject
kindstring (boolean, json, number, string)
maintainer_idsarray (wire: maintainerIds)
metadataobject
permanentboolean (false, true)
revisionnumber
seednumber
slugstring
statestring (active, archived)
tagsarray
updated_atnumber (wire: updatedAt)
updated_bystring (wire: updatedBy)
variantsarray

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectproject_id_or_name, flag_id_or_slugif_match, with_metadata, team_id, slugRetrieve a specific feature flag by its ID or slug.
listselectproject_id_or_namestate, limit, cursor, search, tags, created_by, maintainer_ids, include_marketplace_flags, team_id, slugRetrieve feature flags for a project. Returns an opaque cursor for pagination.
createinsertproject_id_or_name, slug, kind, environmentsteam_idCreate a new feature flag for a project. The flag must have a unique slug within the project and specify its kind (boolean, string, number, or json).
updateupdateproject_id_or_name, flag_id_or_slugif_match, with_metadata, team_id, slugUpdate an existing feature flag. This endpoint supports partial updates, allowing you to modify specific properties like variants, environments, or state without providing the full flag configuration.
deletedeleteproject_id_or_name, flag_id_or_slugif_match, with_metadata, team_id, slugPermanently delete a feature flag from the project. This action cannot be undone. Consider archiving the flag instead if you may need it in the future.
list_v1execproject_id_or_namestate, withMetadata, limit, cursor, search, tags, teamId, slugRetrieve feature flags for a project. The list can be filtered by state and supports pagination.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
flag_id_or_slugstringThe flag id or name
project_id_or_namestringThe project id or name
created_bystringFilter flags by the id of the entity that created them (a user or team id). (wire: createdBy)
cursorstringPagination cursor to continue from.
if_matchstringEtag to match, can be used interchangeably with the if-match header (wire: ifMatch)
include_marketplace_flagsbooleanWhether to include Marketplace experimentation items in the paginated response. Defaults to false. (wire: includeMarketplaceFlags)
limitintegerMaximum number of flags to return. When not set, all flags are returned.
maintainer_idsarrayFilter flags by maintainer user id. Repeat the parameter for multiple maintainers (any may match). (wire: maintainerIds)
slugstringThe Team slug to perform the request on behalf of.
statestringThe state of the flags to retrieve. Defaults to active.
tagsarrayFilter flags by tag. Repeat the parameter for multiple tags (all must match).
teamIdstringThe Team identifier to perform the request on behalf of.
team_idstringThe Team identifier to perform the request on behalf of. (wire: teamId)
withMetadatabooleanDeprecated. Whether to include creator metadata in each flag in the response. Resolve creator identity client-side (e.g. via the team members endpoint) instead; this parameter will be removed in a future release. Use GET /v1/projects/:id/feature-flags/flags/:flagIdOrSlug?withMetadata=true for single-flag lookups that need creator metadata.
with_metadatabooleanWhether to include metadata in the response (wire: withMetadata)

SELECT examples

Retrieve a specific feature flag by its ID or slug.

SELECT
id,
owner_id,
project_id,
type_name,
created_at,
created_by,
description,
environments,
kind,
maintainer_ids,
metadata,
permanent,
revision,
seed,
slug,
state,
tags,
updated_at,
updated_by,
variants
FROM vercel.feature_flags.flags
WHERE project_id_or_name = '{{ project_id_or_name }}' -- required
AND flag_id_or_slug = '{{ flag_id_or_slug }}' -- required
AND if_match = '{{ if_match }}'
AND with_metadata = '{{ with_metadata }}'
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

INSERT examples

Create a new feature flag for a project. The flag must have a unique slug within the project and specify its kind (boolean, string, number, or json).

INSERT INTO vercel.feature_flags.flags (
slug,
kind,
variants,
environments,
seed,
description,
state,
maintainer_ids,
permanent,
tags,
project_id_or_name,
team_id
)
SELECT
'{{ slug }}' /* required */,
'{{ kind }}' /* required */,
'{{ variants }}',
'{{ environments }}' /* required */,
{{ seed }},
'{{ description }}',
'{{ state }}',
'{{ maintainer_ids }}',
{{ permanent }},
'{{ tags }}',
'{{ project_id_or_name }}',
'{{ team_id }}'
RETURNING
id,
owner_id,
project_id,
type_name,
created_at,
created_by,
description,
environments,
kind,
maintainer_ids,
permanent,
revision,
seed,
slug,
state,
tags,
updated_at,
updated_by,
variants
;

UPDATE examples

Update an existing feature flag. This endpoint supports partial updates, allowing you to modify specific properties like variants, environments, or state without providing the full flag configuration.

UPDATE vercel.feature_flags.flags
SET
created_by = '{{ created_by }}',
message = '{{ message }}',
variants = '{{ variants }}',
environments = '{{ environments }}',
seed = {{ seed }},
description = '{{ description }}',
state = '{{ state }}',
maintainer_ids = '{{ maintainer_ids }}',
permanent = {{ permanent }},
tags = '{{ tags }}'
WHERE
project_id_or_name = '{{ project_id_or_name }}' --required
AND flag_id_or_slug = '{{ flag_id_or_slug }}' --required
AND if_match = '{{ if_match}}'
AND with_metadata = {{ with_metadata}}
AND team_id = '{{ team_id}}'
AND slug = '{{ slug}}'
RETURNING
id,
owner_id,
project_id,
type_name,
created_at,
created_by,
description,
environments,
kind,
maintainer_ids,
metadata,
permanent,
revision,
seed,
slug,
state,
tags,
updated_at,
updated_by,
variants;

DELETE examples

Permanently delete a feature flag from the project. This action cannot be undone. Consider archiving the flag instead if you may need it in the future.

DELETE FROM vercel.feature_flags.flags
WHERE project_id_or_name = '{{ project_id_or_name }}' --required
AND flag_id_or_slug = '{{ flag_id_or_slug }}' --required
AND if_match = '{{ if_match }}'
AND with_metadata = '{{ with_metadata }}'
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

Lifecycle Methods

EXEC variables use wire (API) names.

Retrieve feature flags for a project. The list can be filtered by state and supports pagination.

EXEC vercel.feature_flags.flags.list_v1
@project_id_or_name='{{ project_id_or_name }}' --required,
@state='{{ state }}',
@withMetadata={{ withMetadata }},
@limit='{{ limit }}',
@cursor='{{ cursor }}',
@search='{{ search }}',
@tags='{{ tags }}',
@teamId='{{ teamId }}',
@slug='{{ slug }}'
;