Proxy API request
curl --request POST \
--url https://{tenant}/api/proxy \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"method": "GET",
"url": "http://localhost:8181/test-oas/get",
"headers": {
"test": "tyk",
"Content-Type": "application/json"
},
"body": {
"name": "New Resource",
"description": "Description of the resource."
}
}
'import requests
url = "https://{tenant}/api/proxy"
payload = {
"method": "GET",
"url": "http://localhost:8181/test-oas/get",
"headers": {
"test": "tyk",
"Content-Type": "application/json"
},
"body": {
"name": "New Resource",
"description": "Description of the resource."
}
}
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({
method: 'GET',
url: 'http://localhost:8181/test-oas/get',
headers: {test: 'tyk', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'New Resource', description: 'Description of the resource.'})
})
};
fetch('https://{tenant}/api/proxy', 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/proxy",
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([
'method' => 'GET',
'url' => 'http://localhost:8181/test-oas/get',
'headers' => [
'test' => 'tyk',
'Content-Type' => 'application/json'
],
'body' => [
'name' => 'New Resource',
'description' => 'Description of the resource.'
]
]),
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/proxy"
payload := strings.NewReader("{\n \"method\": \"GET\",\n \"url\": \"http://localhost:8181/test-oas/get\",\n \"headers\": {\n \"test\": \"tyk\",\n \"Content-Type\": \"application/json\"\n },\n \"body\": {\n \"name\": \"New Resource\",\n \"description\": \"Description of the resource.\"\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/proxy")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"method\": \"GET\",\n \"url\": \"http://localhost:8181/test-oas/get\",\n \"headers\": {\n \"test\": \"tyk\",\n \"Content-Type\": \"application/json\"\n },\n \"body\": {\n \"name\": \"New Resource\",\n \"description\": \"Description of the resource.\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/proxy")
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 \"method\": \"GET\",\n \"url\": \"http://localhost:8181/test-oas/get\",\n \"headers\": {\n \"test\": \"tyk\",\n \"Content-Type\": \"application/json\"\n },\n \"body\": {\n \"name\": \"New Resource\",\n \"description\": \"Description of the resource.\"\n }\n}"
response = http.request(request)
puts response.read_body{
"status_code": 200,
"headers": {
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
"Content-Length": "364",
"Content-Type": "application/json",
"Date": "Thu, 19 Dec 2024 14:10:48 GMT",
"Server": "gunicorn/19.9.0",
"X-Ratelimit-Limit": "0",
"X-Ratelimit-Remaining": "0",
"X-Ratelimit-Reset": "0"
},
"body": {
"args": {},
"headers": {
"Accept-Encoding": "gzip",
"Content-Length": "83",
"Content-Type": "application/json",
"Host": "httpbin.org",
"Test": "tyk",
"User-Agent": "Go-http-client/1.1",
"X-Amzn-Trace-Id": "Root=1-67642968-11206636527acf9a25d230c3"
},
"origin": "::1, 81.18.84.15",
"url": "http://httpbin.org/get"
}
}{
"Status": "Error",
"Message": "Invalid proxy request",
"Meta": null
}{
"Status": "Error",
"Message": "Provided URL is not a recognised gateway URL",
"Meta": null
}{
"Status": "Error",
"Message": "Failed to process proxy request",
"Meta": null
}Proxy
Proxy API request
Forwards a request to a specified gateway endpoint. This endpoint allows you to send requests to other services through the Tyk gateway, which can be useful for testing or accessing protected resources.
The proxy will forward your request to the specified URL, including any headers and body data you provide. It then returns the response from the target service, including status code, headers, and body.
POST
/
api
/
proxy
Proxy API request
curl --request POST \
--url https://{tenant}/api/proxy \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"method": "GET",
"url": "http://localhost:8181/test-oas/get",
"headers": {
"test": "tyk",
"Content-Type": "application/json"
},
"body": {
"name": "New Resource",
"description": "Description of the resource."
}
}
'import requests
url = "https://{tenant}/api/proxy"
payload = {
"method": "GET",
"url": "http://localhost:8181/test-oas/get",
"headers": {
"test": "tyk",
"Content-Type": "application/json"
},
"body": {
"name": "New Resource",
"description": "Description of the resource."
}
}
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({
method: 'GET',
url: 'http://localhost:8181/test-oas/get',
headers: {test: 'tyk', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'New Resource', description: 'Description of the resource.'})
})
};
fetch('https://{tenant}/api/proxy', 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/proxy",
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([
'method' => 'GET',
'url' => 'http://localhost:8181/test-oas/get',
'headers' => [
'test' => 'tyk',
'Content-Type' => 'application/json'
],
'body' => [
'name' => 'New Resource',
'description' => 'Description of the resource.'
]
]),
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/proxy"
payload := strings.NewReader("{\n \"method\": \"GET\",\n \"url\": \"http://localhost:8181/test-oas/get\",\n \"headers\": {\n \"test\": \"tyk\",\n \"Content-Type\": \"application/json\"\n },\n \"body\": {\n \"name\": \"New Resource\",\n \"description\": \"Description of the resource.\"\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/proxy")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"method\": \"GET\",\n \"url\": \"http://localhost:8181/test-oas/get\",\n \"headers\": {\n \"test\": \"tyk\",\n \"Content-Type\": \"application/json\"\n },\n \"body\": {\n \"name\": \"New Resource\",\n \"description\": \"Description of the resource.\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/proxy")
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 \"method\": \"GET\",\n \"url\": \"http://localhost:8181/test-oas/get\",\n \"headers\": {\n \"test\": \"tyk\",\n \"Content-Type\": \"application/json\"\n },\n \"body\": {\n \"name\": \"New Resource\",\n \"description\": \"Description of the resource.\"\n }\n}"
response = http.request(request)
puts response.read_body{
"status_code": 200,
"headers": {
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
"Content-Length": "364",
"Content-Type": "application/json",
"Date": "Thu, 19 Dec 2024 14:10:48 GMT",
"Server": "gunicorn/19.9.0",
"X-Ratelimit-Limit": "0",
"X-Ratelimit-Remaining": "0",
"X-Ratelimit-Reset": "0"
},
"body": {
"args": {},
"headers": {
"Accept-Encoding": "gzip",
"Content-Length": "83",
"Content-Type": "application/json",
"Host": "httpbin.org",
"Test": "tyk",
"User-Agent": "Go-http-client/1.1",
"X-Amzn-Trace-Id": "Root=1-67642968-11206636527acf9a25d230c3"
},
"origin": "::1, 81.18.84.15",
"url": "http://httpbin.org/get"
}
}{
"Status": "Error",
"Message": "Invalid proxy request",
"Meta": null
}{
"Status": "Error",
"Message": "Provided URL is not a recognised gateway URL",
"Meta": null
}{
"Status": "Error",
"Message": "Failed to process proxy request",
"Meta": null
}Authorizations
The Tyk Dashboard API Access Credentials
Body
application/json
HTTP method for the proxy request (GET, POST, PUT, DELETE, etc.)
Full URL for the proxy request (valid Gateway url), including scheme, host, and path
Headers to be sent with the proxy request
Show child attributes
Show child attributes
Body of the proxy request, typically used for POST or PUT requests
Was this page helpful?
⌘I