curl --request PUT \
--url https://api-dev.narrative.io/access-tokens/tokens/{access_token_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"summary": "Rename only",
"value": {
"name": "My Token"
}
}
'import requests
url = "https://api-dev.narrative.io/access-tokens/tokens/{access_token_id}"
payload = {
"summary": "Rename only",
"value": { "name": "My Token" }
}
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({summary: 'Rename only', value: {name: 'My Token'}})
};
fetch('https://api-dev.narrative.io/access-tokens/tokens/{access_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-dev.narrative.io/access-tokens/tokens/{access_token_id}",
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([
'summary' => 'Rename only',
'value' => [
'name' => 'My Token'
]
]),
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-dev.narrative.io/access-tokens/tokens/{access_token_id}"
payload := strings.NewReader("{\n \"summary\": \"Rename only\",\n \"value\": {\n \"name\": \"My Token\"\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://api-dev.narrative.io/access-tokens/tokens/{access_token_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"summary\": \"Rename only\",\n \"value\": {\n \"name\": \"My Token\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/access-tokens/tokens/{access_token_id}")
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 \"summary\": \"Rename only\",\n \"value\": {\n \"name\": \"My Token\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "546c65d6-e589-4d3c-b1fe-7e61711cc418",
"name": "My Token",
"permissions": [
{
"access": "read",
"resource": "datasets"
},
{
"access": "write",
"resource": "datasets"
},
{
"access": "read",
"resource": "subscriptions"
},
{
"access": "write",
"resource": "subscriptions"
}
],
"expires_at": "2023-10-31T11:19:13.400498Z"
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Update a System Access Token
Change a System Access Token’s name, permissions or expiry. Fields you omit are left alone, but the body must carry at least one of them.
Updating does not reissue the credential — the existing access_token keeps working with the new permissions
and expiry, and is not returned here.
Requires write access to access_tokens.
curl --request PUT \
--url https://api-dev.narrative.io/access-tokens/tokens/{access_token_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"summary": "Rename only",
"value": {
"name": "My Token"
}
}
'import requests
url = "https://api-dev.narrative.io/access-tokens/tokens/{access_token_id}"
payload = {
"summary": "Rename only",
"value": { "name": "My Token" }
}
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({summary: 'Rename only', value: {name: 'My Token'}})
};
fetch('https://api-dev.narrative.io/access-tokens/tokens/{access_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-dev.narrative.io/access-tokens/tokens/{access_token_id}",
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([
'summary' => 'Rename only',
'value' => [
'name' => 'My Token'
]
]),
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-dev.narrative.io/access-tokens/tokens/{access_token_id}"
payload := strings.NewReader("{\n \"summary\": \"Rename only\",\n \"value\": {\n \"name\": \"My Token\"\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://api-dev.narrative.io/access-tokens/tokens/{access_token_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"summary\": \"Rename only\",\n \"value\": {\n \"name\": \"My Token\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/access-tokens/tokens/{access_token_id}")
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 \"summary\": \"Rename only\",\n \"value\": {\n \"name\": \"My Token\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "546c65d6-e589-4d3c-b1fe-7e61711cc418",
"name": "My Token",
"permissions": [
{
"access": "read",
"resource": "datasets"
},
{
"access": "write",
"resource": "datasets"
},
{
"access": "read",
"resource": "subscriptions"
},
{
"access": "write",
"resource": "subscriptions"
}
],
"expires_at": "2023-10-31T11:19:13.400498Z"
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The token's id. Anything that is not a UUID does not match the route and returns 404.
Body
Every field is optional, but at least one must be present — an empty body is a 400. Fields you omit are left alone.
The new name of the token.
1 - 256The permissions to grant, replacing the current set.
Show child attributes
Show child attributes
When the token should expire. Accepts either an RFC 3339 timestamp or a bare YYYY-MM-DD date, which is read
as midnight UTC.
The gap between now and this value must be at least 1 and at most 365 whole days — a value less than 24 hours out rounds down to 0 days and is rejected. Omit it to get the maximum, 365 days.
^\d{4}-\d{2}-\d{2}T"2023-10-31T11:19:13.400498Z"
Response
OK
Everything about a System Access Token except the credential itself. The credential is returned once, by
POST /access-tokens/tokens, and never again.
The id of the token.
The name of the token.
The permissions granted to the token.
Show child attributes
Show child attributes
When the token expires, RFC 3339. Expiry is stored with day granularity, so this is the requested expiry rounded down to a whole number of days from when the token was created — ask for 36 hours and you get 24.
"2023-10-31T11:19:13.400498Z"
Was this page helpful?

