### Install Dependencies and Run App Source: https://docs.getunleash.io/guides/implement-feature-flags-in-react.md Install project dependencies using Yarn and then start the development server for the React application. ```bash yarn yarn dev ``` -------------------------------- ### Install Go SDK Source: https://docs.getunleash.io/sdks/go.md Install the Unleash Go SDK module using the go get command. Ensure you are using Go 1.21 or later. ```bash go get github.com/Unleash/unleash-go-sdk/v6@latest ``` -------------------------------- ### Go HTTP Client Example for Get Access Overview Source: https://docs.getunleash.io/api/get-access-overview.md This Go program shows how to make a GET request to the Unleash API to get the access overview. It prints the response status and body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/access/overview" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.getunleash.io/api/get-application.md This Go example demonstrates making an HTTP GET request to the Unleash API. Replace `` with your valid API key. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/metrics/applications/appName" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Project Role Access (Go) Source: https://docs.getunleash.io/api/get-role-project-access.md This Go example demonstrates how to make an HTTP GET request to the API. It reads and prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/projects/roles/roleId/access" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Project Flag Creators (Go) Source: https://docs.getunleash.io/api/get-project-flag-creators.md This Go example shows how to construct an HTTP GET request, set the Authorization header, and read the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/projects/projectId/flag-creators" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Clone AI Chatbot Repository Source: https://docs.getunleash.io/guides/manage-ai-models-with-feature-flags.md Clone the example repository to get started with the AI chatbot integration. ```sh git clone https://github.com/alvinometric/feature-flags-ai cd feature-flags-ai ``` -------------------------------- ### Initialize Go Module and Install Dependencies Source: https://docs.getunleash.io/guides/implement-feature-flags-in-golang.md Set up a new Go project and install the Unleash SDK. This is the initial step for integrating feature flags. ```sh mkdir unleash-go cd unleash-go go mod init unleash-demo ``` ```sh go get github.com/Unleash/unleash-go-sdk/v5 ``` -------------------------------- ### C# RestSharp Example Source: https://docs.getunleash.io/api/get-available-change-request-reviewers.md An example using the RestSharp library in C# to make a GET request for available reviewers. Ensure you have the RestSharp NuGet package installed and replace placeholders. ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/api/admin/projects/projectId/change-requests/available-reviewers/environment"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", ""); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get UI Configuration (Go) Source: https://docs.getunleash.io/api/get-ui-config.md This Go example demonstrates fetching the UI configuration using the standard `net/http` package. Replace `` with your authentication token. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/ui-config" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Service Accounts (PHP) Source: https://docs.getunleash.io/api/get-service-accounts.md Example using GuzzleHttp in PHP to make a GET request to the service accounts API. This requires the GuzzleHttp library to be installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/service-account', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.getunleash.io/api/get-available-change-request-reviewers.md Demonstrates how to make a GET request using Go's standard `net/http` package to fetch available reviewers. Replace placeholders for API key and project ID. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/projects/projectId/change-requests/available-reviewers/environment" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Roles using PHP GuzzleHttp Source: https://docs.getunleash.io/api/get-roles.md This PHP example uses the GuzzleHttp client to make a GET request to the roles API. Ensure you have Guzzle installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/roles', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### POWER.md: Onboarding and Environment Setup Source: https://docs.getunleash.io/integrate/kiro.md Defines Unleash Power metadata, onboarding steps, and environment variable setup for Kiro. Includes bash scripts for creating credentials and sourcing them in shell profiles. ```markdown --- name: "unleash" displayName: "Unleash Feature Flags" description: "Automate feature flag management with Unleash. Evaluate code changes for risk, create flags with consistent naming, generate SDK wrapping code, manage rollouts, and clean up stale flags." keywords: ["feature flag", "feature toggle", "rollout", "unleash", "release", "experiment", "kill-switch", "canary", "progressive delivery", "featureops"] --- # Onboarding ## Step 1: Verify prerequisites - **Node.js 18+**: Verify with `node --version` - **Unleash instance**: Cloud or self-hosted, with API access - **Personal Access Token**: With permissions to create and manage flags ## Step 2: Set environment variables Create a credentials file and source it from your shell profile: ```bash mkdir -p ~/.unleash cat > ~/.unleash/mcp.env << 'EOF' UNLEASH_BASE_URL=https://your-instance.getunleash.io UNLEASH_PAT=your-personal-access-token UNLEASH_DEFAULT_PROJECT=default EOF chmod 600 ~/.unleash/mcp.env ``` Add to `~/.zshrc` or `~/.bashrc`: ```bash if [ -f ~/.unleash/mcp.env ]; then source ~/.unleash/mcp.env export UNLEASH_BASE_URL UNLEASH_PAT UNLEASH_DEFAULT_PROJECT fi ``` ## Step 3: Add hooks (optional) Save a File Save hook to `.kiro/hooks/evaluate-payments-flag.kiro.hook` to automatically evaluate payments changes. Adjust the `filePattern` to match your project's high-risk directories. # When to Load Steering Files - Setting up feature flags → `feature-flag-conventions.md` - Configuring rollout strategies → `rollout-guidance.md` - Cleaning up stale flags → `cleanup-cadence.md` ``` -------------------------------- ### Get Environment using C# RestSharp Source: https://docs.getunleash.io/api/get-environment.md This C# example uses the RestSharp library to retrieve environment information. Ensure you have the RestSharp NuGet package installed. ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/api/admin/environments/name"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", ""); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Setup Unleash Instance Source: https://docs.getunleash.io/guides/implement-feature-flags-in-nextjs.md Run these commands to download the Unleash Docker Compose file and start an Unleash instance locally. ```bash wget getunleash.io/docker-compose.yml docker-compose up -d ``` -------------------------------- ### Get Feature Strategies (PHP) Source: https://docs.getunleash.io/api/get-feature-strategies.md This PHP example uses Guzzle HTTP client to fetch feature strategies. It makes a GET request with the required `Authorization` header. Make sure to install Guzzle via Composer and replace the placeholders. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/projects/projectId/features/featureName/environments/environment/strategies', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get PATs using PHP Guzzle Source: https://docs.getunleash.io/api/get-pats.md This PHP example uses the Guzzle HTTP client to fetch PATs. Make sure you have Guzzle installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/user/tokens', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Initialize Unleash with Custom Redis Storage Source: https://docs.getunleash.io/sdks/node.md This example demonstrates initializing the Unleash client with a custom Redis-backed storage provider. Ensure you have the 'redis' package installed and a Redis server running. ```javascript import { initialize, InMemStorageProvider } from 'unleash-client'; import { createClient } from 'redis'; class CustomRedisStore { async set(key, data) { const client = createClient(); await client.connect(); await client.set(key, JSON.stringify(data)); } async get(key) { const client = createClient(); await client.connect(); const data = await client.get(key); return JSON.parse(data); } } const client = initialize({ appName: 'my-application', url: 'http://localhost:3000/api/', customHeaders: { Authorization: 'my-key', }, storageProvider: new CustomRedisStore(), }); ``` -------------------------------- ### Get All Feature Types (PHP) Source: https://docs.getunleash.io/api/get-all-feature-types.md This PHP example uses Guzzle HTTP client to fetch feature types. Make sure to install Guzzle via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/feature-types', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.getunleash.io/api/change-password.md Demonstrates how to reset a password using Go's standard net/http package. Ensure correct import paths for packages like 'strings' and 'net/http'. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/auth/reset/password" payload := strings.NewReader("{ \"token\": \"$2a$15$QzeW/y5/MEppCWVEkoX5euejobYOLSd4We21LQjjKlWH9l2I3wCke\", \"password\": \"correct horse battery staple\"}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Licensed Users using PHP Guzzle Source: https://docs.getunleash.io/api/get-all-licensed-users.md This PHP example uses the Guzzle HTTP client to make a GET request for licensed user information. Ensure you have Guzzle installed via Composer and replace "" with your key. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/licensed-users', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.getunleash.io/api/get-strategies-by-context-field-for-project.md Demonstrates making the API call using Go's standard net/http package. Remember to handle potential errors. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField/strategies" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Retrieve User Access Requests (PHP) Source: https://docs.getunleash.io/api/get-user-access-requests.md This PHP example uses Guzzle HTTP client to send a GET request. Make sure to install Guzzle via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/user-access-requests', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Create Project using Go Source: https://docs.getunleash.io/api/create-project.md This Go program shows how to create a project using the standard net/http package. Replace '' with your actual API key. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/projects" payload := strings.NewReader("{\n \"name\": \"Pet shop\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Project Access with PHP Guzzle Source: https://docs.getunleash.io/api/get-project-access.md This PHP example utilizes the Guzzle HTTP client to fetch project access data. Ensure you have Guzzle installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/projects/projectId/access', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Initialize SDK with Bootstrap File Path Source: https://docs.getunleash.io/sdks/node.md Initialize the Unleash SDK by loading flag configurations from a local file path. Ensure the file exists and contains valid JSON. ```javascript const client = initialize({ appName: 'my-application', url: 'https:///api/', customHeaders: { Authorization: '' }, bootstrap: { filePath: '/tmp/some-bootstrap.json', }, }); ``` -------------------------------- ### Get Environment using PHP Guzzle Source: https://docs.getunleash.io/api/get-environment.md Fetch environment details with PHP using the Guzzle HTTP client. This example requires the Guzzle library to be installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/environments/name', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get Outdated SDKs using PHP (Guzzle) Source: https://docs.getunleash.io/api/get-outdated-sdks.md This PHP example utilizes the Guzzle HTTP client to retrieve outdated SDK data. Ensure you have Guzzle installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/metrics/sdks/outdated', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Go HTTP Client for Signup Source: https://docs.getunleash.io/api/signup/submit-signup-data.md This Go program demonstrates how to make a POST request to the signup API. It uses the standard 'net/http' package. Ensure the API key is correctly provided in the Authorization header. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/signup" payload := strings.NewReader("{\n \"name\": \"Mark Scout\",\n \"companyRole\": \"Developer\",\n \"companyName\": \"Lumon Industries\",\n \"companyIsNA\": true,\n \"productUpdatesEmailConsent\": true,\n \"password\": \"k!5As3HquUrQ\",\n \"inviteEmails\": [\n \"marks@lumon.industries\",\n \"hellyr@lumon.industries\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### PHP Guzzle Example for Get Access Overview Source: https://docs.getunleash.io/api/get-access-overview.md This PHP script uses the Guzzle HTTP client to retrieve the access overview. Make sure you have installed Guzzle via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/access/overview', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Create User with Go SDK Source: https://docs.getunleash.io/api/create-user.md Example of creating a user using Go's standard http library. Replace `` with your actual API key. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/user-admin" payload := strings.NewReader("{\n \"rootRole\": \"Admin\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Fetch Application Overview using JavaScript (Fetch API) Source: https://docs.getunleash.io/api/get-application-overview.md This JavaScript example demonstrates how to fetch the application overview using the Fetch API. Remember to replace `` with your valid API key. ```javascript const url = 'https://app.unleash-instance.example.com/api/admin/metrics/applications/appName/overview'; const options = {method: 'GET', headers: {Authorization: ''}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Get Segments by Strategy ID - PHP Guzzle Source: https://docs.getunleash.io/api/get-segments-by-strategy-id.md This PHP example uses the Guzzle HTTP client to fetch segments by strategy ID. Ensure you have Guzzle installed via Composer and included. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/segments/strategies/strategyId', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get Application Environment Instances (Go) Source: https://docs.getunleash.io/api/get-application-environment-instances.md A Go program to fetch application environment instances. This example shows how to construct an HTTP GET request and read the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/metrics/instances/appName/environment/environment" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Feature Impact Metrics Config (PHP) Source: https://docs.getunleash.io/api/get-flag-impact-metrics-configs-by-feature.md Use Guzzle HTTP client in PHP to retrieve the feature impact metrics configuration. This example assumes Guzzle is installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/projects/projectId/features/featureName/impact-metrics/config', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get Signup Data Response Example Source: https://docs.getunleash.io/api/signup/get-signup-data.md This is an example of a successful response from the Get Signup Data API. ```json { "shouldSetPassword": true, "name": "Emily Carter", "companyRole": "Product Manager", "companyName": "Bright Future Tech", "companyIsNA": false, "productUpdatesEmailConsent": false } ``` -------------------------------- ### Run Development Server Source: https://docs.getunleash.io/guides/manage-ai-models-with-feature-flags.md Start the development server to run the SvelteKit application. ```sh npm run dev ``` -------------------------------- ### Get User Roles with PHP Guzzle Source: https://docs.getunleash.io/api/get-user-roles.md This PHP example uses the Guzzle HTTP client to retrieve user roles. Ensure you have Guzzle installed via Composer and include your API key in the headers. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/user/roles', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Install Unleash .NET SDK Source: https://docs.getunleash.io/sdks/dotnet.md Install the Unleash.Client package using the dotnet CLI. ```bash dotnet add package unleash.client ``` -------------------------------- ### Get Context Field API with PHP (Guzzle) Source: https://docs.getunleash.io/api/get-context-field.md This PHP example uses the Guzzle HTTP client to retrieve context field information. Ensure you have Guzzle installed and replace `` with your authorization token. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/context/contextField', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### PHP Guzzle: Get Feature Usage Summary Source: https://docs.getunleash.io/api/get-feature-usage-summary.md This PHP example uses the Guzzle HTTP client to retrieve feature usage summary data. It requires the Guzzle HTTP client library to be installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/client-metrics/features/name', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.getunleash.io/api/get-project-overview.md This Go code snippet shows how to make a GET request to the project overview API. It prints both the HTTP response and the body. Remember to replace '' with your authentication token. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/projects/projectId/overview" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Signup Data using PHP Guzzle Source: https://docs.getunleash.io/api/signup/get-signup-data.md This PHP example uses the Guzzle HTTP client to retrieve signup data. Make sure Guzzle is installed via Composer and substitute '' with your actual API key. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/signup', [ 'body' => '{}', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get Tags API Response Example Source: https://docs.getunleash.io/api/get-tags.md This is an example of the JSON response you can expect when calling the Get Tags API. It lists the tags configured in your Unleash instance, including their value, type, and color. ```json { "version": 1, "tags": [ { "value": "a-tag-value", "type": "simple", "color": "#FFFFFF" } ] } ``` -------------------------------- ### Create Environment using Go HTTP Client Source: https://docs.getunleash.io/api/create-environment.md Create a new environment using Go's standard `net/http` package. This example shows how to construct the request with headers and payload. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/environments" payload := strings.NewReader("{\n \"name\": \"staging-environment\",\n \"type\": \"preproduction\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get PATs Response Example Source: https://docs.getunleash.io/api/get-pats.md This is an example of the JSON response structure when successfully retrieving Personal Access Tokens. ```json { "pats": [ { "id": 1, "createdAt": "2023-04-19T08:15:14.000Z", "description": "user:xyzrandomstring", "expiresAt": "2023-04-19T08:15:14.000Z", "secret": "user:xyzrandomstring", "seenAt": "2023-04-19T08:15:14.000Z", "userId": 1337 } ] } ``` -------------------------------- ### Create Service Account using Go HTTP client Source: https://docs.getunleash.io/api/create-service-account.md Example of creating a service account using Go's standard net/http package. Replace with your actual API key. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/service-account" payload := strings.NewReader("{\n \"username\": \"service-account-1\",\n \"name\": \"Service Account 1\",\n \"rootRole\": 1\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.getunleash.io/api/create-application.md This Go example demonstrates how to create an application using the standard net/http package. It sets the necessary headers and sends the JSON payload. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/metrics/applications/appName" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Tags API using Go Source: https://docs.getunleash.io/api/get-tags.md This Go code example shows how to make a GET request to the Get Tags API. Replace `` with your Unleash API key. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.unleash-instance.example.com/api/admin/tags" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Fetch Application Overview using Swift Source: https://docs.getunleash.io/api/get-application-overview.md This Swift example demonstrates fetching application overview data using `URLSession`. Ensure you replace `` with your valid API key. ```swift import Foundation let headers = ["Authorization": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/api/admin/metrics/applications/appName/overview")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Create Environment Response Example Source: https://docs.getunleash.io/api/create-environment.md An example of the response received after successfully creating an environment. Includes details like enabled status, project count, and API token count. ```json { "name": "staging-environment", "type": "preproduction", "enabled": true, "protected": true, "sortOrder": 3, "projectCount": 10, "apiTokenCount": 6, "enabledToggleCount": 10, "requiredApprovals": 3 } ``` -------------------------------- ### PHP Guzzle Example Source: https://docs.getunleash.io/api/get-strategies-by-context-field-for-project.md This PHP example utilizes the Guzzle HTTP client. Make sure you have Guzzle installed via Composer. ```php request('GET', 'https://app.unleash-instance.example.com/api/admin/projects/projectId/context/contextField/strategies', [ 'body' => '{}', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Fetch Project Environments using Ruby Source: https://docs.getunleash.io/api/get-project-environments.md This Ruby example uses the built-in Net::HTTP library to make a GET request to the API. It shows how to set up the HTTP client, request, and headers, including the API key. ```ruby require 'uri' require 'net/http' url = URI("https://app.unleash-instance.example.com/api/admin/environments/project/projectId") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = '' response = http.request(request) puts response.read_body ```