> 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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: admin-api
  version: 1.0.0
paths:
  /edge/issue-token:
    post:
      operationId: edgeCreateOrReturnTokens
      summary: Get or create valid tokens for the requested environment
      description: >-
        This operation accepts a list of environments/project pairs to return
        tokens for. If they do not exist, Unleash will generate them
      tags:
        - unleashEdge
      responses:
        '200':
          description: validatedEdgeTokensSchema
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/validatedEdgeTokensSchema'
        '400':
          description: The request data does not match what we expect.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/EdgeCreateOrReturnTokensRequestBadRequestError
        '403':
          description: >-
            The provided user credentials are valid, but the user does not have
            the necessary permissions to perform this operation
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/EdgeCreateOrReturnTokensRequestForbiddenError
        '413':
          description: >-
            The request body is larger than what we accept. By default we only
            accept bodies of 100kB or less
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/EdgeCreateOrReturnTokensRequestContentTooLargeError
        '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:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/EdgeCreateOrReturnTokensRequestUnsupportedMediaTypeError
      requestBody:
        description: edgeEnvironmentProjectsListSchema
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/edgeEnvironmentProjectsListSchema'
servers:
  - url: https://app.unleash-instance.example.com
    description: Your Unleash instance (replace with your actual URL)
components:
  schemas:
    EdgeEnvironmentProjectsListSchemaTokensItems:
      type: object
      properties:
        environment:
          type: string
          description: The name of an existing environment
        projects:
          type: array
          items:
            type: string
          description: >-
            The list of projects Edge wants access to, or '*' for a wildcard
            token
      required:
        - environment
        - projects
      description: A list of requested environment -> projects tuples.
      title: EdgeEnvironmentProjectsListSchemaTokensItems
    edgeEnvironmentProjectsListSchema:
      type: object
      properties:
        tokens:
          type: array
          items:
            $ref: '#/components/schemas/EdgeEnvironmentProjectsListSchemaTokensItems'
          description: A list of requested api tokens.
      required:
        - tokens
      description: >-
        Schema to request api tokens for a list of environment -> projects
        tuples
      title: edgeEnvironmentProjectsListSchema
    EdgeTokenSchemaType:
      type: string
      enum:
        - client
        - admin
        - frontend
        - backend
      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
      title: EdgeTokenSchemaType
    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 [`*`]
        environment:
          type: string
          description: The environment this token as access to
        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.
            <project(s)>:<environment>.randomcharacters
      required:
        - projects
        - environment
        - type
        - token
      description: >-
        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)
      title: edgeTokenSchema
    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
      description: A object containing a list of valid Unleash tokens.
      title: validatedEdgeTokensSchema
    EdgeCreateOrReturnTokensRequestBadRequestError:
      type: object
      properties:
        id:
          type: string
          description: The ID of the error instance
        name:
          type: string
          description: The name of the error kind
        message:
          type: string
          description: A description of what went wrong.
      title: EdgeCreateOrReturnTokensRequestBadRequestError
    EdgeCreateOrReturnTokensRequestForbiddenError:
      type: object
      properties:
        id:
          type: string
          description: The ID of the error instance
        name:
          type: string
          description: The name of the error kind
        message:
          type: string
          description: A description of what went wrong.
      title: EdgeCreateOrReturnTokensRequestForbiddenError
    EdgeCreateOrReturnTokensRequestContentTooLargeError:
      type: object
      properties:
        id:
          type: string
          description: The ID of the error instance
        name:
          type: string
          description: The name of the error kind
        message:
          type: string
          description: A description of what went wrong.
      title: EdgeCreateOrReturnTokensRequestContentTooLargeError
    EdgeCreateOrReturnTokensRequestUnsupportedMediaTypeError:
      type: object
      properties:
        id:
          type: string
          description: The ID of the error instance
        name:
          type: string
          description: The name of the error kind
        message:
          type: string
          description: A description of what went wrong.
      title: EdgeCreateOrReturnTokensRequestUnsupportedMediaTypeError

```

## 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()
```