Update Api Token Scopes By Id
curl --request PATCH \
--url https://api.deepinfra.com/v1/api-tokens/id/{token_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"scopes": []
}'import requests
url = "https://api.deepinfra.com/v1/api-tokens/id/{token_id}"
payload = { "scopes": [] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({scopes: []})
};
fetch('https://api.deepinfra.com/v1/api-tokens/id/{token_id}', 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://api.deepinfra.com/v1/api-tokens/id/{token_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'scopes' => [
]
]),
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://api.deepinfra.com/v1/api-tokens/id/{token_id}"
payload := strings.NewReader("{\n \"scopes\": []\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.deepinfra.com/v1/api-tokens/id/{token_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"scopes\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/v1/api-tokens/id/{token_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"scopes\": []\n}"
response = http.request(request)
puts response.read_body{
"created_at": 123,
"name": "<string>",
"token_id": "<string>",
"allowed_ips": [
"<string>"
],
"prefix": "",
"fragment": "",
"scopes": []
}{
"error": "Model not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authentication
Update Api Token Scopes By Id
Replace an API token’s scopes, by token_id.
token_id comes from Get Api Tokens (GET /v1/api-tokens). An API key calling this cannot grant a sensitive scope
the token does not already hold.
PATCH
/
v1
/
api-tokens
/
id
/
{token_id}
Update Api Token Scopes By Id
curl --request PATCH \
--url https://api.deepinfra.com/v1/api-tokens/id/{token_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"scopes": []
}'import requests
url = "https://api.deepinfra.com/v1/api-tokens/id/{token_id}"
payload = { "scopes": [] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({scopes: []})
};
fetch('https://api.deepinfra.com/v1/api-tokens/id/{token_id}', 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://api.deepinfra.com/v1/api-tokens/id/{token_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'scopes' => [
]
]),
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://api.deepinfra.com/v1/api-tokens/id/{token_id}"
payload := strings.NewReader("{\n \"scopes\": []\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.deepinfra.com/v1/api-tokens/id/{token_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"scopes\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/v1/api-tokens/id/{token_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"scopes\": []\n}"
response = http.request(request)
puts response.read_body{
"created_at": 123,
"name": "<string>",
"token_id": "<string>",
"allowed_ips": [
"<string>"
],
"prefix": "",
"fragment": "",
"scopes": []
}{
"error": "Model not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}When called with an API key, the key needs the
account_api_key scope (about scopes).account_api_key is sensitive: a key can be given it only once the account owner has enabled it. To enable it, sign in to the dashboard as the account owner, open Account → Danger zone and tick Allow API keys to manage API keys, then give it to a key from the dashboard. No API key can enable it or give it to a key: an API key that sets it is refused with 422 (an API key cannot grant scope: account_api_key), whether or not it is enabled.Authorizations
Body
application/json
what the key may do: at least one scope, or unrestricted alone for every non-sensitive scope
What an API key may do. A scope x also grants x:read; unrestricted grants every non-sensitive scope.
Available options:
inference, models:read, account:read, models, lora:read, lora, voice:read, voice, account_scoped_jwt:read, account_scoped_jwt, batch, compute:sandbox, compute:agents, compute:containers, billing:read, metrics, account_api_key:read, account_api_key, unrestricted Response
Successful Response
what the key may do
What an API key may do. A scope x also grants x:read; unrestricted grants every non-sensitive scope.
Available options:
inference, models:read, account:read, models, lora:read, lora, voice:read, voice, account_scoped_jwt:read, account_scoped_jwt, batch, compute:sandbox, compute:agents, compute:containers, billing:read, metrics, account_api_key:read, account_api_key, unrestricted