Skip to main content
PATCH
/
royalty
/
saved-views
/
reorder
Reorder the caller's saved analytics views
curl --request PATCH \
  --url https://api.royalti.io/royalty/saved-views/reorder \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "order": [
    "b3f2c1a4-1234-4abc-9def-1234567890ab",
    "c4a3d2b5-2345-4bcd-8ef0-234567890abc"
  ]
}
'
import requests

url = "https://api.royalti.io/royalty/saved-views/reorder"

payload = { "order": ["b3f2c1a4-1234-4abc-9def-1234567890ab", "c4a3d2b5-2345-4bcd-8ef0-234567890abc"] }
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({
    order: ['b3f2c1a4-1234-4abc-9def-1234567890ab', 'c4a3d2b5-2345-4bcd-8ef0-234567890abc']
  })
};

fetch('https://api.royalti.io/royalty/saved-views/reorder', 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.royalti.io/royalty/saved-views/reorder",
  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([
    'order' => [
        'b3f2c1a4-1234-4abc-9def-1234567890ab',
        'c4a3d2b5-2345-4bcd-8ef0-234567890abc'
    ]
  ]),
  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.royalti.io/royalty/saved-views/reorder"

	payload := strings.NewReader("{\n  \"order\": [\n    \"b3f2c1a4-1234-4abc-9def-1234567890ab\",\n    \"c4a3d2b5-2345-4bcd-8ef0-234567890abc\"\n  ]\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.royalti.io/royalty/saved-views/reorder")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"order\": [\n    \"b3f2c1a4-1234-4abc-9def-1234567890ab\",\n    \"c4a3d2b5-2345-4bcd-8ef0-234567890abc\"\n  ]\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.royalti.io/royalty/saved-views/reorder")

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  \"order\": [\n    \"b3f2c1a4-1234-4abc-9def-1234567890ab\",\n    \"c4a3d2b5-2345-4bcd-8ef0-234567890abc\"\n  ]\n}"

response = http.request(request)
puts response.read_body
{
  "status": "success",
  "SavedViews": [
    {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "name": "<string>",
      "config": {},
      "isDefault": true,
      "sortOrder": 123,
      "createdAt": "2023-11-07T05:31:56Z",
      "updatedAt": "2023-11-07T05:31:56Z"
    }
  ],
  "totalItems": 123,
  "totalPages": 1,
  "currentPage": 1
}
{
  "status": "<string>",
  "message": "<string>"
}
{
  "status": "error",
  "message": "One or more saved views not found"
}
{
  "success": false,
  "error": {
    "code": "<string>",
    "message": "<string>",
    "details": [
      "<string>"
    ]
  }
}
This endpoint requires authentication. Include your Bearer token in the Authorization header.

Description

Reorder the caller’s saved analytics views Takes the full ordered list of the caller’s view IDs; the server writes sortOrder as each ID’s array index. Returns the re-ordered list so the client can reconcile without a refetch. Authorization:
  • Required role: user or higher

Code Examples

const response = await fetch('https://api.royalti.io/royalty/saved-views/reorder', {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "order": [
      {}
    ]
  })
});

const data = await response.json();
console.log(data);
import requests

response = requests.patch(
  'https://api.royalti.io/royalty/saved-views/reorder',
  headers={
    'Authorization': f'Bearer {token}'
  },
  json={"order":[{}]}
)

data = response.json()
print(data)
curl -X PATCH https://api.royalti.io/royalty/saved-views/reorder \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"order":[{}]}'

Authorizations

Authorization
string
header
required

JWT Authorization header using the Bearer scheme. Format: "Bearer {token}"

Body

application/json
order
string<uuid>[]
required
Minimum array length: 1

Response

Views reordered

status
string
Example:

"success"

SavedViews
object[]
totalItems
integer
totalPages
integer
Example:

1

currentPage
integer
Example:

1