curl --request POST \
--url https://api.gcore.com/iam/clients/{clientId}/tokens \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "My token",
"exp_date": "2021-01-01T12:00:00.000000Z",
"client_user": {
"role": {
"id": 1,
"name": "Administrators"
}
},
"description": "It's my token"
}
EOFimport requests
url = "https://api.gcore.com/iam/clients/{clientId}/tokens"
payload = {
"name": "My token",
"exp_date": "2021-01-01T12:00:00.000000Z",
"client_user": { "role": {
"id": 1,
"name": "Administrators"
} },
"description": "It's my token"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'My token',
exp_date: '2021-01-01T12:00:00.000000Z',
client_user: {role: {id: 1, name: 'Administrators'}},
description: 'It\'s my token'
})
};
fetch('https://api.gcore.com/iam/clients/{clientId}/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/iam/clients/{clientId}/tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My token',
'exp_date' => '2021-01-01T12:00:00.000000Z',
'client_user' => [
'role' => [
'id' => 1,
'name' => 'Administrators'
]
],
'description' => 'It\'s my token'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gcore.com/iam/clients/{clientId}/tokens"
payload := strings.NewReader("{\n \"name\": \"My token\",\n \"exp_date\": \"2021-01-01T12:00:00.000000Z\",\n \"client_user\": {\n \"role\": {\n \"id\": 1,\n \"name\": \"Administrators\"\n }\n },\n \"description\": \"It's my token\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gcore.com/iam/clients/{clientId}/tokens")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My token\",\n \"exp_date\": \"2021-01-01T12:00:00.000000Z\",\n \"client_user\": {\n \"role\": {\n \"id\": 1,\n \"name\": \"Administrators\"\n }\n },\n \"description\": \"It's my token\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/iam/clients/{clientId}/tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"My token\",\n \"exp_date\": \"2021-01-01T12:00:00.000000Z\",\n \"client_user\": {\n \"role\": {\n \"id\": 1,\n \"name\": \"Administrators\"\n }\n },\n \"description\": \"It's my token\"\n}"
response = http.request(request)
puts response.read_body{
"name": "My token",
"exp_date": "2021-01-01T12:00:00.000000Z",
"client_user": {
"role": {
"id": 1,
"name": "Administrators"
},
"deleted": false,
"user_id": 123,
"user_name": "John Doe",
"user_email": "some@email.com",
"client_id": 456
},
"id": 42,
"deleted": false,
"expired": false,
"created": "2021-01-01T12:00:00.000000Z",
"last_usage": "2021-01-01T12:00:00.000000Z",
"token": "<string>",
"description": "It's my token"
}{
"errors": {
"client_user": {
"role": [
"Invalid role: RoleName"
]
}
}
}Create API token
Deprecated: This endpoint will be removed on 2026-07-17.
Use POST /v2/clients/{clientId}/tokens instead.
Create an API token in the current account.
curl --request POST \
--url https://api.gcore.com/iam/clients/{clientId}/tokens \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "My token",
"exp_date": "2021-01-01T12:00:00.000000Z",
"client_user": {
"role": {
"id": 1,
"name": "Administrators"
}
},
"description": "It's my token"
}
EOFimport requests
url = "https://api.gcore.com/iam/clients/{clientId}/tokens"
payload = {
"name": "My token",
"exp_date": "2021-01-01T12:00:00.000000Z",
"client_user": { "role": {
"id": 1,
"name": "Administrators"
} },
"description": "It's my token"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'My token',
exp_date: '2021-01-01T12:00:00.000000Z',
client_user: {role: {id: 1, name: 'Administrators'}},
description: 'It\'s my token'
})
};
fetch('https://api.gcore.com/iam/clients/{clientId}/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/iam/clients/{clientId}/tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My token',
'exp_date' => '2021-01-01T12:00:00.000000Z',
'client_user' => [
'role' => [
'id' => 1,
'name' => 'Administrators'
]
],
'description' => 'It\'s my token'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gcore.com/iam/clients/{clientId}/tokens"
payload := strings.NewReader("{\n \"name\": \"My token\",\n \"exp_date\": \"2021-01-01T12:00:00.000000Z\",\n \"client_user\": {\n \"role\": {\n \"id\": 1,\n \"name\": \"Administrators\"\n }\n },\n \"description\": \"It's my token\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gcore.com/iam/clients/{clientId}/tokens")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My token\",\n \"exp_date\": \"2021-01-01T12:00:00.000000Z\",\n \"client_user\": {\n \"role\": {\n \"id\": 1,\n \"name\": \"Administrators\"\n }\n },\n \"description\": \"It's my token\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/iam/clients/{clientId}/tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"My token\",\n \"exp_date\": \"2021-01-01T12:00:00.000000Z\",\n \"client_user\": {\n \"role\": {\n \"id\": 1,\n \"name\": \"Administrators\"\n }\n },\n \"description\": \"It's my token\"\n}"
response = http.request(request)
puts response.read_body{
"name": "My token",
"exp_date": "2021-01-01T12:00:00.000000Z",
"client_user": {
"role": {
"id": 1,
"name": "Administrators"
},
"deleted": false,
"user_id": 123,
"user_name": "John Doe",
"user_email": "some@email.com",
"client_id": 456
},
"id": 42,
"deleted": false,
"expired": false,
"created": "2021-01-01T12:00:00.000000Z",
"last_usage": "2021-01-01T12:00:00.000000Z",
"token": "<string>",
"description": "It's my token"
}{
"errors": {
"client_user": {
"role": [
"Invalid role: RoleName"
]
}
}
}Authorizations
API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234_abcdef
Path Parameters
Account ID.
Body
API token name.
"My token"
Date when the API token becomes expired (ISO 8086/RFC 3339 format), UTC. If null, then the API token will never expire.
"2021-01-01T12:00:00.000000Z"
API token role.
Show child attributes
Show child attributes
API token description.
"It's my token"
Response
OK.
API token name.
"My token"
Date when the API token becomes expired (ISO 8086/RFC 3339 format), UTC. If null, then the API token will never expire.
"2021-01-01T12:00:00.000000Z"
API token role and issuer data.
Show child attributes
Show child attributes
API token ID.
42
Deletion flag. If true, then the API token was deleted.
false
Expiration flag. If true, then the API token has expired. When an API token expires it will be automatically deleted.
false
Date when the API token was issued (ISO 8086/RFC 3339 format), UTC.
"2021-01-01T12:00:00.000000Z"
Date when the API token was last used (ISO 8086/RFC 3339 format), UTC.
"2021-01-01T12:00:00.000000Z"
API token. Copy it, because you will not be able to get it again. We do not store tokens. All responsibility for token storage and usage is on the issuer.
API token description.
"It's my token"
Was this page helpful?