curl --request PUT \
--url https://{tenant}/api/clientidps/{id}/mappings/{apiId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"scope_to_policy": {
"read": "665d51505715ec2d76022c87",
"write": "5e4f2c1a3b6d7e8f9a0b1c2d"
}
}
'import requests
url = "https://{tenant}/api/clientidps/{id}/mappings/{apiId}"
payload = { "scope_to_policy": {
"read": "665d51505715ec2d76022c87",
"write": "5e4f2c1a3b6d7e8f9a0b1c2d"
} }
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({
scope_to_policy: {read: '665d51505715ec2d76022c87', write: '5e4f2c1a3b6d7e8f9a0b1c2d'}
})
};
fetch('https://{tenant}/api/clientidps/{id}/mappings/{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/clientidps/{id}/mappings/{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([
'scope_to_policy' => [
'read' => '665d51505715ec2d76022c87',
'write' => '5e4f2c1a3b6d7e8f9a0b1c2d'
]
]),
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/clientidps/{id}/mappings/{apiId}"
payload := strings.NewReader("{\n \"scope_to_policy\": {\n \"read\": \"665d51505715ec2d76022c87\",\n \"write\": \"5e4f2c1a3b6d7e8f9a0b1c2d\"\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/clientidps/{id}/mappings/{apiId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"scope_to_policy\": {\n \"read\": \"665d51505715ec2d76022c87\",\n \"write\": \"5e4f2c1a3b6d7e8f9a0b1c2d\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/clientidps/{id}/mappings/{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 \"scope_to_policy\": {\n \"read\": \"665d51505715ec2d76022c87\",\n \"write\": \"5e4f2c1a3b6d7e8f9a0b1c2d\"\n }\n}"
response = http.request(request)
puts response.read_body{
"_id": "<string>",
"client_idp_id": "<string>",
"org_id": "<string>",
"name": "<string>",
"issuer": "<string>",
"jwks_uri": "<string>",
"scope_claim_name": "<string>",
"api_mappings": {
"b84fe1a04e5648927971c0557971565c": {
"scope_to_policy": {
"read": "665d51505715ec2d76022c87"
}
}
},
"date_created": "2023-11-07T05:31:56Z",
"last_updated": "2023-11-07T05:31:56Z"
}Upsert an API mapping.
Creates or replaces the scope mapping for the given API within the client IdP.
curl --request PUT \
--url https://{tenant}/api/clientidps/{id}/mappings/{apiId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"scope_to_policy": {
"read": "665d51505715ec2d76022c87",
"write": "5e4f2c1a3b6d7e8f9a0b1c2d"
}
}
'import requests
url = "https://{tenant}/api/clientidps/{id}/mappings/{apiId}"
payload = { "scope_to_policy": {
"read": "665d51505715ec2d76022c87",
"write": "5e4f2c1a3b6d7e8f9a0b1c2d"
} }
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({
scope_to_policy: {read: '665d51505715ec2d76022c87', write: '5e4f2c1a3b6d7e8f9a0b1c2d'}
})
};
fetch('https://{tenant}/api/clientidps/{id}/mappings/{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/clientidps/{id}/mappings/{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([
'scope_to_policy' => [
'read' => '665d51505715ec2d76022c87',
'write' => '5e4f2c1a3b6d7e8f9a0b1c2d'
]
]),
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/clientidps/{id}/mappings/{apiId}"
payload := strings.NewReader("{\n \"scope_to_policy\": {\n \"read\": \"665d51505715ec2d76022c87\",\n \"write\": \"5e4f2c1a3b6d7e8f9a0b1c2d\"\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/clientidps/{id}/mappings/{apiId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"scope_to_policy\": {\n \"read\": \"665d51505715ec2d76022c87\",\n \"write\": \"5e4f2c1a3b6d7e8f9a0b1c2d\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/clientidps/{id}/mappings/{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 \"scope_to_policy\": {\n \"read\": \"665d51505715ec2d76022c87\",\n \"write\": \"5e4f2c1a3b6d7e8f9a0b1c2d\"\n }\n}"
response = http.request(request)
puts response.read_body{
"_id": "<string>",
"client_idp_id": "<string>",
"org_id": "<string>",
"name": "<string>",
"issuer": "<string>",
"jwks_uri": "<string>",
"scope_claim_name": "<string>",
"api_mappings": {
"b84fe1a04e5648927971c0557971565c": {
"scope_to_policy": {
"read": "665d51505715ec2d76022c87"
}
}
},
"date_created": "2023-11-07T05:31:56Z",
"last_updated": "2023-11-07T05:31:56Z"
}Authorizations
The Tyk Dashboard API Access Credentials
Path Parameters
Internal record ID hex or custom client_idp_id.
The API id to upsert.
Body
Scope-to-policy mapping for a single API.
Map of scope name → policy ID.
Show child attributes
Show child attributes
{
"read": "665d51505715ec2d76022c87",
"write": "5e4f2c1a3b6d7e8f9a0b1c2d"
}
Response
Mapping upserted. Returns the full updated client IdP document.
A client Identity Provider stored beside API definitions.
Internal record ID hex. Set server-side on creation.
Stable user-facing identifier. Defaults to _id hex when not supplied on create.
Organisation ID. Set server-side from the session; cannot be overridden.
JWT claim holding the OAuth scopes (e.g. scope, scp, roles). Empty falls back to scope gateway-side.
Map of api_id → ScopeMapping.
Show child attributes
Show child attributes
{
"b84fe1a04e5648927971c0557971565c": {
"scope_to_policy": { "read": "665d51505715ec2d76022c87" }
}
}
Was this page helpful?