{"modulePath":"github.com/Flagsmith/flagsmith-cli","version":"v1.1.1-0.20260730103710-c6179254e1e8","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\n## Variables\n\n```go\nvar ErrPlanGated = errors.New(\"not available on your organisation's current plan\")\n```\nErrPlanGated marks a self-serve plan limit a user lifts by upgrading — seats, a payment problem, or no subscription. The error's own message is the API's specific reason.\n\n```go\nvar ErrQuotaExceeded = errors.New(\"resource limit reached on your organisation's current plan\")\n```\nErrQuotaExceeded marks a resource cap that is raised on request rather than by self-serve upgrade — the feature, segment, and segment-override limits, which enterprise plans can relax. Telling the two apart is by message text only (see classifyLimit); Flagsmith ships no machine-readable error code.\n\n```go\nvar ErrWorkflowGated = fmt.Errorf(\"this environment uses change-request workflows; direct updates are disabled\")\n```\nErrWorkflowGated is returned when update-flag-v2 refuses because the environment has change-request workflows enabled.\n\n## Types\n\n```go\ntype APIKey string\n```\nAPIKey authenticates with an organisation Master API key.\n\n```go\nfunc (k APIKey) Apply(req *http.Request)\n```\n\n```go\ntype Auth interface {\n\tApply(req *http.Request)\n}\n```\nAuth applies an Authorization scheme to a request.\n\n```go\ntype Bearer string\n```\nBearer authenticates with an OAuth access token.\n\n```go\nfunc (b Bearer) Apply(req *http.Request)\n```\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient is the Flagsmith Admin API client.\n\n```go\nfunc NewClient(baseURL string, auth Auth, opts ...Option) *Client\n```\nNewClient builds a Client for one instance base URL and auth scheme. The base URL's trailing slash is trimmed so paths join cleanly.\n\n```go\nfunc (c *Client) CloneEnvironment(ctx context.Context, apiKey string, body map[string]any) (*Environment, error)\n```\nCloneEnvironment clones an environment into a new one named by body\\[\"name\"].\n\n```go\nfunc (c *Client) CoreIdentityOverrides(ctx context.Context, envKey string, featureID int) ([]IdentityOverrideRow, error)\n```\nCoreIdentityOverrides lists every core (Postgres) identity override for a feature, via the environment featurestates list's identity mode.\n\n```go\nfunc (c *Client) CreateEnvironment(ctx context.Context, body map[string]any) (*Environment, error)\n```\nCreateEnvironment creates an environment from a flat field body (name + project required). The client-side api\\_key is minted server-side.\n\n```go\nfunc (c *Client) CreateEnvironmentAPIKey(ctx context.Context, envKey string, body map[string]any) (*EnvironmentAPIKey, error)\n```\nCreateEnvironmentAPIKey mints a server-side key; the response includes the full key value (shown once).\n\n```go\nfunc (c *Client) CreateFeature(ctx context.Context, projectID int, in FeatureWrite) (*Feature, error)\n```\nCreateFeature creates a project feature (project taken from the URL).\n\n```go\nfunc (c *Client) CreateIdentity(ctx context.Context, envKey, identifier string) (int, error)\n```\n\n```go\nfunc (c *Client) CreateMVOption(ctx context.Context, projectID, featureID int, in MultivariateOption) (*MultivariateOption, error)\n```\nCreateMVOption adds a multivariate option (variant) to a feature.\n\n```go\nfunc (c *Client) CreateOrganisation(ctx context.Context, body map[string]any) (*Organisation, error)\n```\nCreateOrganisation creates an organisation from a flat field body.\n\n```go\nfunc (c *Client) CreateProject(ctx context.Context, body map[string]any) (*Project, error)\n```\nCreateProject creates a project from a flat field body (name + organisation required).\n\nA project-cap denial arrives as a bare 403, identical to an RBAC \"you lack CREATE\\_PROJECT\" denial, so a 403 is only reported as ErrPlanGated once the org is confirmed to be at its plan's project limit.\n\n```go\nfunc (c *Client) CreateSegment(ctx context.Context, projectID int, in Segment) (*Segment, error)\n```\nCreateSegment creates a segment.\n\n```go\nfunc (c *Client) DeleteEdgeIdentityOverride(ctx context.Context, envKey, identifier string, featureID int) error\n```\n\n```go\nfunc (c *Client) DeleteEnvironment(ctx context.Context, apiKey string) error\n```\nDeleteEnvironment removes an environment by api\\_key.\n\n```go\nfunc (c *Client) DeleteEnvironmentAPIKey(ctx context.Context, envKey string, keyID int) error\n```\n\n```go\nfunc (c *Client) DeleteFeature(ctx context.Context, projectID, featureID int) error\n```\n\n```go\nfunc (c *Client) DeleteIdentityOverride(ctx context.Context, envKey string, identityID, fsID int) error\n```\nDeleteIdentityOverride removes a core identity override by feature-state id.\n\n```go\nfunc (c *Client) DeleteMVOption(ctx context.Context, projectID, featureID, optionID int) error\n```\n\n```go\nfunc (c *Client) DeleteOrganisation(ctx context.Context, orgID int) error\n```\n\n```go\nfunc (c *Client) DeleteProject(ctx context.Context, projectID int) error\n```\n\n```go\nfunc (c *Client) DeleteSegment(ctx context.Context, projectID, segmentID int) error\n```\n\n```go\nfunc (c *Client) DeleteSegmentOverride(ctx context.Context, environmentKey string, feature FeatureRef, segmentID int) error\n```\nDeleteSegmentOverride removes a feature's override for one segment, via the experimental delete-segment-override endpoint keyed by the environment key.\n\n```go\nfunc (c *Client) EdgeIdentityOverride(ctx context.Context, envKey, identityUUID string, featureID int) (*IdentityFeatureState, error)\n```\nEdgeIdentityOverride returns an edge identity's override for a feature, or nil. It is keyed by the identity uuid (the identifier endpoint has no GET).\n\n```go\nfunc (c *Client) EdgeIdentityOverrides(ctx context.Context, envKey string, featureID int) ([]IdentityOverrideRow, error)\n```\nEdgeIdentityOverrides lists every edge (DynamoDB) identity override for a feature. The endpoint has no trailing slash and no pagination — replicated verbatim.\n\n```go\nfunc (c *Client) EdgeIdentityUUID(ctx context.Context, envKey, identifier string) (uuid string, found bool, err error)\n```\nEdgeIdentityUUID resolves an identifier to its edge identity uuid, or found false when none exists yet.\n\n```go\nfunc (c *Client) EnvironmentAPIKeys(ctx context.Context, envKey string) ([]EnvironmentAPIKey, error)\n```\n\n```go\nfunc (c *Client) EnvironmentDocument(ctx context.Context, apiKey string) (json.RawMessage, error)\n```\nEnvironmentDocument fetches the environment document (the offline-evaluation payload) as raw JSON, via the admin document action.\n\n```go\nfunc (c *Client) Environments(ctx context.Context, projectID int) ([]Environment, error)\n```\n\n```go\nfunc (c *Client) FeatureSegments(ctx context.Context, environmentID, featureID int) ([]FeatureSegment, error)\n```\nFeatureSegments lists a feature's segment overrides in one environment, in priority order. Both filters are required by the endpoint.\n\n```go\nfunc (c *Client) FeatureStates(ctx context.Context, environmentID, featureID int) ([]EnvironmentFeatureState, error)\n```\nFeatureStates lists a feature's live states in one environment.\n\n```go\nfunc (c *Client) Features(ctx context.Context, projectID, environmentID, segmentID int, search string) ([]Feature, error)\n```\nFeatures lists a project's features with their state in one environment, identified by its numeric ID. When segmentID is non-zero, each feature also carries its segment\\_feature\\_state for that segment. A non-empty search narrows the list server-side: a contains match on the name, not an exact one.\n\n```go\nfunc (c *Client) GetEnvironment(ctx context.Context, apiKey string) (*Environment, error)\n```\nGetEnvironment fetches one environment by its client-side api\\_key.\n\n```go\nfunc (c *Client) GetFeature(ctx context.Context, projectID, featureID int) (*Feature, error)\n```\nGetFeature fetches one project feature (with its multivariate options).\n\n```go\nfunc (c *Client) GetOrganisation(ctx context.Context, orgID int) (*Organisation, error)\n```\n\n```go\nfunc (c *Client) GetProject(ctx context.Context, projectID int) (*Project, error)\n```\n\n```go\nfunc (c *Client) GetSegment(ctx context.Context, projectID, segmentID int) (*Segment, error)\n```\nGetSegment fetches one segment with its full rule tree.\n\n```go\nfunc (c *Client) GetSubscriptionMetadata(ctx context.Context, orgID int) (*SubscriptionMetadata, error)\n```\n\n```go\nfunc (c *Client) IdentityByIdentifier(ctx context.Context, envKey, identifier string) (id int, found bool, err error)\n```\nIdentityByIdentifier resolves an identifier to its numeric identity id via the core Admin API. found is false when no identity matches.\n\n```go\nfunc (c *Client) IdentityOverride(ctx context.Context, envKey string, identityID, featureID int) (*IdentityFeatureState, error)\n```\nIdentityOverride returns a core identity's override for a feature, or nil.\n\n```go\nfunc (c *Client) Organisations(ctx context.Context) ([]Organisation, error)\n```\n\n```go\nfunc (c *Client) ProjectFeatures(ctx context.Context, projectID int, includeArchived bool) ([]Feature, error)\n```\nProjectFeatures lists a project's features. includeArchived controls whether archived features are returned.\n\n```go\nfunc (c *Client) Projects(ctx context.Context, organisationID int) ([]Project, error)\n```\nProjects lists an organisation's projects. organisationID 0 lists all accessible projects (the endpoint's organisation filter is optional).\n\n```go\nfunc (c *Client) Segments(ctx context.Context, projectID int, include bool) ([]Segment, error)\n```\nSegments lists a project's segments. include controls whether feature-specific segments are returned.\n\n```go\nfunc (c *Client) SetEdgeIdentityOverride(ctx context.Context, envKey, identifier string, featureID int, enabled bool, value any) error\n```\nSetEdgeIdentityOverride creates-or-updates an edge identity override in one call (the identity is created if it does not exist). value is a native scalar.\n\n```go\nfunc (c *Client) SetIdentityOverride(ctx context.Context, envKey string, identityID, featureID, fsID int, enabled bool, value any) error\n```\nSetIdentityOverride creates (fsID == 0) or updates a core identity override. value is a native scalar (string/int/bool); the server infers its type.\n\n```go\nfunc (c *Client) UpdateEnvironment(ctx context.Context, apiKey string, body map[string]any) (*Environment, error)\n```\nUpdateEnvironment patches an environment (project is immutable and ignored).\n\n```go\nfunc (c *Client) UpdateFeature(ctx context.Context, projectID, featureID int, in FeatureWrite) (*Feature, error)\n```\nUpdateFeature patches the mutable fields of a feature (name, initial value, and default-enabled are read-only server-side and ignored if sent).\n\n```go\nfunc (c *Client) UpdateFlag(ctx context.Context, environmentKey string, in UpdateFlagRequest) error\n```\nUpdateFlag applies an environment-default change via the experimental update-flag-v2 endpoint, keyed by the environment's client-side key. The endpoint returns 204 No Content on success.\n\n```go\nfunc (c *Client) UpdateMVOption(ctx context.Context, projectID, featureID, optionID int, in MultivariateOption) (*MultivariateOption, error)\n```\nUpdateMVOption patches a multivariate option in place (preserving the id, so per-environment weight overrides survive).\n\n```go\nfunc (c *Client) UpdateOrganisation(ctx context.Context, orgID int, body map[string]any) (*Organisation, error)\n```\n\n```go\nfunc (c *Client) UpdateProject(ctx context.Context, projectID int, body map[string]any) (*Project, error)\n```\nUpdateProject patches a project's fields (organisation is immutable and ignored if sent).\n\n```go\nfunc (c *Client) UpdateSegment(ctx context.Context, projectID, segmentID int, in Segment) (*Segment, error)\n```\nUpdateSegment replaces a segment's rule tree and fields.\n\n```go\nfunc (c *Client) UsersMe(ctx context.Context) (*User, error)\n```\n\n```go\ntype CodeReferenceCount struct {\n\tCount int `json:\"count\"`\n}\n```\nCodeReferenceCount is a per-repository count of code references to a feature.\n\n```go\ntype Environment struct {\n\tID                     int    `json:\"id\"`\n\tName                   string `json:\"name\"`\n\tAPIKey                 string `json:\"api_key\"`\n\tProject                int    `json:\"project\"`\n\tDescription            string `json:\"description\"`\n\tUseV2FeatureVersioning bool   `json:\"use_v2_feature_versioning\"`\n\t// contains filtered or unexported fields\n}\n```\nEnvironment carries the curated fields plus the raw API item, so JSON output mirrors the server's full field set. Identified by APIKey, not id.\n\n```go\nfunc (e Environment) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (e *Environment) UnmarshalJSON(b []byte) error\n```\n\n```go\ntype EnvironmentAPIKey struct {\n\tID        int     `json:\"id\"`\n\tKey       string  `json:\"key,omitempty\"`\n\tName      string  `json:\"name\"`\n\tActive    bool    `json:\"active\"`\n\tCreatedAt string  `json:\"created_at\"`\n\tExpiresAt *string `json:\"expires_at\"`\n}\n```\nEnvironmentAPIKey is a server-side (ser.) SDK key for an environment. Key is returned in full only on create.\n\n```go\ntype EnvironmentDefault struct {\n\tEnabled bool         `json:\"enabled\"`\n\tValue   FeatureValue `json:\"value\"`\n}\n```\nEnvironmentDefault is the environment-wide state update-flag-v2 requires in full on every call.\n\n```go\ntype EnvironmentFeatureState struct {\n\tID             int        `json:\"id\"`\n\tEnabled        bool       `json:\"enabled\"`\n\tFeatureSegment *int       `json:\"feature_segment\"`\n\tIdentity       *int       `json:\"identity\"`\n\tValue          TypedValue `json:\"feature_state_value\"`\n}\n```\nEnvironmentFeatureState is one row of the admin featurestates list: a feature's state for the environment default (feature\\_segment null), one segment override, or (in v2-versioned environments) an identity override.\n\n```go\ntype Feature struct {\n\tID                   int                  `json:\"id\"`\n\tName                 string               `json:\"name\"`\n\tType                 string               `json:\"type\"`\n\tDescription          string               `json:\"description\"`\n\tNumSegmentOverrides  int                  `json:\"num_segment_overrides\"`\n\tNumIdentityOverrides *int                 `json:\"num_identity_overrides\"`\n\tLifecycleStage       string               `json:\"lifecycle_stage\"`\n\tCodeReferencesCounts []CodeReferenceCount `json:\"code_references_counts\"`\n\tEnvironmentState     *FeatureState        `json:\"environment_feature_state\"`\n\tSegmentState         *FeatureState        `json:\"segment_feature_state\"`\n\n\t// Project-level definition fields.\n\tInitialValue        *string              `json:\"initial_value\"`\n\tDefaultEnabled      bool                 `json:\"default_enabled\"`\n\tIsArchived          bool                 `json:\"is_archived\"`\n\tMultivariateOptions []MultivariateOption `json:\"multivariate_options\"`\n}\n```\nFeature is a project feature with its state in the requested environment.\n\n```go\nfunc (f Feature) CodeReferences() int\n```\nCodeReferences totals the per-repository code reference counts.\n\n```go\ntype FeatureRef struct {\n\tName string `json:\"name,omitempty\"`\n\tID   int    `json:\"id,omitempty\"`\n}\n```\nFeatureRef targets a feature by name or id (exactly one) in update-flag-v2.\n\n```go\ntype FeatureSegment struct {\n\tID          int    `json:\"id\"`\n\tSegment     int    `json:\"segment\"`\n\tSegmentName string `json:\"segment_name\"`\n\tPriority    int    `json:\"priority\"`\n}\n```\nFeatureSegment links a feature to one segment override in an environment: the override's priority plus the segment's id and name. The endpoint returns rows in priority order and reflects the live version transparently.\n\n```go\ntype FeatureState struct {\n\tEnabled bool `json:\"enabled\"`\n\tValue   any  `json:\"feature_state_value\"`\n}\n```\nFeatureState is a feature's state in one environment. In the project features list, feature\\_state\\_value is a bare scalar.\n\n```go\ntype FeatureValue struct {\n\tType  string `json:\"type\"`  // \"integer\" | \"string\" | \"boolean\"\n\tValue string `json:\"value\"` // always a string; parsed server-side per type\n}\n```\nFeatureValue is a typed flag value in the update-flag-v2 wire form: the type as a word and the value always as a string.\n\n```go\ntype FeatureWrite struct {\n\tName                string               `json:\"name,omitempty\"`\n\tDescription         *string              `json:\"description,omitempty\"`\n\tInitialValue        *string              `json:\"initial_value,omitempty\"`\n\tDefaultEnabled      *bool                `json:\"default_enabled,omitempty\"`\n\tIsArchived          *bool                `json:\"is_archived,omitempty\"`\n\tMultivariateOptions []MultivariateOption `json:\"multivariate_options,omitempty\"`\n}\n```\nFeatureWrite is the create/update body. Pointer fields distinguish \"unset\" from a zero value; the API ignores fields that are read-only for the action.\n\n```go\ntype IdentityFeatureState struct {\n\tID      int  `json:\"id\"`\n\tEnabled bool `json:\"enabled\"`\n\tValue   any  `json:\"feature_state_value\"`\n\tFeature int  `json:\"feature\"`\n}\n```\nIdentityFeatureState is a feature's override for one identity. ID is the feature-state id used to update/delete it; it is unset for edge reads.\n\n```go\ntype IdentityOverrideRow struct {\n\tIdentifier string\n\tEnabled    bool\n\tValue      any\n}\n```\nIdentityOverrideRow is one identity's override of a feature, as listed by the core or edge override endpoints. Value is a bare scalar.\n\n```go\ntype MultivariateOption struct {\n\tID                          int      `json:\"id,omitempty\"`\n\tType                        string   `json:\"type,omitempty\"`\n\tStringValue                 *string  `json:\"string_value,omitempty\"`\n\tIntegerValue                *int     `json:\"integer_value,omitempty\"`\n\tBooleanValue                *bool    `json:\"boolean_value,omitempty\"`\n\tDefaultPercentageAllocation *float64 `json:\"default_percentage_allocation,omitempty\"`\n\tKey                         string   `json:\"key,omitempty\"`\n\tFeature                     int      `json:\"feature,omitempty\"`\n}\n```\nMultivariateOption is a variant of a multivariate feature. The value is a typed struct (type is \"unicode\"/\"int\"/\"bool\"); default\\_percentage\\_allocation is the variant's weight.\n\n```go\ntype Option func(*Client)\n```\nOption configures a Client.\n\n```go\nfunc WithHTTPClient(h *http.Client) Option\n```\nWithHTTPClient injects the underlying \\*http.Client. Defaults to httpx.New with the client's User-Agent.\n\n```go\nfunc WithUserAgent(ua string) Option\n```\nWithUserAgent sets the User-Agent sent on every request.\n\n```go\ntype Organisation struct {\n\tID   int    `json:\"id\"`\n\tName string `json:\"name\"`\n\t// contains filtered or unexported fields\n}\n```\nOrganisation carries the id/name plus the raw API item, so JSON output mirrors the server's full field set.\n\n```go\nfunc (o Organisation) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (o *Organisation) UnmarshalJSON(b []byte) error\n```\n\n```go\ntype Project struct {\n\tID                int    `json:\"id\"`\n\tName              string `json:\"name\"`\n\tOrganisation      int    `json:\"organisation\"`\n\tUseEdgeIdentities bool   `json:\"use_edge_identities\"`\n\t// contains filtered or unexported fields\n}\n```\nProject carries the curated fields plus the raw API item, so JSON output mirrors the server's full field set. UseEdgeIdentities decides whether identity overrides live on the core or the edge endpoints.\n\n```go\nfunc (p Project) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (p *Project) UnmarshalJSON(b []byte) error\n```\n\n```go\ntype Segment struct {\n\tID          int           `json:\"id,omitempty\"`\n\tName        string        `json:\"name\"`\n\tDescription string        `json:\"description,omitempty\"`\n\tProject     int           `json:\"project,omitempty\"`\n\tFeature     *int          `json:\"feature,omitempty\"`\n\tRules       []SegmentRule `json:\"rules\"`\n}\n```\nSegment is a project segment. Feature is set for feature-specific segments.\n\n```go\ntype SegmentCondition struct {\n\tProperty string `json:\"property,omitempty\"`\n\tOperator string `json:\"operator\"`\n\tValue    any    `json:\"value\"`\n}\n```\nSegmentCondition is one condition in a segment rule. On the wire \\`value\\` is a plain string (or null); IN arrays are carried as a JSON-array string.\n\n```go\ntype SegmentOverride struct {\n\tSegmentID int          `json:\"segment_id\"`\n\tEnabled   bool         `json:\"enabled\"`\n\tValue     FeatureValue `json:\"value\"`\n\tPriority  *int         `json:\"priority,omitempty\"`\n}\n```\nSegmentOverride is one segment's state in the update-flag-v2 body. Priority, when set, moves the override to that position — the server renumbers the others around it, preserving their relative order.\n\n```go\ntype SegmentRule struct {\n\tType       string             `json:\"type\"`\n\tConditions []SegmentCondition `json:\"conditions,omitempty\"`\n\tRules      []SegmentRule      `json:\"rules,omitempty\"`\n}\n```\nSegmentRule is a node in a segment's rule tree (ALL/ANY/NONE over conditions and sub-rules).\n\n```go\ntype SubscriptionMetadata struct {\n\tMaxSeats    *int `json:\"max_seats\"`\n\tMaxAPICalls *int `json:\"max_api_calls\"`\n\tMaxProjects *int `json:\"max_projects\"`\n}\n```\nSubscriptionMetadata is an organisation's plan limits. A nil field means the plan sets no limit for it.\n\n```go\ntype TypedValue struct {\n\tType         string  `json:\"type\"`\n\tStringValue  *string `json:\"string_value\"`\n\tIntegerValue *int    `json:\"integer_value\"`\n\tBooleanValue *bool   `json:\"boolean_value\"`\n}\n```\nTypedValue is the nested feature\\_state\\_value wire form the admin featurestates endpoints return: {type, string\\_value, integer\\_value, boolean\\_value} with type one of \"unicode\", \"int\", \"bool\".\n\n```go\nfunc (v TypedValue) Scalar() any\n```\nScalar converts the typed wire form to a bare scalar.\n\n```go\ntype UpdateFlagRequest struct {\n\tFeature            FeatureRef         `json:\"feature\"`\n\tEnvironmentDefault EnvironmentDefault `json:\"environment_default\"`\n\tSegmentOverrides   []SegmentOverride  `json:\"segment_overrides,omitempty\"`\n}\n```\nUpdateFlagRequest is the update-flag-v2 body. environment\\_default is always required; segment\\_overrides only creates/updates the segments listed and never removes others. This endpoint does not manage identity overrides.\n\n```go\ntype User struct {\n\tEmail     string `json:\"email\"`\n\tFirstName string `json:\"first_name\"`\n\tLastName  string `json:\"last_name\"`\n\tUUID      string `json:\"uuid\"`\n}\n```\nUser is a subset of GET /api/v1/auth/users/me/.\n\n","path":"github.com/Flagsmith/flagsmith-cli/internal/api","name":"api","synopsis":"","isRedistributable":true}
