Add user.
curl --request POST \
--url https://{tenant}/api/users \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"active": true,
"email_address": "itachi@gmail.com",
"first_name": "itachi",
"last_name": "sasuke",
"user_permissions": {
"analytics": "read",
"api_assets": "write",
"apis": "write",
"certs": "write",
"hooks": "write",
"idm": "write",
"keys": "write",
"log": "read",
"oauth": "write",
"policies": "write",
"portal": "write",
"system": "write",
"user_groups": "write",
"users": "write",
"websockets": "read"
}
}
'import requests
url = "https://{tenant}/api/users"
payload = {
"active": True,
"email_address": "itachi@gmail.com",
"first_name": "itachi",
"last_name": "sasuke",
"user_permissions": {
"analytics": "read",
"api_assets": "write",
"apis": "write",
"certs": "write",
"hooks": "write",
"idm": "write",
"keys": "write",
"log": "read",
"oauth": "write",
"policies": "write",
"portal": "write",
"system": "write",
"user_groups": "write",
"users": "write",
"websockets": "read"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
active: true,
email_address: 'itachi@gmail.com',
first_name: 'itachi',
last_name: 'sasuke',
user_permissions: {
analytics: 'read',
api_assets: 'write',
apis: 'write',
certs: 'write',
hooks: 'write',
idm: 'write',
keys: 'write',
log: 'read',
oauth: 'write',
policies: 'write',
portal: 'write',
system: 'write',
user_groups: 'write',
users: 'write',
websockets: 'read'
}
})
};
fetch('https://{tenant}/api/users', 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://{tenant}/api/users",
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([
'active' => true,
'email_address' => 'itachi@gmail.com',
'first_name' => 'itachi',
'last_name' => 'sasuke',
'user_permissions' => [
'analytics' => 'read',
'api_assets' => 'write',
'apis' => 'write',
'certs' => 'write',
'hooks' => 'write',
'idm' => 'write',
'keys' => 'write',
'log' => 'read',
'oauth' => 'write',
'policies' => 'write',
'portal' => 'write',
'system' => 'write',
'user_groups' => 'write',
'users' => 'write',
'websockets' => 'read'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://{tenant}/api/users"
payload := strings.NewReader("{\n \"active\": true,\n \"email_address\": \"itachi@gmail.com\",\n \"first_name\": \"itachi\",\n \"last_name\": \"sasuke\",\n \"user_permissions\": {\n \"analytics\": \"read\",\n \"api_assets\": \"write\",\n \"apis\": \"write\",\n \"certs\": \"write\",\n \"hooks\": \"write\",\n \"idm\": \"write\",\n \"keys\": \"write\",\n \"log\": \"read\",\n \"oauth\": \"write\",\n \"policies\": \"write\",\n \"portal\": \"write\",\n \"system\": \"write\",\n \"user_groups\": \"write\",\n \"users\": \"write\",\n \"websockets\": \"read\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://{tenant}/api/users")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"active\": true,\n \"email_address\": \"itachi@gmail.com\",\n \"first_name\": \"itachi\",\n \"last_name\": \"sasuke\",\n \"user_permissions\": {\n \"analytics\": \"read\",\n \"api_assets\": \"write\",\n \"apis\": \"write\",\n \"certs\": \"write\",\n \"hooks\": \"write\",\n \"idm\": \"write\",\n \"keys\": \"write\",\n \"log\": \"read\",\n \"oauth\": \"write\",\n \"policies\": \"write\",\n \"portal\": \"write\",\n \"system\": \"write\",\n \"user_groups\": \"write\",\n \"users\": \"write\",\n \"websockets\": \"read\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/users")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"active\": true,\n \"email_address\": \"itachi@gmail.com\",\n \"first_name\": \"itachi\",\n \"last_name\": \"sasuke\",\n \"user_permissions\": {\n \"analytics\": \"read\",\n \"api_assets\": \"write\",\n \"apis\": \"write\",\n \"certs\": \"write\",\n \"hooks\": \"write\",\n \"idm\": \"write\",\n \"keys\": \"write\",\n \"log\": \"read\",\n \"oauth\": \"write\",\n \"policies\": \"write\",\n \"portal\": \"write\",\n \"system\": \"write\",\n \"user_groups\": \"write\",\n \"users\": \"write\",\n \"websockets\": \"read\"\n }\n}"
response = http.request(request)
puts response.read_body{
"Message": "User and session have been created",
"Meta": "6649a9e85715ec4c96cbef2f",
"Status": "OK"
}{
"Message": "User object validation failed.",
"Meta": null,
"Status": "Error"
}{
"Message": "Not authorised",
"Meta": null,
"Status": "Error"
}{
"Message": "User email already exists for this org.",
"Meta": null,
"Status": "Error"
}{
"Message": "Couldn't retrieve user session details.",
"Meta": null,
"Status": "Error"
}Users
Add user.
Create a user. If you want to create an admin user, you need to send {IsAdmin: admin} in the user_permissions field e.g ```{user_permissions: {IsAdmin: admin},last_name: sasuke,email_address: itachi@gmail.com,first_name: itachi}```. You can add a user to a given user-group by sending the group_id in the request body. If you want to give a user access only to specific objects e.g policies you can send the object and the permission granted to the user (read or write permission in the user_permissions field (check the request example given for more details)).
POST
/
api
/
users
Add user.
curl --request POST \
--url https://{tenant}/api/users \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"active": true,
"email_address": "itachi@gmail.com",
"first_name": "itachi",
"last_name": "sasuke",
"user_permissions": {
"analytics": "read",
"api_assets": "write",
"apis": "write",
"certs": "write",
"hooks": "write",
"idm": "write",
"keys": "write",
"log": "read",
"oauth": "write",
"policies": "write",
"portal": "write",
"system": "write",
"user_groups": "write",
"users": "write",
"websockets": "read"
}
}
'import requests
url = "https://{tenant}/api/users"
payload = {
"active": True,
"email_address": "itachi@gmail.com",
"first_name": "itachi",
"last_name": "sasuke",
"user_permissions": {
"analytics": "read",
"api_assets": "write",
"apis": "write",
"certs": "write",
"hooks": "write",
"idm": "write",
"keys": "write",
"log": "read",
"oauth": "write",
"policies": "write",
"portal": "write",
"system": "write",
"user_groups": "write",
"users": "write",
"websockets": "read"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
active: true,
email_address: 'itachi@gmail.com',
first_name: 'itachi',
last_name: 'sasuke',
user_permissions: {
analytics: 'read',
api_assets: 'write',
apis: 'write',
certs: 'write',
hooks: 'write',
idm: 'write',
keys: 'write',
log: 'read',
oauth: 'write',
policies: 'write',
portal: 'write',
system: 'write',
user_groups: 'write',
users: 'write',
websockets: 'read'
}
})
};
fetch('https://{tenant}/api/users', 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://{tenant}/api/users",
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([
'active' => true,
'email_address' => 'itachi@gmail.com',
'first_name' => 'itachi',
'last_name' => 'sasuke',
'user_permissions' => [
'analytics' => 'read',
'api_assets' => 'write',
'apis' => 'write',
'certs' => 'write',
'hooks' => 'write',
'idm' => 'write',
'keys' => 'write',
'log' => 'read',
'oauth' => 'write',
'policies' => 'write',
'portal' => 'write',
'system' => 'write',
'user_groups' => 'write',
'users' => 'write',
'websockets' => 'read'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://{tenant}/api/users"
payload := strings.NewReader("{\n \"active\": true,\n \"email_address\": \"itachi@gmail.com\",\n \"first_name\": \"itachi\",\n \"last_name\": \"sasuke\",\n \"user_permissions\": {\n \"analytics\": \"read\",\n \"api_assets\": \"write\",\n \"apis\": \"write\",\n \"certs\": \"write\",\n \"hooks\": \"write\",\n \"idm\": \"write\",\n \"keys\": \"write\",\n \"log\": \"read\",\n \"oauth\": \"write\",\n \"policies\": \"write\",\n \"portal\": \"write\",\n \"system\": \"write\",\n \"user_groups\": \"write\",\n \"users\": \"write\",\n \"websockets\": \"read\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://{tenant}/api/users")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"active\": true,\n \"email_address\": \"itachi@gmail.com\",\n \"first_name\": \"itachi\",\n \"last_name\": \"sasuke\",\n \"user_permissions\": {\n \"analytics\": \"read\",\n \"api_assets\": \"write\",\n \"apis\": \"write\",\n \"certs\": \"write\",\n \"hooks\": \"write\",\n \"idm\": \"write\",\n \"keys\": \"write\",\n \"log\": \"read\",\n \"oauth\": \"write\",\n \"policies\": \"write\",\n \"portal\": \"write\",\n \"system\": \"write\",\n \"user_groups\": \"write\",\n \"users\": \"write\",\n \"websockets\": \"read\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/users")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"active\": true,\n \"email_address\": \"itachi@gmail.com\",\n \"first_name\": \"itachi\",\n \"last_name\": \"sasuke\",\n \"user_permissions\": {\n \"analytics\": \"read\",\n \"api_assets\": \"write\",\n \"apis\": \"write\",\n \"certs\": \"write\",\n \"hooks\": \"write\",\n \"idm\": \"write\",\n \"keys\": \"write\",\n \"log\": \"read\",\n \"oauth\": \"write\",\n \"policies\": \"write\",\n \"portal\": \"write\",\n \"system\": \"write\",\n \"user_groups\": \"write\",\n \"users\": \"write\",\n \"websockets\": \"read\"\n }\n}"
response = http.request(request)
puts response.read_body{
"Message": "User and session have been created",
"Meta": "6649a9e85715ec4c96cbef2f",
"Status": "OK"
}{
"Message": "User object validation failed.",
"Meta": null,
"Status": "Error"
}{
"Message": "Not authorised",
"Meta": null,
"Status": "Error"
}{
"Message": "User email already exists for this org.",
"Meta": null,
"Status": "Error"
}{
"Message": "Couldn't retrieve user session details.",
"Meta": null,
"Status": "Error"
}Authorizations
The Tyk Dashboard API Access Credentials
Body
application/json
Example:
"multi-org-user@example.org"
Example:
"itachi"
Example:
"sasuke"
Show child attributes
Show child attributes
Example:
"d7ebef749e4348cb67fec3cfc81f0a50"
Example:
true
Example:
"2024-05-19T08:23:29.034+03:00"
Example:
"5e9d9544a1dcd60001d0ed20"
Example:
"66498cd1e2fcd1000184ecb5"
Example:
"2024-05-19T08:42:22.659839+03:00"
Example:
"5e9d9544a1dcd60001d0ed20"
Example:
0
Example:
"2024-05-19T08:23:29.146+03:00"
Was this page helpful?
⌘I