> ## 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.

# Update Tenant Source by RoyaltySource ID

> Updates a tenant source association by the RoyaltySource ID.

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

## Description

### Required Permissions

* `sources:update`

### Important: ID Parameter

**The `id` parameter represents the RoyaltySource ID, not the TenantSource association ID.**

This endpoint updates the tenant's source association WHERE `RoyaltySourceId = id` AND `TenantId = authenticated_tenant`.

### Business Rules

* Can only update own tenant's associations
* Updates only `settings` and `replacements` fields

### Side Effects

* Triggers regeneration of tenant's sales data query cache
* Updates tenant-specific BigQuery query configurations

## Code Examples

<CodeGroup>
  ```javascript Node.js theme={null}
  const response = await fetch('https://api.royalti.io/sources/example-id', {
    method: 'PUT',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      "settings": {
        "delimiter": ","
      },
      "replacements": {
        "old": "new"
      }
    })
  });

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

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

  response = requests.put(
    'https://api.royalti.io/sources/example-id',
    headers={
      'Authorization': f'Bearer {token}'
    },
    json={"settings":{"delimiter":","},"replacements":{"old":"new"}}
  )

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

  ```bash cURL theme={null}
  curl -X PUT https://api.royalti.io/sources/example-id \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"settings":{"delimiter":","},"replacements":{"old":"new"}}'

  ```
</CodeGroup>


## OpenAPI

````yaml put /sources/{id}
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/{id}:
    put:
      tags:
        - Sources
      summary: Update Tenant Source by RoyaltySource ID
      description: >-
        Updates a tenant source association by the RoyaltySource ID.


        ### Required Permissions

        - `sources:update`


        ### Important: ID Parameter

        **The `id` parameter represents the RoyaltySource ID, not the
        TenantSource association ID.**


        This endpoint updates the tenant's source association WHERE
        `RoyaltySourceId = id` AND `TenantId = authenticated_tenant`.


        ### Business Rules

        - Can only update own tenant's associations

        - Updates only `settings` and `replacements` fields


        ### Side Effects

        - Triggers regeneration of tenant's sales data query cache

        - Updates tenant-specific BigQuery query configurations
      parameters:
        - name: id
          in: path
          required: true
          description: RoyaltySource ID (not TenantSource ID)
          schema:
            type: string
            example: src-1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                settings:
                  type: object
                  description: Tenant-specific settings for this source
                  example:
                    delimiter: ','
                replacements:
                  type: object
                  description: Field mapping/replacement rules
                  example:
                    old: new
      responses:
        '200':
          description: Tenant source updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TenantSource'
              example:
                TenantId: 1
                RoyaltySourceId: src-1
                isActive: true
                settings:
                  delimiter: ','
                replacements:
                  old: new
                royaltySource:
                  id: src-1
                  name: spotify
                  label: Spotify
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Source association not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                notFound:
                  value:
                    success: false
                    error:
                      code: '404'
                      message: Source association not found
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - bearerAuth: []
components:
  schemas:
    TenantSource:
      type: object
      description: |-
        Association between a tenant and a royalty source.
        Note: The composite key is (TenantId, RoyaltySourceId).
      properties:
        TenantId:
          type: integer
          description: Tenant ID (automatically set from authenticated user)
          example: 1
        RoyaltySourceId:
          type: string
          description: Royalty source ID
          example: src-1
        isActive:
          type: boolean
          description: Whether this source association is active for the tenant
          default: true
          example: true
        settings:
          type: object
          description: Tenant-specific settings for this source
          example: {}
        replacements:
          type: object
          description: Tenant-specific field replacements/mappings
          example: {}
        royaltySource:
          $ref: '#/components/schemas/RoyaltySource'
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type: array
              items:
                type: string
    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}"

````