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

# Apply Template

> **POST /defaultsettings/templates/{templateId}/apply**

## Description

**POST /defaultsettings/templates/{templateId}/apply**

**Description:**
Apply a template to create a new default setting for an entity. This increments
the template's usage count.

**Method:**
`POST`

**Path Parameters:**

| Parameter  | Type | Description             | Required |
| ---------- | ---- | ----------------------- | -------- |
| templateId | uuid | ID of template to apply | Yes      |

**Request Body:**

| Parameter  | Type   | Description                                    | Required    |
| ---------- | ------ | ---------------------------------------------- | ----------- |
| entityType | string | Target entity type                             | Yes         |
| entityId   | uuid   | Target entity ID (optional for tenant/catalog) | Conditional |

## Code Examples

<CodeGroup>
  ```javascript Node.js theme={null}
  const response = await fetch('https://api.royalti.io/defaultsettings/templates/example-id/apply', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      "entityType": "sample-entityType",
      "entityId": "sample-entityId"
    })
  });

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

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

  response = requests.post(
    'https://api.royalti.io/defaultsettings/templates/example-id/apply',
    json={"entityType":"sample-entityType","entityId":"sample-entityId"}
  )

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

  ```bash cURL theme={null}
  curl -X POST https://api.royalti.io/defaultsettings/templates/example-id/apply \
    -H "Content-Type: application/json" \
    -d '{"entityType":"sample-entityType","entityId":"sample-entityId"}'

  ```
</CodeGroup>


## OpenAPI

````yaml post /defaultsettings/templates/{templateId}/apply
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:
  /defaultsettings/templates/{templateId}/apply:
    post:
      tags:
        - Templates
      summary: Apply Template
      description: >-
        **POST /defaultsettings/templates/{templateId}/apply**


        **Description:**

        Apply a template to create a new default setting for an entity. This
        increments

        the template's usage count.


        **Method:**

        `POST`


        **Path Parameters:**


        | Parameter | Type | Description | Required |

        | --- | --- | --- | --- |

        | templateId | uuid | ID of template to apply | Yes |


        **Request Body:**


        | Parameter | Type | Description | Required |

        | --- | --- | --- | --- |

        | entityType | string | Target entity type | Yes |

        | entityId | uuid | Target entity ID (optional for tenant/catalog) |
        Conditional |
      parameters:
        - name: templateId
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: ID of the template to apply
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - entityType
              properties:
                entityType:
                  type: string
                  enum:
                    - tenant
                    - label
                    - artist
                    - user
                    - catalog
                entityId:
                  type: string
                  format: uuid
            example:
              entityType: artist
              entityId: 660e8400-e29b-41d4-a716-446655440001
      responses:
        '201':
          description: Template applied successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Template applied successfully
                  data:
                    $ref: '#/components/schemas/DefaultSetting'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    DefaultSetting:
      type: object
      description: A default setting entry
      required:
        - id
        - TenantId
        - entityType
        - category
        - settings
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the default setting
        TenantId:
          type: integer
          description: Workspace/tenant identifier
        entityType:
          type: string
          enum:
            - tenant
            - label
            - artist
            - user
            - catalog
          description: Type of entity this setting applies to
        entityId:
          type: string
          format: uuid
          nullable: true
          description: Specific entity ID (null for tenant/catalog-level settings)
        category:
          type: string
          enum:
            - content
            - business
            - ddex
            - validation
          description: Category of settings
        settings:
          $ref: '#/components/schemas/DefaultSettingsData'
        isActive:
          type: boolean
          default: true
          description: Whether this setting is currently active
        priority:
          type: integer
          default: 0
          description: Priority for conflict resolution (higher = higher priority)
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    DefaultSettingsData:
      type: object
      description: The actual settings data organized by category
      properties:
        content:
          type: object
          description: Content-related default settings
          properties:
            type:
              type: string
              enum:
                - Audio
                - Video
                - Ringtone
                - YouTube
              description: Media type
            format:
              type: string
              enum:
                - Single
                - EP
                - Album
                - LP
              description: Release format
            version:
              type: string
              description: Version information (e.g., "Deluxe Edition", "Remastered")
            explicit:
              type: string
              enum:
                - explicit
                - clean
              description: Explicit content flag
            language:
              type: string
              description: Primary language (ISO 639-1 code)
            mainGenre:
              type: array
              items:
                type: string
              description: Primary genre classifications
            subGenre:
              type: array
              items:
                type: string
              description: Secondary genre classifications
            contributors:
              type: object
              additionalProperties:
                type: array
                items:
                  type: string
              description: >-
                Contributors mapped by role (key: role name, value: array of
                contributor names)
        business:
          type: object
          description: Business-related default settings
          properties:
            label:
              type: string
              description: Record label name
            copyright:
              type: string
              description: Copyright notice (e.g., "© 2024 Label Name")
            publisher:
              type: string
              description: Music publisher name
            copyrightOwner:
              type: string
              description: Copyright owner/holder
            distribution:
              type: string
              description: Distribution method or partner
            status:
              type: string
              enum:
                - Live
                - Taken Down
                - Scheduled
                - Pending
                - Error
              description: Default release status
        ddex:
          type: object
          description: DDEX-specific default settings
          properties:
            enableDDEX:
              type: boolean
              description: Enable DDEX message generation
            labelName:
              type: string
              description: Label name for DDEX messages
            resourceReference:
              type: string
              description: Default resource reference pattern
            grid:
              type: string
              description: Global Release Identifier (GRid)
            icpn:
              type: string
              description: International Catalog Product Number
        validation:
          type: object
          description: Validation rules
          properties:
            requireGenre:
              type: boolean
              description: Require genre selection
            requireLyrics:
              type: boolean
              description: Require lyrics for tracks
            requireDescription:
              type: boolean
              description: Require description field
            minimumTrackCount:
              type: integer
              minimum: 0
              description: Minimum number of tracks
            maximumTrackCount:
              type: integer
              minimum: 1
              description: Maximum number of tracks
    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
  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
    NotFound:
      description: Not found
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: error
              message:
                type: string
                example: Resource not found
    Conflict:
      description: Conflict - Resource already exists or duplicate constraint violation
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error:
              code: CONFLICT
              message: A default setting for this entity and category already exists
    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}"

````