> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.royalti.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Royalty Source (Admin)

> Creates a new royalty source record available globally.

<Note>
  This endpoint requires authentication. Include your Bearer token in the Authorization header.
</Note>

## Code Examples

<CodeGroup>
  ```javascript Node.js theme={null}
  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);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
    'https://api.royalti.io/sources/admin',
    headers={
      'Authorization': f'Bearer {token}'
    },
    json={"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}
  )

  data = response.json()
  print(data)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.royalti.io/sources/admin \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"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}'

  ```
</CodeGroup>


## OpenAPI

````yaml post /sources/admin
openapi: 3.0.0
info:
  title: Royalti.io API
  description: "# Royalti API\r\n\r\nThis is the Royalti music royalty management platform API server.\r\n\r\n## Overview\r\n\r\nThe Royalti API provides comprehensive music royalty management services including:\r\n- Music publishing and writer management\r\n- Royalty processing and analytics\r\n- DDEX integration for music industry standards\r\n- File processing and pattern recognition\r\n- Payment processing and distribution\r\n\r\n## Authentication\r\n\r\nThe API uses JWT-based authentication with multiple protection levels:\r\n- Public endpoints for basic operations\r\n- Protected endpoints requiring valid JWT tokens\r\n- Admin endpoints for administrative functions\r\n\r\n## Features\r\n\r\n- Multi-dimensional royalty analytics\r\n- CWR (Collective Works Registration) support\r\n- DDEX integration for music metadata\r\n- Advanced file processing with pattern recognition\r\n- Real-time data processing with queue system"
  version: 2.6.0
  contact:
    name: Royalti.io Support
    email: support@royalti.io
    url: https://royalti.io
  license:
    name: Proprietary
    url: https://royalti.io/terms
servers:
  - url: https://api.royalti.io
    description: Production server
  - url: https://api-dev.royalti.io
    description: Development server
  - url: http://localhost:8084
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: Accounting
    description: Accounting and financial transaction operations
  - name: DDEX
    description: DDEX operations (ERN/MEAD, messages, delivery, providers)
  - name: Label
    description: Label management operations
  - name: Internal Webhooks
    description: Internal system webhooks for royalty processing and downloads
  - name: Payment Webhooks
    description: Payment processor webhook endpoints
  - name: Billing Webhooks
    description: Stripe billing and subscription webhooks
  - name: Infrastructure Webhooks
    description: Cloudflare domain and SSL webhooks
  - name: Distribution Webhooks
    description: Digital distribution platform webhooks (FUGA)
paths:
  /sources/admin:
    post:
      tags:
        - Sources
      summary: Create Royalty Source (Admin)
      description: |-
        Creates a new royalty source record available globally.

        ### Required Permissions
        - `sources:admin:create`
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Source name (will be normalized to lowercase)
                  example: Spotify
                label:
                  type: string
                  description: Display label
                  example: Spotify
                type:
                  type: string
                  description: Source type
                  example: DSP
                format:
                  type: string
                  description: File format
                  example: csv
                public:
                  type: boolean
                  description: Make source publicly available (default true)
                  default: true
                  example: true
                isActive:
                  type: boolean
                  description: Mark source as active (default true)
                  default: true
                  example: true
                startDate:
                  type: string
                  format: date
                  nullable: true
                  example: '2020-01-01'
                endDate:
                  type: string
                  format: date
                  nullable: true
                  example: '2025-01-01'
                dataQuery:
                  type: object
                  nullable: true
                  description: JSONB query configuration
                  example:
                    type: bigquery
                    dataset: royalty_data
                fileNameFormat:
                  type: string
                  nullable: true
                  example: royalty_{date}.csv
                schema:
                  type: string
                  nullable: true
                  description: Text representation of schema
                  example: artist_name,track_name,streams,revenue
                delimiter:
                  type: string
                  nullable: true
                  example: ','
                tableNameFormat:
                  type: string
                  nullable: true
                  example: royalty_{tenant}
                headerRows:
                  type: integer
                  nullable: true
                  example: 1
              required:
                - name
                - label
                - type
                - format
      responses:
        '201':
          description: Royalty source created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RoyaltySource'
              example:
                id: src-3
                name: Spotify
                label: Spotify
                type: DSP
                format: csv
                public: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - bearerAuth: []
components:
  schemas:
    RoyaltySource:
      type: object
      properties:
        id:
          type: string
          example: src-1
        name:
          type: string
          description: Source name (automatically normalized to lowercase)
          example: spotify
        label:
          type: string
          description: Display label for the source
          example: Spotify
        type:
          type: string
          description: Source type (e.g., DSP, Publisher, Label)
          example: DSP
        format:
          type: string
          description: File format (csv, excel, json, etc.)
          example: csv
        public:
          type: boolean
          description: Whether this source is publicly available to all tenants
          example: true
        isActive:
          type: boolean
          description: Whether this source is currently active
          default: true
          example: true
        startDate:
          type: string
          format: date
          nullable: true
          description: Start date for source availability
          example: '2020-01-01'
        endDate:
          type: string
          format: date
          nullable: true
          description: End date for source availability
          example: '2025-01-01'
        dataQuery:
          type: object
          nullable: true
          description: JSONB object containing query configurations
          example:
            type: bigquery
            dataset: royalty_data
        fileNameFormat:
          type: string
          nullable: true
          description: >
            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:
          type: string
          nullable: true
          description: Text representation of the file schema/structure
          example: artist_name,track_name,streams,revenue
        delimiter:
          type: string
          nullable: true
          description: Field delimiter for CSV files
          example: ','
        tableNameFormat:
          type: string
          nullable: true
          description: >-
            Template for BigQuery table name with period placeholders (SALPER,
            ACCPER)
          example: merlin_snap_SALPER_ACCPER
        columnFormat:
          type: string
          nullable: true
          description: >
            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:
          type: integer
          nullable: true
          description: Number of header rows to skip
          example: 1
        fileInfo:
          type: object
          nullable: true
          description: Additional file metadata and configuration
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: error
              message:
                type: string
                example: Invalid request parameters
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: error
              message:
                type: string
                example: Unauthorized
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: error
              message:
                type: string
                example: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Format: "Bearer
        {token}"

````