Update API Definition
curl --request PUT \
--url https://{tenant}/api/apis/{apiId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"api_definition": {
"api_id": "b84fe1a04e5648927971c0557971565c",
"auth": {
"auth_header_name": "authorization"
},
"definition": {
"key": "version",
"location": "header"
},
"name": "Update API name",
"org_id": "664a14650619d40001f1f00f",
"proxy": {
"listen_path": "/updated-tyk-api-test/",
"strip_listen_path": true,
"target_url": "https://httpbin.org"
},
"use_oauth2": true,
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default"
}
}
}
}
}
'import requests
url = "https://{tenant}/api/apis/{apiId}"
payload = { "api_definition": {
"api_id": "b84fe1a04e5648927971c0557971565c",
"auth": { "auth_header_name": "authorization" },
"definition": {
"key": "version",
"location": "header"
},
"name": "Update API name",
"org_id": "664a14650619d40001f1f00f",
"proxy": {
"listen_path": "/updated-tyk-api-test/",
"strip_listen_path": True,
"target_url": "https://httpbin.org"
},
"use_oauth2": True,
"version_data": {
"not_versioned": True,
"versions": { "Default": { "name": "Default" } }
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
api_definition: {
api_id: 'b84fe1a04e5648927971c0557971565c',
auth: {auth_header_name: 'authorization'},
definition: {key: 'version', location: 'header'},
name: 'Update API name',
org_id: '664a14650619d40001f1f00f',
proxy: {
listen_path: '/updated-tyk-api-test/',
strip_listen_path: true,
target_url: 'https://httpbin.org'
},
use_oauth2: true,
version_data: {not_versioned: true, versions: {Default: {name: 'Default'}}}
}
})
};
fetch('https://{tenant}/api/apis/{apiId}', 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/apis/{apiId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'api_definition' => [
'api_id' => 'b84fe1a04e5648927971c0557971565c',
'auth' => [
'auth_header_name' => 'authorization'
],
'definition' => [
'key' => 'version',
'location' => 'header'
],
'name' => 'Update API name',
'org_id' => '664a14650619d40001f1f00f',
'proxy' => [
'listen_path' => '/updated-tyk-api-test/',
'strip_listen_path' => true,
'target_url' => 'https://httpbin.org'
],
'use_oauth2' => true,
'version_data' => [
'not_versioned' => true,
'versions' => [
'Default' => [
'name' => 'Default'
]
]
]
]
]),
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/apis/{apiId}"
payload := strings.NewReader("{\n \"api_definition\": {\n \"api_id\": \"b84fe1a04e5648927971c0557971565c\",\n \"auth\": {\n \"auth_header_name\": \"authorization\"\n },\n \"definition\": {\n \"key\": \"version\",\n \"location\": \"header\"\n },\n \"name\": \"Update API name\",\n \"org_id\": \"664a14650619d40001f1f00f\",\n \"proxy\": {\n \"listen_path\": \"/updated-tyk-api-test/\",\n \"strip_listen_path\": true,\n \"target_url\": \"https://httpbin.org\"\n },\n \"use_oauth2\": true,\n \"version_data\": {\n \"not_versioned\": true,\n \"versions\": {\n \"Default\": {\n \"name\": \"Default\"\n }\n }\n }\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://{tenant}/api/apis/{apiId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"api_definition\": {\n \"api_id\": \"b84fe1a04e5648927971c0557971565c\",\n \"auth\": {\n \"auth_header_name\": \"authorization\"\n },\n \"definition\": {\n \"key\": \"version\",\n \"location\": \"header\"\n },\n \"name\": \"Update API name\",\n \"org_id\": \"664a14650619d40001f1f00f\",\n \"proxy\": {\n \"listen_path\": \"/updated-tyk-api-test/\",\n \"strip_listen_path\": true,\n \"target_url\": \"https://httpbin.org\"\n },\n \"use_oauth2\": true,\n \"version_data\": {\n \"not_versioned\": true,\n \"versions\": {\n \"Default\": {\n \"name\": \"Default\"\n }\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/apis/{apiId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"api_definition\": {\n \"api_id\": \"b84fe1a04e5648927971c0557971565c\",\n \"auth\": {\n \"auth_header_name\": \"authorization\"\n },\n \"definition\": {\n \"key\": \"version\",\n \"location\": \"header\"\n },\n \"name\": \"Update API name\",\n \"org_id\": \"664a14650619d40001f1f00f\",\n \"proxy\": {\n \"listen_path\": \"/updated-tyk-api-test/\",\n \"strip_listen_path\": true,\n \"target_url\": \"https://httpbin.org\"\n },\n \"use_oauth2\": true,\n \"version_data\": {\n \"not_versioned\": true,\n \"versions\": {\n \"Default\": {\n \"name\": \"Default\"\n }\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"Message": "API updated",
"Meta": null,
"Status": "OK"
}{
"Message": "Invalid `ID` value",
"Meta": null,
"Status": "Error"
}{
"Message": "Not authorised",
"Meta": null,
"Status": "Error"
}{
"Message": "access denied: You do not have permission to access /api/apis/{apiId}",
"Meta": null,
"Status": "Error"
}{
"Message": "API definition does not exist",
"Meta": null,
"Status": "Error"
}{
"Message": "Error while validating schema",
"Meta": null,
"Status": "Error"
}APIs
Update API Definition
Update an API Definition. api_id can be updated for On-Premise installations, but it cannot be updated when the Dashboard resides in Tyk Cloud. Updates to api_id in Tyk Cloud will be ignored.
PUT
/
api
/
apis
/
{apiId}
Update API Definition
curl --request PUT \
--url https://{tenant}/api/apis/{apiId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"api_definition": {
"api_id": "b84fe1a04e5648927971c0557971565c",
"auth": {
"auth_header_name": "authorization"
},
"definition": {
"key": "version",
"location": "header"
},
"name": "Update API name",
"org_id": "664a14650619d40001f1f00f",
"proxy": {
"listen_path": "/updated-tyk-api-test/",
"strip_listen_path": true,
"target_url": "https://httpbin.org"
},
"use_oauth2": true,
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default"
}
}
}
}
}
'import requests
url = "https://{tenant}/api/apis/{apiId}"
payload = { "api_definition": {
"api_id": "b84fe1a04e5648927971c0557971565c",
"auth": { "auth_header_name": "authorization" },
"definition": {
"key": "version",
"location": "header"
},
"name": "Update API name",
"org_id": "664a14650619d40001f1f00f",
"proxy": {
"listen_path": "/updated-tyk-api-test/",
"strip_listen_path": True,
"target_url": "https://httpbin.org"
},
"use_oauth2": True,
"version_data": {
"not_versioned": True,
"versions": { "Default": { "name": "Default" } }
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
api_definition: {
api_id: 'b84fe1a04e5648927971c0557971565c',
auth: {auth_header_name: 'authorization'},
definition: {key: 'version', location: 'header'},
name: 'Update API name',
org_id: '664a14650619d40001f1f00f',
proxy: {
listen_path: '/updated-tyk-api-test/',
strip_listen_path: true,
target_url: 'https://httpbin.org'
},
use_oauth2: true,
version_data: {not_versioned: true, versions: {Default: {name: 'Default'}}}
}
})
};
fetch('https://{tenant}/api/apis/{apiId}', 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/apis/{apiId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'api_definition' => [
'api_id' => 'b84fe1a04e5648927971c0557971565c',
'auth' => [
'auth_header_name' => 'authorization'
],
'definition' => [
'key' => 'version',
'location' => 'header'
],
'name' => 'Update API name',
'org_id' => '664a14650619d40001f1f00f',
'proxy' => [
'listen_path' => '/updated-tyk-api-test/',
'strip_listen_path' => true,
'target_url' => 'https://httpbin.org'
],
'use_oauth2' => true,
'version_data' => [
'not_versioned' => true,
'versions' => [
'Default' => [
'name' => 'Default'
]
]
]
]
]),
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/apis/{apiId}"
payload := strings.NewReader("{\n \"api_definition\": {\n \"api_id\": \"b84fe1a04e5648927971c0557971565c\",\n \"auth\": {\n \"auth_header_name\": \"authorization\"\n },\n \"definition\": {\n \"key\": \"version\",\n \"location\": \"header\"\n },\n \"name\": \"Update API name\",\n \"org_id\": \"664a14650619d40001f1f00f\",\n \"proxy\": {\n \"listen_path\": \"/updated-tyk-api-test/\",\n \"strip_listen_path\": true,\n \"target_url\": \"https://httpbin.org\"\n },\n \"use_oauth2\": true,\n \"version_data\": {\n \"not_versioned\": true,\n \"versions\": {\n \"Default\": {\n \"name\": \"Default\"\n }\n }\n }\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://{tenant}/api/apis/{apiId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"api_definition\": {\n \"api_id\": \"b84fe1a04e5648927971c0557971565c\",\n \"auth\": {\n \"auth_header_name\": \"authorization\"\n },\n \"definition\": {\n \"key\": \"version\",\n \"location\": \"header\"\n },\n \"name\": \"Update API name\",\n \"org_id\": \"664a14650619d40001f1f00f\",\n \"proxy\": {\n \"listen_path\": \"/updated-tyk-api-test/\",\n \"strip_listen_path\": true,\n \"target_url\": \"https://httpbin.org\"\n },\n \"use_oauth2\": true,\n \"version_data\": {\n \"not_versioned\": true,\n \"versions\": {\n \"Default\": {\n \"name\": \"Default\"\n }\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/apis/{apiId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"api_definition\": {\n \"api_id\": \"b84fe1a04e5648927971c0557971565c\",\n \"auth\": {\n \"auth_header_name\": \"authorization\"\n },\n \"definition\": {\n \"key\": \"version\",\n \"location\": \"header\"\n },\n \"name\": \"Update API name\",\n \"org_id\": \"664a14650619d40001f1f00f\",\n \"proxy\": {\n \"listen_path\": \"/updated-tyk-api-test/\",\n \"strip_listen_path\": true,\n \"target_url\": \"https://httpbin.org\"\n },\n \"use_oauth2\": true,\n \"version_data\": {\n \"not_versioned\": true,\n \"versions\": {\n \"Default\": {\n \"name\": \"Default\"\n }\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"Message": "API updated",
"Meta": null,
"Status": "OK"
}{
"Message": "Invalid `ID` value",
"Meta": null,
"Status": "Error"
}{
"Message": "Not authorised",
"Meta": null,
"Status": "Error"
}{
"Message": "access denied: You do not have permission to access /api/apis/{apiId}",
"Meta": null,
"Status": "Error"
}{
"Message": "API definition does not exist",
"Meta": null,
"Status": "Error"
}{
"Message": "Error while validating schema",
"Meta": null,
"Status": "Error"
}Authorizations
The Tyk Dashboard API Access Credentials
Path Parameters
ID of API to get. Can either be internal or public API ID.
Body
application/json
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
⌘I