Import organisations
curl --request POST \
--url https://{tenant}/admin/organisations/import \
--header 'Admin-Auth: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"apis": [
{
"api_human_name": "API 2",
"api_id": "5fa2db834e07444f760b7ceb314209fb"
},
{
"api_human_name": "API 1",
"api_id": "7a6ddeca9244448a4233866938a0d6e2"
},
{
"api_human_name": "API 3",
"api_id": "109eacaa50b24b64651a1d4dce8ec385"
}
],
"cname": "my.domain.com",
"cname_enabled": true,
"developer_count": 21,
"developer_quota": 123,
"event_options": {
"key_event": {
"email": "",
"redis": true,
"webhook": ""
},
"key_request_event": {
"email": "",
"redis": false,
"webhook": ""
}
},
"hybrid_enabled": false,
"id": "53ac07777cbb8c2d53000002",
"owner_name": "Test",
"owner_slug": "test",
"ui": {
"default_lang": "",
"designer": {},
"dont_allow_license_management": false,
"dont_allow_license_management_view": false,
"dont_show_admin_sockets": false,
"hide_help": false,
"languages": {},
"login_page": {},
"nav": {},
"portal_section": {},
"uptime": {}
}
}
'import requests
url = "https://{tenant}/admin/organisations/import"
payload = {
"apis": [
{
"api_human_name": "API 2",
"api_id": "5fa2db834e07444f760b7ceb314209fb"
},
{
"api_human_name": "API 1",
"api_id": "7a6ddeca9244448a4233866938a0d6e2"
},
{
"api_human_name": "API 3",
"api_id": "109eacaa50b24b64651a1d4dce8ec385"
}
],
"cname": "my.domain.com",
"cname_enabled": True,
"developer_count": 21,
"developer_quota": 123,
"event_options": {
"key_event": {
"email": "",
"redis": True,
"webhook": ""
},
"key_request_event": {
"email": "",
"redis": False,
"webhook": ""
}
},
"hybrid_enabled": False,
"id": "53ac07777cbb8c2d53000002",
"owner_name": "Test",
"owner_slug": "test",
"ui": {
"default_lang": "",
"designer": {},
"dont_allow_license_management": False,
"dont_allow_license_management_view": False,
"dont_show_admin_sockets": False,
"hide_help": False,
"languages": {},
"login_page": {},
"nav": {},
"portal_section": {},
"uptime": {}
}
}
headers = {
"Admin-Auth": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Admin-Auth': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
apis: [
{api_human_name: 'API 2', api_id: '5fa2db834e07444f760b7ceb314209fb'},
{api_human_name: 'API 1', api_id: '7a6ddeca9244448a4233866938a0d6e2'},
{api_human_name: 'API 3', api_id: '109eacaa50b24b64651a1d4dce8ec385'}
],
cname: 'my.domain.com',
cname_enabled: true,
developer_count: 21,
developer_quota: 123,
event_options: {
key_event: {email: '', redis: true, webhook: ''},
key_request_event: {email: '', redis: false, webhook: ''}
},
hybrid_enabled: false,
id: '53ac07777cbb8c2d53000002',
owner_name: 'Test',
owner_slug: 'test',
ui: {
default_lang: '',
designer: {},
dont_allow_license_management: false,
dont_allow_license_management_view: false,
dont_show_admin_sockets: false,
hide_help: false,
languages: {},
login_page: {},
nav: {},
portal_section: {},
uptime: {}
}
})
};
fetch('https://{tenant}/admin/organisations/import', 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}/admin/organisations/import",
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([
'apis' => [
[
'api_human_name' => 'API 2',
'api_id' => '5fa2db834e07444f760b7ceb314209fb'
],
[
'api_human_name' => 'API 1',
'api_id' => '7a6ddeca9244448a4233866938a0d6e2'
],
[
'api_human_name' => 'API 3',
'api_id' => '109eacaa50b24b64651a1d4dce8ec385'
]
],
'cname' => 'my.domain.com',
'cname_enabled' => true,
'developer_count' => 21,
'developer_quota' => 123,
'event_options' => [
'key_event' => [
'email' => '',
'redis' => true,
'webhook' => ''
],
'key_request_event' => [
'email' => '',
'redis' => false,
'webhook' => ''
]
],
'hybrid_enabled' => false,
'id' => '53ac07777cbb8c2d53000002',
'owner_name' => 'Test',
'owner_slug' => 'test',
'ui' => [
'default_lang' => '',
'designer' => [
],
'dont_allow_license_management' => false,
'dont_allow_license_management_view' => false,
'dont_show_admin_sockets' => false,
'hide_help' => false,
'languages' => [
],
'login_page' => [
],
'nav' => [
],
'portal_section' => [
],
'uptime' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"Admin-Auth: <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://{tenant}/admin/organisations/import"
payload := strings.NewReader("{\n \"apis\": [\n {\n \"api_human_name\": \"API 2\",\n \"api_id\": \"5fa2db834e07444f760b7ceb314209fb\"\n },\n {\n \"api_human_name\": \"API 1\",\n \"api_id\": \"7a6ddeca9244448a4233866938a0d6e2\"\n },\n {\n \"api_human_name\": \"API 3\",\n \"api_id\": \"109eacaa50b24b64651a1d4dce8ec385\"\n }\n ],\n \"cname\": \"my.domain.com\",\n \"cname_enabled\": true,\n \"developer_count\": 21,\n \"developer_quota\": 123,\n \"event_options\": {\n \"key_event\": {\n \"email\": \"\",\n \"redis\": true,\n \"webhook\": \"\"\n },\n \"key_request_event\": {\n \"email\": \"\",\n \"redis\": false,\n \"webhook\": \"\"\n }\n },\n \"hybrid_enabled\": false,\n \"id\": \"53ac07777cbb8c2d53000002\",\n \"owner_name\": \"Test\",\n \"owner_slug\": \"test\",\n \"ui\": {\n \"default_lang\": \"\",\n \"designer\": {},\n \"dont_allow_license_management\": false,\n \"dont_allow_license_management_view\": false,\n \"dont_show_admin_sockets\": false,\n \"hide_help\": false,\n \"languages\": {},\n \"login_page\": {},\n \"nav\": {},\n \"portal_section\": {},\n \"uptime\": {}\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Admin-Auth", "<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://{tenant}/admin/organisations/import")
.header("Admin-Auth", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"apis\": [\n {\n \"api_human_name\": \"API 2\",\n \"api_id\": \"5fa2db834e07444f760b7ceb314209fb\"\n },\n {\n \"api_human_name\": \"API 1\",\n \"api_id\": \"7a6ddeca9244448a4233866938a0d6e2\"\n },\n {\n \"api_human_name\": \"API 3\",\n \"api_id\": \"109eacaa50b24b64651a1d4dce8ec385\"\n }\n ],\n \"cname\": \"my.domain.com\",\n \"cname_enabled\": true,\n \"developer_count\": 21,\n \"developer_quota\": 123,\n \"event_options\": {\n \"key_event\": {\n \"email\": \"\",\n \"redis\": true,\n \"webhook\": \"\"\n },\n \"key_request_event\": {\n \"email\": \"\",\n \"redis\": false,\n \"webhook\": \"\"\n }\n },\n \"hybrid_enabled\": false,\n \"id\": \"53ac07777cbb8c2d53000002\",\n \"owner_name\": \"Test\",\n \"owner_slug\": \"test\",\n \"ui\": {\n \"default_lang\": \"\",\n \"designer\": {},\n \"dont_allow_license_management\": false,\n \"dont_allow_license_management_view\": false,\n \"dont_show_admin_sockets\": false,\n \"hide_help\": false,\n \"languages\": {},\n \"login_page\": {},\n \"nav\": {},\n \"portal_section\": {},\n \"uptime\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/admin/organisations/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Admin-Auth"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"apis\": [\n {\n \"api_human_name\": \"API 2\",\n \"api_id\": \"5fa2db834e07444f760b7ceb314209fb\"\n },\n {\n \"api_human_name\": \"API 1\",\n \"api_id\": \"7a6ddeca9244448a4233866938a0d6e2\"\n },\n {\n \"api_human_name\": \"API 3\",\n \"api_id\": \"109eacaa50b24b64651a1d4dce8ec385\"\n }\n ],\n \"cname\": \"my.domain.com\",\n \"cname_enabled\": true,\n \"developer_count\": 21,\n \"developer_quota\": 123,\n \"event_options\": {\n \"key_event\": {\n \"email\": \"\",\n \"redis\": true,\n \"webhook\": \"\"\n },\n \"key_request_event\": {\n \"email\": \"\",\n \"redis\": false,\n \"webhook\": \"\"\n }\n },\n \"hybrid_enabled\": false,\n \"id\": \"53ac07777cbb8c2d53000002\",\n \"owner_name\": \"Test\",\n \"owner_slug\": \"test\",\n \"ui\": {\n \"default_lang\": \"\",\n \"designer\": {},\n \"dont_allow_license_management\": false,\n \"dont_allow_license_management_view\": false,\n \"dont_show_admin_sockets\": false,\n \"hide_help\": false,\n \"languages\": {},\n \"login_page\": {},\n \"nav\": {},\n \"portal_section\": {},\n \"uptime\": {}\n }\n}"
response = http.request(request)
puts response.read_body{
"Message": "Org imported",
"Meta": "53ac07777cbb8c2d53000002",
"Status": "OK"
}{
"Message": "Not authorised",
"Meta": null,
"Status": "Error"
}{
"Message": "Failed to save new Org object to DB",
"Meta": null,
"Status": "Error"
}{
"Message": "Failed to read response body, body empty",
"Meta": null,
"Status": "Error"
}Import
Import organisations
The organisation object is the most fundamental object in a Tyk setup, all other ownership properties hang off the relationship between an organisation and it’s APIs, Policies and API Tokens.
POST
/
admin
/
organisations
/
import
Import organisations
curl --request POST \
--url https://{tenant}/admin/organisations/import \
--header 'Admin-Auth: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"apis": [
{
"api_human_name": "API 2",
"api_id": "5fa2db834e07444f760b7ceb314209fb"
},
{
"api_human_name": "API 1",
"api_id": "7a6ddeca9244448a4233866938a0d6e2"
},
{
"api_human_name": "API 3",
"api_id": "109eacaa50b24b64651a1d4dce8ec385"
}
],
"cname": "my.domain.com",
"cname_enabled": true,
"developer_count": 21,
"developer_quota": 123,
"event_options": {
"key_event": {
"email": "",
"redis": true,
"webhook": ""
},
"key_request_event": {
"email": "",
"redis": false,
"webhook": ""
}
},
"hybrid_enabled": false,
"id": "53ac07777cbb8c2d53000002",
"owner_name": "Test",
"owner_slug": "test",
"ui": {
"default_lang": "",
"designer": {},
"dont_allow_license_management": false,
"dont_allow_license_management_view": false,
"dont_show_admin_sockets": false,
"hide_help": false,
"languages": {},
"login_page": {},
"nav": {},
"portal_section": {},
"uptime": {}
}
}
'import requests
url = "https://{tenant}/admin/organisations/import"
payload = {
"apis": [
{
"api_human_name": "API 2",
"api_id": "5fa2db834e07444f760b7ceb314209fb"
},
{
"api_human_name": "API 1",
"api_id": "7a6ddeca9244448a4233866938a0d6e2"
},
{
"api_human_name": "API 3",
"api_id": "109eacaa50b24b64651a1d4dce8ec385"
}
],
"cname": "my.domain.com",
"cname_enabled": True,
"developer_count": 21,
"developer_quota": 123,
"event_options": {
"key_event": {
"email": "",
"redis": True,
"webhook": ""
},
"key_request_event": {
"email": "",
"redis": False,
"webhook": ""
}
},
"hybrid_enabled": False,
"id": "53ac07777cbb8c2d53000002",
"owner_name": "Test",
"owner_slug": "test",
"ui": {
"default_lang": "",
"designer": {},
"dont_allow_license_management": False,
"dont_allow_license_management_view": False,
"dont_show_admin_sockets": False,
"hide_help": False,
"languages": {},
"login_page": {},
"nav": {},
"portal_section": {},
"uptime": {}
}
}
headers = {
"Admin-Auth": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Admin-Auth': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
apis: [
{api_human_name: 'API 2', api_id: '5fa2db834e07444f760b7ceb314209fb'},
{api_human_name: 'API 1', api_id: '7a6ddeca9244448a4233866938a0d6e2'},
{api_human_name: 'API 3', api_id: '109eacaa50b24b64651a1d4dce8ec385'}
],
cname: 'my.domain.com',
cname_enabled: true,
developer_count: 21,
developer_quota: 123,
event_options: {
key_event: {email: '', redis: true, webhook: ''},
key_request_event: {email: '', redis: false, webhook: ''}
},
hybrid_enabled: false,
id: '53ac07777cbb8c2d53000002',
owner_name: 'Test',
owner_slug: 'test',
ui: {
default_lang: '',
designer: {},
dont_allow_license_management: false,
dont_allow_license_management_view: false,
dont_show_admin_sockets: false,
hide_help: false,
languages: {},
login_page: {},
nav: {},
portal_section: {},
uptime: {}
}
})
};
fetch('https://{tenant}/admin/organisations/import', 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}/admin/organisations/import",
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([
'apis' => [
[
'api_human_name' => 'API 2',
'api_id' => '5fa2db834e07444f760b7ceb314209fb'
],
[
'api_human_name' => 'API 1',
'api_id' => '7a6ddeca9244448a4233866938a0d6e2'
],
[
'api_human_name' => 'API 3',
'api_id' => '109eacaa50b24b64651a1d4dce8ec385'
]
],
'cname' => 'my.domain.com',
'cname_enabled' => true,
'developer_count' => 21,
'developer_quota' => 123,
'event_options' => [
'key_event' => [
'email' => '',
'redis' => true,
'webhook' => ''
],
'key_request_event' => [
'email' => '',
'redis' => false,
'webhook' => ''
]
],
'hybrid_enabled' => false,
'id' => '53ac07777cbb8c2d53000002',
'owner_name' => 'Test',
'owner_slug' => 'test',
'ui' => [
'default_lang' => '',
'designer' => [
],
'dont_allow_license_management' => false,
'dont_allow_license_management_view' => false,
'dont_show_admin_sockets' => false,
'hide_help' => false,
'languages' => [
],
'login_page' => [
],
'nav' => [
],
'portal_section' => [
],
'uptime' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"Admin-Auth: <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://{tenant}/admin/organisations/import"
payload := strings.NewReader("{\n \"apis\": [\n {\n \"api_human_name\": \"API 2\",\n \"api_id\": \"5fa2db834e07444f760b7ceb314209fb\"\n },\n {\n \"api_human_name\": \"API 1\",\n \"api_id\": \"7a6ddeca9244448a4233866938a0d6e2\"\n },\n {\n \"api_human_name\": \"API 3\",\n \"api_id\": \"109eacaa50b24b64651a1d4dce8ec385\"\n }\n ],\n \"cname\": \"my.domain.com\",\n \"cname_enabled\": true,\n \"developer_count\": 21,\n \"developer_quota\": 123,\n \"event_options\": {\n \"key_event\": {\n \"email\": \"\",\n \"redis\": true,\n \"webhook\": \"\"\n },\n \"key_request_event\": {\n \"email\": \"\",\n \"redis\": false,\n \"webhook\": \"\"\n }\n },\n \"hybrid_enabled\": false,\n \"id\": \"53ac07777cbb8c2d53000002\",\n \"owner_name\": \"Test\",\n \"owner_slug\": \"test\",\n \"ui\": {\n \"default_lang\": \"\",\n \"designer\": {},\n \"dont_allow_license_management\": false,\n \"dont_allow_license_management_view\": false,\n \"dont_show_admin_sockets\": false,\n \"hide_help\": false,\n \"languages\": {},\n \"login_page\": {},\n \"nav\": {},\n \"portal_section\": {},\n \"uptime\": {}\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Admin-Auth", "<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://{tenant}/admin/organisations/import")
.header("Admin-Auth", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"apis\": [\n {\n \"api_human_name\": \"API 2\",\n \"api_id\": \"5fa2db834e07444f760b7ceb314209fb\"\n },\n {\n \"api_human_name\": \"API 1\",\n \"api_id\": \"7a6ddeca9244448a4233866938a0d6e2\"\n },\n {\n \"api_human_name\": \"API 3\",\n \"api_id\": \"109eacaa50b24b64651a1d4dce8ec385\"\n }\n ],\n \"cname\": \"my.domain.com\",\n \"cname_enabled\": true,\n \"developer_count\": 21,\n \"developer_quota\": 123,\n \"event_options\": {\n \"key_event\": {\n \"email\": \"\",\n \"redis\": true,\n \"webhook\": \"\"\n },\n \"key_request_event\": {\n \"email\": \"\",\n \"redis\": false,\n \"webhook\": \"\"\n }\n },\n \"hybrid_enabled\": false,\n \"id\": \"53ac07777cbb8c2d53000002\",\n \"owner_name\": \"Test\",\n \"owner_slug\": \"test\",\n \"ui\": {\n \"default_lang\": \"\",\n \"designer\": {},\n \"dont_allow_license_management\": false,\n \"dont_allow_license_management_view\": false,\n \"dont_show_admin_sockets\": false,\n \"hide_help\": false,\n \"languages\": {},\n \"login_page\": {},\n \"nav\": {},\n \"portal_section\": {},\n \"uptime\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/admin/organisations/import")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Admin-Auth"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"apis\": [\n {\n \"api_human_name\": \"API 2\",\n \"api_id\": \"5fa2db834e07444f760b7ceb314209fb\"\n },\n {\n \"api_human_name\": \"API 1\",\n \"api_id\": \"7a6ddeca9244448a4233866938a0d6e2\"\n },\n {\n \"api_human_name\": \"API 3\",\n \"api_id\": \"109eacaa50b24b64651a1d4dce8ec385\"\n }\n ],\n \"cname\": \"my.domain.com\",\n \"cname_enabled\": true,\n \"developer_count\": 21,\n \"developer_quota\": 123,\n \"event_options\": {\n \"key_event\": {\n \"email\": \"\",\n \"redis\": true,\n \"webhook\": \"\"\n },\n \"key_request_event\": {\n \"email\": \"\",\n \"redis\": false,\n \"webhook\": \"\"\n }\n },\n \"hybrid_enabled\": false,\n \"id\": \"53ac07777cbb8c2d53000002\",\n \"owner_name\": \"Test\",\n \"owner_slug\": \"test\",\n \"ui\": {\n \"default_lang\": \"\",\n \"designer\": {},\n \"dont_allow_license_management\": false,\n \"dont_allow_license_management_view\": false,\n \"dont_show_admin_sockets\": false,\n \"hide_help\": false,\n \"languages\": {},\n \"login_page\": {},\n \"nav\": {},\n \"portal_section\": {},\n \"uptime\": {}\n }\n}"
response = http.request(request)
puts response.read_body{
"Message": "Org imported",
"Meta": "53ac07777cbb8c2d53000002",
"Status": "OK"
}{
"Message": "Not authorised",
"Meta": null,
"Status": "Error"
}{
"Message": "Failed to save new Org object to DB",
"Meta": null,
"Status": "Error"
}{
"Message": "Failed to read response body, body empty",
"Meta": null,
"Status": "Error"
}Authorizations
Api key
Body
application/json
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
⌘I