Skip to main content
POST
/
sources
/
admin
Create Royalty Source (Admin)
curl --request POST \
  --url https://api.royalti.io/sources/admin \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Spotify",
  "label": "Spotify",
  "type": "DSP",
  "format": "csv",
  "public": true,
  "isActive": true,
  "startDate": "2020-01-01",
  "endDate": "2025-01-01",
  "dataQuery": {
    "type": "bigquery",
    "dataset": "royalty_data"
  },
  "fileNameFormat": "royalty_{date}.csv",
  "schema": "artist_name,track_name,streams,revenue",
  "delimiter": ",",
  "tableNameFormat": "royalty_{tenant}",
  "headerRows": 1
}
'
{
  "id": "src-3",
  "name": "Spotify",
  "label": "Spotify",
  "type": "DSP",
  "format": "csv",
  "public": true
}
This endpoint requires authentication. Include your Bearer token in the Authorization header.

Code Examples

const response = await fetch('https://api.royalti.io/sources/admin', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "name": "Spotify",
    "label": "Spotify",
    "type": "DSP",
    "format": "csv",
    "public": true,
    "isActive": true,
    "startDate": "2020-01-01",
    "endDate": "2025-01-01",
    "dataQuery": {
      "type": "bigquery",
      "dataset": "royalty_data"
    },
    "fileNameFormat": "royalty_{date}.csv",
    "schema": "artist_name,track_name,streams,revenue",
    "delimiter": ",",
    "tableNameFormat": "royalty_{tenant}",
    "headerRows": 1
  })
});

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

Authorizations

Authorization
string
header
required

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

Body

application/json
name
string
required

Source name (will be normalized to lowercase)

Example:

"Spotify"

label
string
required

Display label

Example:

"Spotify"

type
string
required

Source type

Example:

"DSP"

format
string
required

File format

Example:

"csv"

public
boolean
default:true

Make source publicly available (default true)

Example:

true

isActive
boolean
default:true

Mark source as active (default true)

Example:

true

startDate
string<date> | null
Example:

"2020-01-01"

endDate
string<date> | null
Example:

"2025-01-01"

dataQuery
object

JSONB query configuration

Example:
{
"type": "bigquery",
"dataset": "royalty_data"
}
fileNameFormat
string | null
Example:

"royalty_{date}.csv"

schema
string | null

Text representation of schema

Example:

"artist_name,track_name,streams,revenue"

delimiter
string | null
Example:

","

tableNameFormat
string | null
Example:

"royalty_{tenant}"

headerRows
integer | null
Example:

1

Response

Royalty source created successfully

id
string
Example:

"src-1"

name
string

Source name (automatically normalized to lowercase)

Example:

"spotify"

label
string

Display label for the source

Example:

"Spotify"

type
string

Source type (e.g., DSP, Publisher, Label)

Example:

"DSP"

format
string

File format (csv, excel, json, etc.)

Example:

"csv"

public
boolean

Whether this source is publicly available to all tenants

Example:

true

isActive
boolean
default:true

Whether this source is currently active

Example:

true

startDate
string<date> | null

Start date for source availability

Example:

"2020-01-01"

endDate
string<date> | null

End date for source availability

Example:

"2025-01-01"

dataQuery
object

JSONB object containing query configurations

Example:
{
"type": "bigquery",
"dataset": "royalty_data"
}
fileNameFormat
string | null

Template for expected file name format with period placeholders. Placeholders: {SALPER-FORMAT} (sale period), {ACCPER-FORMAT} (accounting period) Formats: YYYYMM, YYYY-MM, YYYY-MM-DD, MMM-YYYY, etc.

Example:

"{ORG}_Snap_{SALPER-YYYYMM}_Monthly-Sales.csv"

schema
string | null

Text representation of the file schema/structure

Example:

"artist_name,track_name,streams,revenue"

delimiter
string | null

Field delimiter for CSV files

Example:

","

tableNameFormat
string | null

Template for BigQuery table name with period placeholders (SALPER, ACCPER)

Example:

"merlin_snap_SALPER_ACCPER"

columnFormat
string | null

DSL for column semantic mappings. Defines how columns map to period types and formats. Format: ColumnName:TYPE-FORMAT;ColumnName2:TYPE-FORMAT;... Types: SALPER (sale period), ACCPER (accounting period), ISRC, UPC, CATNO, etc. Formats: YYYY-MM-DD, YYYYMM, YYYY-MM, etc.

Example:

"Start_Date:SALPER-YYYY-MM-DD;ISRC:ISRC"

headerRows
integer | null

Number of header rows to skip

Example:

1

fileInfo
object

Additional file metadata and configuration