Skip to main content
PATCH
/
source-creator
/
sessions
/
{id}
/
header-rows
Re-parse the session's file with a different header-row count
curl --request PATCH \
  --url https://api.royalti.io/source-creator/sessions/{id}/header-rows \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "headerRows": 2
}
'
import requests

url = "https://api.royalti.io/source-creator/sessions/{id}/header-rows"

payload = { "headerRows": 2 }
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({headerRows: 2})
};

fetch('https://api.royalti.io/source-creator/sessions/{id}/header-rows', 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/source-creator/sessions/{id}/header-rows",
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([
'headerRows' => 2
]),
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/source-creator/sessions/{id}/header-rows"

payload := strings.NewReader("{\n \"headerRows\": 2\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/source-creator/sessions/{id}/header-rows")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"headerRows\": 2\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.royalti.io/source-creator/sessions/{id}/header-rows")

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 \"headerRows\": 2\n}"

response = http.request(request)
puts response.read_body
{
  "status": "success",
  "message": "Header row updated; file re-parsed",
  "data": {
    "sessionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "headers": [
      "<string>"
    ],
    "sampleRows": [
      {}
    ],
    "fileInfo": {
      "delimiter": ",",
      "decimalSeparator": "<string>",
      "headerRows": 123,
      "totalRows": 123,
      "sheets": [
        "<string>"
      ],
      "selectedSheet": "<string>",
      "detectedEncoding": "<string>"
    },
    "existingMatch": {
      "sourceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "sourceName": "<string>",
      "confidence": 123
    },
    "matchingSources": [
      {
        "royaltySourceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "sourceName": "<string>",
        "sourceLabel": "<string>",
        "matchScore": 123,
        "matchedColumns": [
          "<string>"
        ],
        "unmatchedColumns": [
          "<string>"
        ],
        "isOwnSource": true
      }
    ],
    "suggestedName": "<string>",
    "periodDetection": {
      "accountingPeriod": {
        "value": "2025-01",
        "format": "YYYY-MM",
        "rawMatch": "Jan2025",
        "confidence": 0.9
      },
      "salePeriod": {
        "value": "2025-01",
        "format": "YYYY-MM",
        "rawMatch": "Jan2025",
        "confidence": 0.9
      },
      "hasDateColumns": true,
      "dateColumnNames": [
        "<string>"
      ]
    },
    "parentSourceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  }
}
{
"status": "error",
"message": "<string>"
}
{
"status": "error",
"message": "This feature requires a plan upgrade",
"data": {
"feature": "royaltyAccess",
"currentPlan": "FREE",
"availablePlans": [
{}
]
}
}
{
"status": "error",
"message": "<string>"
}
This endpoint requires authentication. Include your Bearer token in the Authorization header.

Description

PATCH /source-creator/sessions//header-rows Description: Re-downloads the session’s original file bytes (from the linked FileDetectionSession’s GCS path) and re-parses using a new headerRows value — useful for prelude-shaped files (e.g. merlin_pandora, merlin_spotify) where the real data header sits below a metadata banner. Re-runs source matching and period detection against the new headers and clears any prior AI-suggested / user-confirmed mappings (column identity changed). Only supported for sessions created via the file-detection flow (FileDetectionSessionId set) and only for CSV/TSV — not Excel, and not sessions uploaded directly via /analyze without a linked detection session. Authorization:
  • Requires royaltyAccess subscription feature
Method: PATCH

Code Examples

const response = await fetch('https://api.royalti.io/source-creator/sessions/example-id/header-rows', {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "headerRows": 1
  })
});

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

response = requests.patch(
  'https://api.royalti.io/source-creator/sessions/example-id/header-rows',
  headers={
    'Authorization': f'Bearer {token}'
  },
  json={"headerRows":1}
)

data = response.json()
print(data)
curl -X PATCH https://api.royalti.io/source-creator/sessions/example-id/header-rows \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"headerRows":1}'

Authorizations

Authorization
string
header
required

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

Path Parameters

id
string<uuid>
required

Session ID

Body

application/json
headerRows
integer
required
Required range: x >= 1

Response

Header row updated; file re-parsed

status
string
Example:

"success"

message
string
Example:

"Header row updated; file re-parsed"

data
object