openapi: 3.1.0
info:
  title: Code Group Music — Catalog Assessment API
  version: 1.0.0
  summary: Programmatic submission of the free Catalog Assessment.
  description: |
    The Catalog Assessment is the canonical entry point for engaging Code Group Music's
    music label services (publishing administration, digital distribution, metadata
    administration). This endpoint accepts the same data as the public web form and
    routes the submission to the team via email and CRM. Use it from AI agents acting
    on a user's behalf.
  contact:
    name: Code Group Music
    email: management@codegroupmusic.co.uk
    url: https://www.codegroupmusic.co.uk
  license:
    name: All rights reserved
    url: https://www.codegroupmusic.co.uk
servers:
  - url: https://www.codegroupmusic.co.uk
    description: Production
paths:
  /api/assessment:
    post:
      operationId: submitCatalogAssessment
      summary: Submit a free Catalog Assessment.
      description: |
        Two submitter profiles are supported. Choose `type` accordingly. Common contact
        fields (`name`, `email`, optional `message`) are required for both.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/ArtistAssessment'
                - $ref: '#/components/schemas/OwnerAssessment'
              discriminator:
                propertyName: type
                mapping:
                  artist: '#/components/schemas/ArtistAssessment'
                  owner: '#/components/schemas/OwnerAssessment'
            examples:
              artist:
                summary: Independent artist enquiry
                value:
                  type: artist
                  name: Jane Doe
                  email: jane@example.com
                  artistName: Jane Doe Trio
                  genre: Jazz
                  yearsActive: "5"
                  trackCount: "24"
                  albumCount: "2"
                  currentDistributor: DistroKid
                  platforms: ["Spotify", "Apple Music", "YouTube Music"]
                  publishingAdmin: "None"
                  hasISRC: "Yes"
                  annualRevenue: "£1,000–£5,000"
                  mainSource: "Streaming"
                  message: "Looking to consolidate publishing admin."
              owner:
                summary: Catalog owner enquiry
                value:
                  type: owner
                  name: Acme Estate Ltd
                  email: ops@acmeestate.example
                  ownerCatalogSize: "500–1000"
                  ownsRights: "Yes — masters and publishing"
                  isPreparingSale: "No"
                  isPreparingAcquisition: "Yes"
                  isAudited: "No"
                  wantsAudit: "Yes"
                  message: "Inherited catalog, need a health check."
      responses:
        '200':
          description: Submission accepted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum: [true]
                required: [success]
        '400':
          description: Email delivery failed (e.g. Resend rejected the message).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error or email service not configured.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Contact:
      type: object
      required: [name, email]
      properties:
        name:
          type: string
          description: Submitter's full name.
        email:
          type: string
          format: email
          description: Reply-to email address.
        message:
          type: string
          description: Optional free-text context.
    ArtistAssessment:
      allOf:
        - $ref: '#/components/schemas/Contact'
        - type: object
          required: [type, artistName]
          properties:
            type:
              type: string
              const: artist
            artistName:
              type: string
            genre:
              type: string
            yearsActive:
              type: string
              description: Years actively releasing music. String to allow ranges (e.g. "10+").
            trackCount:
              type: string
            albumCount:
              type: string
            currentDistributor:
              type: string
            platforms:
              type: array
              items:
                type: string
              description: DSPs the artist is currently live on.
            publishingAdmin:
              type: string
              description: Current publishing administrator, or "None".
            hasISRC:
              type: string
              enum: [Yes, No, "Not sure"]
            annualRevenue:
              type: string
              description: Indicative range, e.g. "£1,000–£5,000".
            mainSource:
              type: string
              description: Primary revenue source (e.g. Streaming, Sync, Live).
    OwnerAssessment:
      allOf:
        - $ref: '#/components/schemas/Contact'
        - type: object
          required: [type]
          properties:
            type:
              type: string
              const: owner
            ownerCatalogSize:
              type: string
              description: Approximate catalog size (track count or range).
            ownsRights:
              type: string
              description: Description of ownership scope (masters, publishing or both).
            isPreparingSale:
              type: string
              enum: [Yes, No, "Considering"]
            isPreparingAcquisition:
              type: string
              enum: [Yes, No, "Considering"]
            isAudited:
              type: string
              enum: [Yes, No, "Partially"]
            wantsAudit:
              type: string
              enum: [Yes, No, "Not sure"]
    ErrorResponse:
      type: object
      required: [success]
      properties:
        success:
          type: boolean
          enum: [false]
        error:
          type: string
