# Check which tokens are valid POST https://app.unleash-instance.example.com/edge/validate Content-Type: application/json This operation accepts a list of tokens to validate. Unleash will validate each token you provide. For each valid token you provide, Unleash will return the token along with its type and which projects it has access to. Reference: https://docs.getunleash.io/api/get-valid-tokens ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Check which tokens are valid version: endpoint_unleashEdge.getValidTokens paths: /edge/validate: post: operationId: get-valid-tokens summary: Check which tokens are valid description: >- This operation accepts a list of tokens to validate. Unleash will validate each token you provide. For each valid token you provide, Unleash will return the token along with its type and which projects it has access to. tags: - - subpackage_unleashEdge parameters: [] responses: '200': description: validatedEdgeTokensSchema content: application/json: schema: $ref: '#/components/schemas/validatedEdgeTokensSchema' '400': description: The request data does not match what we expect. content: {} '413': description: >- The request body is larger than what we accept. By default we only accept bodies of 100kB or less content: {} '415': description: >- The operation does not support request payloads of the provided type. Please ensure that you're using one of the listed payload types and that you have specified the right content type in the "content-type" header. content: {} requestBody: description: tokenStringListSchema content: application/json: schema: $ref: '#/components/schemas/tokenStringListSchema' components: schemas: tokenStringListSchema: type: object properties: tokens: type: array items: type: string description: Tokens that we want to get access information about required: - tokens EdgeTokenSchemaType: type: string enum: - value: client - value: admin - value: frontend - value: backend edgeTokenSchema: type: object properties: projects: type: array items: type: string description: >- The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as [`*`] type: $ref: '#/components/schemas/EdgeTokenSchemaType' description: >- The [API token](https://docs.getunleash.io/concepts/api-tokens-and-client-keys)'s **type**. Unleash supports three different types of API tokens ([ADMIN](https://docs.getunleash.io/concepts/api-tokens-and-client-keys#admin-tokens), [CLIENT](https://docs.getunleash.io/concepts/api-tokens-and-client-keys#backend-tokens), [FRONTEND](https://docs.getunleash.io/concepts/api-tokens-and-client-keys#frontend-tokens)). They all have varying access, so when validating a token it's important to know what kind you're dealing with token: type: string description: >- The actual token value. [Unleash API tokens](https://docs.getunleash.io/concepts/api-tokens-and-client-keys) are comprised of three parts. :.randomcharacters required: - projects - type - token validatedEdgeTokensSchema: type: object properties: tokens: type: array items: $ref: '#/components/schemas/edgeTokenSchema' description: >- The list of Unleash token objects. Each object contains the token itself and some additional metadata. required: - tokens ``` ## SDK Code Examples ```python import requests url = "https://app.unleash-instance.example.com/edge/validate" payload = { "tokens": ["aproject:development.randomstring", "[]:production.randomstring"] } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://app.unleash-instance.example.com/edge/validate'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"tokens":["aproject:development.randomstring","[]:production.randomstring"]}' }; 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/edge/validate" payload := strings.NewReader("{\n \"tokens\": [\n \"aproject:development.randomstring\",\n \"[]:production.randomstring\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) 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/edge/validate") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"tokens\": [\n \"aproject:development.randomstring\",\n \"[]:production.randomstring\"\n ]\n}" 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/edge/validate") .header("Content-Type", "application/json") .body("{\n \"tokens\": [\n \"aproject:development.randomstring\",\n \"[]:production.randomstring\"\n ]\n}") .asString(); ``` ```php request('POST', 'https://app.unleash-instance.example.com/edge/validate', [ 'body' => '{ "tokens": [ "aproject:development.randomstring", "[]:production.randomstring" ] }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.unleash-instance.example.com/edge/validate"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"tokens\": [\n \"aproject:development.randomstring\",\n \"[]:production.randomstring\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = ["tokens": ["aproject:development.randomstring", "[]:production.randomstring"]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/edge/validate")! 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() ```