# Create an application to connect reported metrics POST https://app.unleash-instance.example.com/api/admin/metrics/applications/{appName} Content-Type: application/json Is used to report usage as well which sdk the application uses Reference: https://docs.getunleash.io/api/create-application ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create an application to connect reported metrics version: endpoint_metrics.createApplication paths: /api/admin/metrics/applications/{appName}: post: operationId: create-application summary: Create an application to connect reported metrics description: Is used to report usage as well which sdk the application uses tags: - - subpackage_metrics parameters: - name: appName in: path required: true schema: type: string - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '202': description: This response has no body. content: application/json: schema: $ref: '#/components/schemas/Metrics_createApplication_Response_202' '400': description: The request data does not match what we expect. content: {} '401': description: >- Authorization information is missing or invalid. Provide a valid API token as the `authorization` header, e.g. `authorization:*.*.my-admin-token`. content: {} '403': description: >- The provided user credentials are valid, but the user does not have the necessary permissions to perform this operation content: {} requestBody: description: createApplicationSchema content: application/json: schema: $ref: '#/components/schemas/createApplicationSchema' components: schemas: createApplicationSchema: type: object properties: strategies: type: array items: type: string description: >- Which [strategies](https://docs.getunleash.io/concepts#activation-strategies) the application has loaded. Useful when trying to figure out if your [custom strategy](https://docs.getunleash.io/concepts/activation-strategies#custom-strategies) has been loaded in the SDK url: type: string description: >- A link to reference the application reporting the metrics. Could for instance be a GitHub link to the repository of the application color: type: string description: >- Css color to be used to color the application's entry in the application list icon: type: string description: >- An URL to an icon file to be used for the applications's entry in the application list Metrics_createApplication_Response_202: type: object properties: {} ``` ## SDK Code Examples ```python import requests url = "https://app.unleash-instance.example.com/api/admin/metrics/applications/appName" payload = {} headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://app.unleash-instance.example.com/api/admin/metrics/applications/appName'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```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)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://app.unleash-instance.example.com/api/admin/metrics/applications/appName") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://app.unleash-instance.example.com/api/admin/metrics/applications/appName") .header("Authorization", "") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('POST', 'https://app.unleash-instance.example.com/api/admin/metrics/applications/appName', [ 'body' => '{}', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/api/admin/metrics/applications/appName"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/api/admin/metrics/applications/appName")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ```