> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.getunleash.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getunleash.io/_mcp/server.

# Get or create valid tokens for the requested environment

POST https://app.unleash-instance.example.com/edge/issue-token
Content-Type: application/json

This operation accepts a list of environments/project pairs to return tokens for. If they do not exist, Unleash will generate them

Reference: https://docs.getunleash.io/api/edge-create-or-return-tokens

## Request

### Body (application/json)

This endpoint expects an edgeEnvironmentProjectsListSchema.

- `tokens` (list of EdgeEnvironmentProjectsListSchemaTokensItems, required) — A list of requested api tokens.

## Response

### 200

validatedEdgeTokensSchema

- `tokens` (list of edgeTokenSchema, required) — The list of Unleash token objects. Each object contains the token itself and some additional metadata.

## Errors

### 400 Bad Request Error

The request data does not match what we expect.

- `id` (string, optional) — The ID of the error instance
- `name` (string, optional) — The name of the error kind
- `message` (string, optional) — A description of what went wrong.

### 403 Forbidden Error

The provided user credentials are valid, but the user does not have the necessary permissions to perform this operation

- `id` (string, optional) — The ID of the error instance
- `name` (string, optional) — The name of the error kind
- `message` (string, optional) — A description of what went wrong.

### 413 Content Too Large Error

The request body is larger than what we accept. By default we only accept bodies of 100kB or less

- `id` (string, optional) — The ID of the error instance
- `name` (string, optional) — The name of the error kind
- `message` (string, optional) — A description of what went wrong.

### 415 Unsupported Media Type Error

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.

- `id` (string, optional) — The ID of the error instance
- `name` (string, optional) — The name of the error kind
- `message` (string, optional) — A description of what went wrong.

## Types

### EdgeEnvironmentProjectsListSchemaTokensItems

A list of requested environment -> projects tuples.

- `environment` (string, required) — The name of an existing environment
- `projects` (list of string, required) — The list of projects Edge wants access to, or '*' for a wildcard token

### edgeTokenSchema

A representation of a client token, limiting access to [CLIENT](https://docs.getunleash.io/concepts/api-tokens-and-client-keys#backend-tokens) (used by serverside SDKs) or [FRONTEND](https://docs.getunleash.io/concepts/api-tokens-and-client-keys#frontend-tokens) (used by proxy SDKs)

- `projects` (list of string, required) — 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 [`*`]
- `environment` (string, required) — The environment this token as access to
- `type` (enum, required) — 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
  - Allowed values: `client`, `admin`, `frontend`, `backend`
- `token` (string, required) — The actual token value. [Unleash API tokens](https://docs.getunleash.io/concepts/api-tokens-and-client-keys) are comprised of three parts. \<project(s)>:\<environment>.randomcharacters

## Examples

**Request**

```json
{
  "tokens": [
    {
      "environment": "development",
      "projects": [
        "default"
      ]
    }
  ]
}
```

**Response**

```json
{
  "tokens": [
    {
      "projects": [
        "developerexperience",
        "enterprisegrowth"
      ],
      "environment": "development",
      "type": "client",
      "token": "*:development.5c806b5320c88cf27e81f3e9b97dab298a77d5879316e3c2d806206b"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://app.unleash-instance.example.com/edge/issue-token"

payload = { "tokens": [
        {
            "environment": "development",
            "projects": ["default"]
        }
    ] }
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/issue-token';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"tokens":[{"environment":"development","projects":["default"]}]}'
};

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/issue-token"

	payload := strings.NewReader("{\n  \"tokens\": [\n    {\n      \"environment\": \"development\",\n      \"projects\": [\n        \"default\"\n      ]\n    }\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/issue-token")

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    {\n      \"environment\": \"development\",\n      \"projects\": [\n        \"default\"\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.unleash-instance.example.com/edge/issue-token")
  .header("Content-Type", "application/json")
  .body("{\n  \"tokens\": [\n    {\n      \"environment\": \"development\",\n      \"projects\": [\n        \"default\"\n      ]\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.unleash-instance.example.com/edge/issue-token', [
  'body' => '{
  "tokens": [
    {
      "environment": "development",
      "projects": [
        "default"
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.unleash-instance.example.com/edge/issue-token");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"tokens\": [\n    {\n      \"environment\": \"development\",\n      \"projects\": [\n        \"default\"\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["tokens": [
    [
      "environment": "development",
      "projects": ["default"]
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/edge/issue-token")! 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()
```