openapi: 3.1.0
info:
  title: DistroVibe Public API
  version: 1.2.0
  description: >-
    Contract for the implemented v1 route surface. Every response carries an
    X-Request-Id header (quote it to support). POST, PUT, PATCH and DELETE
    accept an Idempotency-Key header (1-255 printable ASCII characters); a
    retry with the same key and body within 24 hours replays the stored
    response with Idempotent-Replayed true, a different body returns 422 and
    a request still in progress returns 409. Errors use an error object with
    code, message and status. Endpoints are not generally available until the
    Developer Platform launches.
servers:
  - url: https://api.distrovibe.com/v1
security:
  - bearerAuth: []
tags:
  - name: Meta
  - name: Account
  - name: Catalog
  - name: Insights
  - name: Releases
  - name: Uploads
  - name: Publishing
  - name: Teams
  - name: Webhooks
  - name: Jobs
  - name: Financials
  - name: Sandbox
paths:
  /:
    get:
      tags: [Meta]
      summary: API index (version, authentication and endpoint list)
      security: []
      responses:
        '200': { description: API index }
  /health:
    get:
      tags: [Meta]
      summary: Service health
      security: []
      responses:
        '200': { description: Service is healthy }
  /account:
    get:
      tags: [Account]
      summary: Account identity and current API quota
      description: Available to every approved key, whatever its scopes. Rate limits are shared by all keys on the account.
      responses:
        '200': { description: Account and quota summary, content: { application/json: { schema: { $ref: '#/components/schemas/AccountResponse' } } } }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /account/usage:
    get:
      tags: [Account]
      summary: Current UTC-month API request usage and purchased package balance
      description: Available to every approved key, whatever its scopes. Rate limits are shared by all keys on the account.
      responses:
        '200': { description: 'Request count, allowance, remaining requests, packageRequestsRemaining and packageNextExpiry. The monthly allowance renews on the 1st (UTC); purchased packages are used after it, soonest expiry first. There are no overage charges: when both are used up, requests return 429 MONTHLY_QUOTA_EXCEEDED.' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /account/limits:
    get:
      tags: [Account]
      summary: Current API and included artist-profile limits
      description: Available to every approved key, whatever its scopes. Rate limits are shared by all keys on the account.
      responses:
        '200': { description: API rate, monthly allowance, concurrency and artist-profile limits }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /artists:
    get:
      tags: [Catalog]
      summary: List artists in the account roster
      x-required-scope: artists:read
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
        - { name: search, in: query, schema: { type: string } }
      responses:
        '200': { description: Paginated artist roster, content: { application/json: { schema: { $ref: '#/components/schemas/ArtistList' } } } }
        '400': { description: Invalid pagination or search }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    post:
      tags: [Catalog]
      summary: Create an artist using the same plan, profile validation and restriction policy as the dashboard
      x-required-scope: artists:write
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: '#/components/schemas/ArtistInput' } } }
      responses:
        '201': { description: Created artist profile }
        '400': { description: Invalid artist profile }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '409': { description: Artist already in roster }
        '413': { description: Request body larger than 16 KB }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /artists/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Catalog]
      summary: Get an owned or label-roster artist profile
      x-required-scope: artists:read
      responses:
        '200': { description: Artist profile }
        '404': { description: Artist not found in this account roster }
    patch:
      tags: [Catalog]
      summary: Update a directly owned artist profile
      description: >-
        Partial update: omitted fields are left unchanged; send null to clear a
        field. A label-roster association alone does not grant ownership
        transfer or write access.
      x-required-scope: artists:write
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: '#/components/schemas/ArtistInput' } } }
      responses:
        '200': { description: Updated artist profile }
        '400': { description: Invalid artist profile }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '404': { description: Artist not directly owned by this account }
        '409': { description: Another artist in the roster already uses this Spotify profile }
        '413': { description: Request body larger than 16 KB }
  /releases:
    post:
      tags: [Releases]
      summary: Create a draft release
      description: >-
        Applies the same rules as the dashboard (artist ownership, label imprint
        and fast-release plan perks, UPC/ISRC blacklist, trusted audio
        locations). Writes apply only to releases the account owns directly.
      x-required-scope: releases:write
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: '#/components/schemas/ReleaseInput' } } }
      responses:
        '201': { description: Created draft, content: { application/json: { schema: { $ref: '#/components/schemas/DraftReleaseResponse' } } } }
        '409': { description: An ISRC is already assigned to another track }
        '422': { description: UPC or ISRC is blacklisted }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    get:
      tags: [Catalog]
      summary: List releases
      x-required-scope: releases:read
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
        - { name: status, in: query, schema: { type: string } }
        - { name: search, in: query, schema: { type: string } }
      responses:
        '200': { description: Paginated release list, content: { application/json: { schema: { $ref: '#/components/schemas/ReleaseList' } } } }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /releases/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Catalog]
      summary: Get a release and its tracks
      description: Provisional DistroVibe ISRCs are withheld until delivery.
      x-required-scope: releases:read
      responses:
        '200': { description: Owned release detail }
        '404': { description: Release not found for this account }
    patch:
      tags: [Releases]
      summary: Partially update a draft release
      description: Omitted fields are unchanged. Use the track endpoints to change tracks.
      x-required-scope: releases:write
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: '#/components/schemas/ReleaseInput' } } }
      responses:
        '200': { description: Updated draft, content: { application/json: { schema: { $ref: '#/components/schemas/DraftReleaseResponse' } } } }
        '404': { description: Release not found }
        '409': { description: Release is no longer a draft, or it changed concurrently }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    delete:
      tags: [Releases]
      summary: Delete a draft release
      x-required-scope: releases:write
      responses:
        '204': { description: Deleted }
        '404': { description: Release not found }
        '409': { description: Only drafts can be deleted }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /releases/{id}/submit:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Releases]
      summary: Submit a draft for review
      description: >-
        Records the Rights Declaration, then runs the subscription, QA,
        release-date (7 days unless fast release) and upload-protection gates.
        A high submission volume may place the release on hold (onHold: true).
      x-required-scope: releases:submit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [rightsDeclaration]
              properties:
                rightsDeclaration:
                  type: object
                  required: [ownsAllRights, noUnlicensedSamples, acceptsTerminationRisk]
                  properties:
                    ownsAllRights: { type: boolean, const: true }
                    noUnlicensedSamples: { type: boolean, const: true }
                    acceptsTerminationRisk: { type: boolean, const: true }
                locale: { type: string, example: en }
      responses:
        '202': { description: Submitted (status PENDING) }
        '404': { description: Release not found }
        '409': { description: Release is no longer a draft }
        '422': { description: QA failed; the response contains the QA report in error.qa }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /releases/{id}/reopen:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Releases]
      summary: Move a rejected release back to draft
      description: >-
        Moves a REJECTED release back to DRAFT, keeping its files, UPC and
        ISRCs, so it can be edited with PATCH /releases/{id} and the track
        endpoints and submitted again with POST /releases/{id}/submit. Only
        releases with canResubmit true can be reopened; final rejections
        return 403 FINAL_REJECTION. Fires release.status_changed.
      x-required-scope: releases:write
      responses:
        '200': { description: Reopened; the release is returned with status DRAFT }
        '404': { description: Release not found }
        '409': { description: Release is not rejected (RELEASE_NOT_REJECTED) }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { description: Final rejection (FINAL_REJECTION), upload restriction or missing scope }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /partner/members/{externalId}:
    parameters:
      - { name: externalId, in: path, required: true, schema: { type: string }, description: Your own user id (the sub of the SSO token) }
    get:
      tags: [Partners]
      summary: A portal member and their current plan
      x-required-scope: partners:members
      responses:
        '200': { description: The member, with plan (your plan key) and package }
        '404': { description: No portal member has signed in through SSO with this id (MEMBER_NOT_FOUND) }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { description: The key doesn't belong to an active partner's owner, or lacks the scope }
  /partner/members/{externalId}/plan:
    parameters:
      - { name: externalId, in: path, required: true, schema: { type: string }, description: Your own user id (the sub of the SSO token) }
    put:
      tags: [Partners]
      summary: Set a portal member's plan from your billing
      description: >-
        Moves the member onto the package whose Plan key matches, right away.
        Use it from your billing webhooks (upgrade, downgrade, cancellation)
        so packages don't wait for the member's next SSO sign-in. null moves
        the member to your default package.
      x-required-scope: partners:members
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [plan]
              properties:
                plan: { type: string, nullable: true, example: pro }
      responses:
        '200': { description: Updated; the member is returned with the new plan and package }
        '400': { description: Invalid plan value or external id }
        '404': { description: Member not found (MEMBER_NOT_FOUND) }
        '422': { description: No package with that plan key (PLAN_NOT_FOUND), or no default package (NO_DEFAULT_PACKAGE) }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { description: The key doesn't belong to an active partner's owner, or lacks the scope }
  /partner/members/{externalId}/releases:
    parameters:
      - { name: externalId, in: path, required: true, schema: { type: string }, description: Your own user id (the sub of the SSO token) }
    get:
      tags: [Partners]
      summary: A portal member's releases
      description: >-
        The member's releases, newest first, with title, artist, type, release
        date, artwork URL, UPC, tracks with ISRCs and current status, and the
        member's externalId and email. Use it with the partner.release_submitted
        and partner.release_status_changed webhooks to keep your catalog in sync.
        With TEST keys, the sandbox has one sample member with externalId
        "sandbox-member-1"; its releases are your sandbox releases, and
        POST /sandbox/releases/{id}/simulate also sends the partner.release_* events.
      x-required-scope: partners:members
      parameters:
        - { name: status, in: query, required: false, schema: { type: string, enum: [DRAFT, PENDING, APPROVED, DISTRIBUTING, NEEDS_DOCS, IN_REVIEW, DELIVERED, LIVE, RELEASED, REJECTED, TAKEDOWN, TAKEDOWN_PENDING, TAKEDOWN_COMPLETE] } }
        - { name: limit, in: query, required: false, schema: { type: integer, minimum: 1, maximum: 100, default: 25 } }
        - { name: cursor, in: query, required: false, schema: { type: string }, description: nextCursor from the previous page }
      responses:
        '200': { description: '{ releases: [...], nextCursor }' }
        '400': { description: Invalid external id or status }
        '404': { description: No portal member has signed in through SSO with this id (MEMBER_NOT_FOUND) }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { description: The key doesn't belong to an active partner's owner, or lacks the scope }
  /partner/releases/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string }, description: The releaseId from a partner.release_* webhook }
    get:
      tags: [Partners]
      summary: One release of a portal member
      description: >-
        Any release of a member of your portal, with the same fields as the
        list above and member { externalId, email }.
      x-required-scope: partners:members
      responses:
        '200': { description: '{ release }' }
        '404': { description: Not a release of one of your portal members (NOT_FOUND) }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { description: The key doesn't belong to an active partner's owner, or lacks the scope }
  /sandbox/releases/{id}/simulate:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Sandbox]
      summary: Simulate a review or delivery status (sandbox only)
      description: >-
        Works with dv_test_ keys only. Moves a submitted sandbox release to a
        new status and sends release.status_changed, as a real review, delivery
        or takedown would.
      x-required-scope: releases:submit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [status]
              properties:
                status: { type: string, enum: [APPROVED, NEEDS_DOCS, REJECTED, DISTRIBUTING, DELIVERED, LIVE, TAKEDOWN_COMPLETE] }
                reason: { type: string, description: Shown as the rejection or documents reason }
      responses:
        '200': { description: Status changed }
        '403': { description: Not a dv_test_ key (SANDBOX_ONLY) }
        '404': { description: Release not found }
        '409': { description: The release can't move to that status (for example a draft) }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '429': { $ref: '#/components/responses/RateLimited' }
  /sandbox/reset:
    post:
      tags: [Sandbox]
      summary: Reset the sandbox (sandbox only)
      description: Deletes everything in the sandbox and recreates the sample catalogue. Works with dv_test_ keys only.
      x-required-scope: releases:read
      responses:
        '200': { description: Sandbox reset }
        '403': { description: Not a dv_test_ key (SANDBOX_ONLY) }
        '401': { $ref: '#/components/responses/Unauthorized' }
  /releases/{id}/takedown:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Releases]
      summary: Take down a distributed release
      description: >-
        Only live releases qualify (drafts are deleted instead; releases still in delivery cannot be taken down yet). Audio masters are deleted and the release moves to TAKEDOWN; a release.status_changed webhook follows.
      x-required-scope: releases:submit
      responses:
        '202': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /releases/{id}/status:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Catalog]
      summary: Get release moderation and distribution status
      x-required-scope: releases:read
      responses:
        '200': { description: Release status and rejection reason when rejected }
        '404': { description: Release not found for this account }
  /releases/{id}/distribution:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Catalog]
      summary: Get requested platform and recorded delivery states
      x-required-scope: releases:read
      responses:
        '200': { description: Recorded distribution status without internal delivery notes }
        '404': { description: Release not found for this account }
  /releases/{id}/tracks:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Catalog]
      summary: List tracks on an owned release
      x-required-scope: releases:read
      responses:
        '200': { description: Safe track metadata }
        '404': { description: Release not found for this account }
    post:
      tags: [Releases]
      summary: Add a track to a draft
      x-required-scope: releases:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - { $ref: '#/components/schemas/TrackInput' }
                - { type: object, properties: { position: { type: integer, minimum: 1, description: '1-based; defaults to the end' } } }
      responses:
        '201': { description: The new track and the updated draft }
        '404': { description: Release not found }
        '409': { description: Release is no longer a draft }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    put:
      tags: [Releases]
      summary: Replace the track list in order
      description: Include a track's id to keep it; tracks left out are deleted; items without id are created.
      x-required-scope: releases:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [tracks]
              properties:
                tracks: { type: array, maxItems: 200, items: { allOf: [{ $ref: '#/components/schemas/TrackInput' }, { type: object, properties: { id: { type: string } } }] } }
      responses:
        '200': { description: Updated draft, content: { application/json: { schema: { $ref: '#/components/schemas/DraftReleaseResponse' } } } }
        '404': { description: Release not found }
        '409': { description: Release is no longer a draft }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /releases/{id}/validate:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Catalog]
      summary: Run existing release quality checks without submitting
      x-required-scope: releases:submit
      responses:
        '200': { description: QA report }
        '404': { description: Release not found for this account }
  /tracks/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Catalog]
      summary: Get a track on an owned release
      x-required-scope: releases:read
      responses:
        '200': { description: Safe track metadata }
        '404': { description: Track not found for this account }
    patch:
      tags: [Releases]
      summary: Partially update a track on a draft
      description: Typically used to set audioUrl after POST /uploads/complete.
      x-required-scope: releases:write
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: '#/components/schemas/TrackInput' } } }
      responses:
        '200': { description: The updated track and draft }
        '404': { description: Track not found }
        '409': { description: Release is no longer a draft }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    delete:
      tags: [Releases]
      summary: Remove a track from a draft
      x-required-scope: releases:write
      responses:
        '200': { description: Updated draft }
        '404': { description: Track not found }
        '409': { description: Release is no longer a draft }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /uploads:
    get:
      tags: [Uploads]
      summary: List upload sessions and the storage balance
      x-required-scope: uploads:write
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
        - { name: status, in: query, schema: { type: string, enum: [PENDING, COMPLETED, FAILED, CANCELLED, EXPIRED, DELETED] } }
      responses:
        '200': { description: Upload sessions and storage (quotaBytes, confirmedBytes, reservedBytes, monthlyUploadLimitBytes, monthlyUploadedBytes) }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    post:
      tags: [Uploads]
      summary: Start a direct upload session
      description: >-
        Reserves storage quota and monthly upload volume, then returns presigned
        URL(s); file bytes go directly to storage, never through DistroVibe
        servers. Files over 100 MB use multipart (one URL per 64 MB part).
        release_audio WAV/FLAC (needs a draft releaseId), cover_art JPEG/PNG,
        document PDF/JPEG/PNG; size limits are in /account/limits.
      x-required-scope: uploads:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [purpose, filename, contentType, fileSize]
              properties:
                purpose: { type: string, enum: [release_audio, cover_art, document] }
                filename: { type: string }
                contentType: { type: string }
                fileSize: { type: integer, minimum: 1 }
                releaseId: { type: string }
      responses:
        '201': { description: '{ session, upload: { type: single|multipart, url | parts[{partNumber, size, url}], headers }, urlsExpireAt }' }
        '409': { description: STORAGE_QUOTA_EXCEEDED }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /uploads/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Uploads]
      summary: Get an upload session
      x-required-scope: uploads:write
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    delete:
      tags: [Uploads]
      summary: Cancel a pending upload or delete an unattached completed file
      x-required-scope: uploads:write
      responses:
        '204': { description: Cancelled or deleted; reserved or stored bytes are released }
        '409': { description: The file is attached to a release }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /uploads/{id}/complete:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Uploads]
      summary: Complete and verify an upload
      description: >-
        Finishes multipart uploads (send parts with ETags), then verifies size, type and header-level media checks - cover art must be square and at least 3000 x 3000; audio must be WAV or FLAC, 44.1 kHz or higher, 16/24/32-bit, mono or stereo. Failed files are removed and their quota released. Only completed uploads can be attached (audioUrl, coverArtUrl, coverSongFileUrl, aiDocumentationUrl).
      x-required-scope: uploads:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                parts: { type: array, items: { type: object, properties: { partNumber: { type: integer }, etag: { type: string } } } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /catalog:
    get:
      tags: [Catalog]
      summary: Search owned catalog by UPC or ISRC, or list all owned tracks
      description: >-
        Supply at most one of upc or isrc. Without either, returns a paginated
        list of every owned track, including tracks still awaiting an ISRC.
      x-required-scope: catalog:read
      parameters:
        - { name: upc, in: query, schema: { type: string } }
        - { name: isrc, in: query, schema: { type: string } }
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
      responses:
        '200': { description: Matching catalog records }
        '400': { description: Both upc and isrc supplied, or invalid pagination }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /catalog/releases:
    get:
      tags: [Catalog]
      summary: Catalog releases with filters and sorting
      x-required-scope: catalog:read
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
        - { name: status, in: query, schema: { type: string } }
        - { name: artistId, in: query, schema: { type: string } }
        - { name: upc, in: query, schema: { type: string } }
        - { name: search, in: query, schema: { type: string } }
        - { name: sort, in: query, schema: { type: string, enum: [createdAt, releaseDate, title, updatedAt] } }
        - { name: order, in: query, schema: { type: string, enum: [asc, desc] } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /catalog/artists:
    get:
      tags: [Catalog]
      summary: Artists you own or manage, with release counts
      x-required-scope: catalog:read
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
        - { name: search, in: query, schema: { type: string } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /catalog/search:
    get:
      tags: [Catalog]
      summary: Search releases, tracks and artists
      description: >-
        Text match on titles and names, exact UPC or exact visible ISRC; up to 20 results per type.
      x-required-scope: catalog:read
      parameters:
        - { name: q, in: query, required: true, schema: { type: string, minLength: 2, maxLength: 100 } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics:
    get:
      tags: [Insights]
      summary: Monthly streams and reported sales
      description: >-
        Inclusive UTC month range (default last 12 months, max 36). Period totals use dated histories only; lifetime figures are labelled lifetime. reportedRevenue is analytics sales data, not payable royalties. Includes dataUpdatedAt.
      x-required-scope: analytics:read
      parameters:
        - { name: from, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { name: to, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { name: releaseId, in: query, schema: { type: string } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics/overview:
    get:
      tags: [Insights]
      summary: Headline analytics with top platforms and countries
      x-required-scope: analytics:read
      parameters:
        - { name: from, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { name: to, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics/streams:
    get:
      tags: [Insights]
      summary: Streams per release for a month range (paginated)
      x-required-scope: analytics:read
      parameters:
        - { name: from, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { name: to, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics/platforms:
    get:
      tags: [Insights]
      summary: Streams per store for a month range
      x-required-scope: analytics:read
      parameters:
        - { name: from, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { name: to, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics/countries:
    get:
      tags: [Insights]
      summary: Lifetime streams per country
      description: >-
        Stores report country figures as lifetime totals only.
      x-required-scope: analytics:read
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics/timeseries:
    get:
      tags: [Insights]
      summary: Streams or reported revenue over time
      description: >-
        groupBy=month uses monthly data with from/to as YYYY-MM; groupBy=day or week uses daily store data only with from/to as YYYY-MM-DD (max 366 days). Monthly imports are never split into days.
      x-required-scope: analytics:read
      parameters:
        - { name: metric, in: query, schema: { type: string, enum: [streams, revenue], default: streams } }
        - { name: groupBy, in: query, schema: { type: string, enum: [day, week, month], default: month } }
        - { name: from, in: query, schema: { type: string } }
        - { name: to, in: query, schema: { type: string } }
        - { name: releaseId, in: query, schema: { type: string } }
        - { name: artistId, in: query, schema: { type: string } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics/artists/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Insights]
      summary: Analytics for one artist you own or manage
      x-required-scope: analytics:read
      parameters:
        - { name: from, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { name: to, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics/releases/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Insights]
      summary: Analytics for one release
      x-required-scope: analytics:read
      parameters:
        - { name: from, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { name: to, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /analytics/tracks/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Insights]
      summary: Lifetime engagement for one track
      description: >-
        Lifetime streams, saves and skips reported by stores plus YouTube statistics; stores provide no dated per-track history.
      x-required-scope: analytics:read
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /royalties:
    get:
      tags: [Financials]
      summary: Monthly sales report and wallet snapshot
      description: >-
        Transactions carry a fixed label per type; free-text descriptions are not exposed.
      x-required-scope: royalties:read
      parameters:
        - { name: month, in: query, schema: { type: string, pattern: '^\d{4}-\d{2}$' } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /royalties/overview:
    get:
      tags: [Financials]
      summary: Wallet balances, lifetime earnings and latest statement
      x-required-scope: royalties:read
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /royalties/statements:
    get:
      tags: [Financials]
      summary: Monthly sales reports (statement id = YYYY-MM)
      x-required-scope: royalties:read
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /royalties/statements/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Financials]
      summary: One month - sales report and wallet transactions
      x-required-scope: royalties:read
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /royalties/earnings:
    get:
      tags: [Financials]
      summary: Lifetime earnings per track
      description: >-
        Earnings belong to the release owner's account; roster releases owned by another account are excluded.
      x-required-scope: royalties:read
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /royalties/splits:
    get:
      tags: [Financials]
      summary: Revenue splits you own and receive
      description: >-
        Recipients' names, shares and status; contact details stay private.
      x-required-scope: royalties:read
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /royalties/transactions:
    get:
      tags: [Financials]
      summary: Wallet transactions
      x-required-scope: royalties:read
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
        - { name: type, in: query, schema: { type: string, enum: [ROYALTY_PAYOUT, WITHDRAWAL, REFUND, ADJUSTMENT, REFERRAL_REWARD, SERVICE_PAYMENT] } }
        - { name: from, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
        - { name: to, in: query, schema: { type: string, pattern: '^\d{4}-(0[1-9]|1[0-2])$' } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /publishing/agreement:
    get:
      tags: [Publishing]
      summary: Whether the Publishing Administration Agreement is signed
      description: The agreement can only be signed by the account owner in the dashboard.
      x-required-scope: publishing:read
      responses:
        '200': { description: '{ signed, signUrl }' }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /publishing/compositions:
    get:
      tags: [Publishing]
      summary: List compositions
      x-required-scope: publishing:read
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
        - { name: status, in: query, schema: { type: string, enum: [PENDING, ACTIVE, REJECTED, WITHDRAWN] } }
      responses:
        '200': { description: Paginated compositions }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    post:
      tags: [Publishing]
      summary: Submit a composition for publishing administration
      description: Writer shares (0-100 each) must total 100% and at least one writer must be collecting. Requires a signed agreement. Registrations are linked by ISRC and performer name.
      x-required-scope: publishing:write
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: '#/components/schemas/CompositionInput' } } }
      responses:
        '201': { description: Submitted composition (status PENDING) }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /publishing/compositions/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Publishing]
      summary: Get a composition
      x-required-scope: publishing:read
      responses:
        '200': { description: Composition }
        '404': { description: Composition not found }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /publishing/compositions/{id}/withdraw:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Publishing]
      summary: Withdraw a composition registration
      x-required-scope: publishing:write
      responses:
        '200': { description: Withdrawn composition }
        '404': { description: Composition not found }
        '409': { description: Already withdrawn }
        '422': { description: Already processed by the publisher }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /teams/members:
    get:
      tags: [Teams]
      summary: List team members
      x-required-scope: teams:read
      responses:
        '200': { description: Members (invitation tokens are never returned) }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    post:
      tags: [Teams]
      summary: Invite a team member
      description: Sends an invitation email (at most 30 invitations per day). The invitee accepts in DistroVibe.
      x-required-scope: teams:manage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name, email, role]
              properties:
                name: { type: string, maxLength: 100 }
                email: { type: string, format: email }
                role: { type: string, maxLength: 50 }
                permissions: { type: array, items: { type: string, enum: [manage_music, view_revenue, manage_team] } }
                assignedArtistIds: { type: array, items: { type: string }, description: Artists from your roster }
      responses:
        '201': { description: Invited member }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /teams/members/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Teams]
      summary: Get a team member
      x-required-scope: teams:read
      responses:
        '200': { description: Member }
        '404': { description: Member not found }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    patch:
      tags: [Teams]
      summary: Change a member's name, role or permissions
      description: Email, status and ownership cannot be changed, so members cannot be escalated to owner.
      x-required-scope: teams:manage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name: { type: string }
                role: { type: string }
                permissions: { type: array, items: { type: string, enum: [manage_music, view_revenue, manage_team] } }
                assignedArtistIds: { type: [array, 'null'], items: { type: string } }
      responses:
        '200': { description: Updated member }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    delete:
      tags: [Teams]
      summary: Remove a team member
      x-required-scope: teams:manage
      responses:
        '204': { description: Removed; access ends immediately }
        '404': { description: Member not found }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /teams/members/{id}/resend:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Teams]
      summary: Resend a pending invitation
      x-required-scope: teams:manage
      responses:
        '200': { description: New invitation expiry }
        '404': { description: Member not found }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /jobs:
    get:
      tags: [Jobs]
      summary: List bulk jobs and available job types
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    post:
      tags: [Jobs]
      summary: Queue a bulk job
      description: >-
        Types - artists.create (artists:write, items are artist inputs),
        releases.validate (releases:submit, items are objects with releaseId),
        catalog.export (catalog:read, no items; up to 10,000 tracks).
        Items per job and concurrent jobs per account are limited; at most 50
        jobs per day. Jobs run asynchronously and one failing item does not
        fail the job. Use Idempotency-Key for safe retries.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [type]
              properties:
                type: { type: string, enum: [artists.create, releases.validate, catalog.export] }
                items: { type: array, items: { type: object } }
      responses:
        '202': { description: Queued job }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /jobs/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Jobs]
      summary: Get job status and progress
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /jobs/{id}/results:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Jobs]
      summary: Per-item results (paginated)
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
        - { name: status, in: query, schema: { type: string, enum: [SUCCEEDED, FAILED] } }
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /jobs/{id}/cancel:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Jobs]
      summary: Cancel a queued or running job
      responses:
        '200': { description: OK }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /webhooks/events:
    get:
      tags: [Webhooks]
      summary: Subscribable event types
      x-required-scope: webhooks:manage
      responses:
        '200': { description: Event catalog }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /webhooks:
    get:
      tags: [Webhooks]
      summary: List webhook endpoints of the key's application
      x-required-scope: webhooks:manage
      responses:
        '200': { description: Endpoints }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    post:
      tags: [Webhooks]
      summary: Create a webhook endpoint
      description: >-
        HTTPS public hosts on port 443 or 8443 only (private, loopback and
        metadata addresses are refused, including via DNS). At most 5 endpoints
        per application. The
        signing secret is returned once.
      x-required-scope: webhooks:manage
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: '#/components/schemas/WebhookInput' } } }
      responses:
        '201': { description: '{ webhook, secret }' }
        '409': { description: Endpoint limit reached }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /webhooks/{id}:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Webhooks]
      summary: Get a webhook endpoint
      x-required-scope: webhooks:manage
      responses:
        '200': { description: Endpoint }
        '404': { description: Endpoint not found }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    patch:
      tags: [Webhooks]
      summary: Update a webhook endpoint
      description: Set status ACTIVE to re-enable an endpoint disabled after 25 consecutive failures.
      x-required-scope: webhooks:manage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - { $ref: '#/components/schemas/WebhookInput' }
                - { type: object, properties: { status: { type: string, enum: [ACTIVE, DISABLED] } } }
      responses:
        '200': { description: Updated endpoint }
        '404': { description: Endpoint not found }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
    delete:
      tags: [Webhooks]
      summary: Delete a webhook endpoint
      x-required-scope: webhooks:manage
      responses:
        '204': { description: Deleted }
        '404': { description: Endpoint not found }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /webhooks/{id}/rotate-secret:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Webhooks]
      summary: Rotate the signing secret
      x-required-scope: webhooks:manage
      responses:
        '200': { description: '{ webhook, secret }' }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /webhooks/{id}/test:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    post:
      tags: [Webhooks]
      summary: Send a webhook.test event now
      x-required-scope: webhooks:manage
      responses:
        '200': { description: Delivery outcome }
        '409': { description: Endpoint is disabled }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /webhooks/{id}/deliveries:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
    get:
      tags: [Webhooks]
      summary: Delivery history, newest first
      x-required-scope: webhooks:manage
      parameters:
        - { $ref: '#/components/parameters/Page' }
        - { $ref: '#/components/parameters/Limit' }
      responses:
        '200': { description: Paginated deliveries }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
  /webhooks/{id}/deliveries/{deliveryId}/retry:
    parameters:
      - { name: id, in: path, required: true, schema: { type: string } }
      - { name: deliveryId, in: path, required: true, schema: { type: string } }
    post:
      tags: [Webhooks]
      summary: Retry a failed delivery now
      x-required-scope: webhooks:manage
      responses:
        '200': { description: Delivery outcome }
        '409': { description: Only failed deliveries can be retried }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '403': { $ref: '#/components/responses/Forbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/LimiterUnavailable' }
webhooks:
  event:
    post:
      summary: Event delivery (Standard Webhooks)
      description: >-
        Each delivery is a POST with headers webhook-id, webhook-timestamp and
        webhook-signature (v1, HMAC-SHA256 over "id.timestamp.body" with the
        endpoint secret). Verify with any Standard Webhooks library and reject
        timestamps older than 5 minutes. Respond 2xx within 10 seconds; other
        responses are retried after 1m, 5m, 30m, 2h, 5h, 10h and 24h (8
        attempts). Payloads carry identifiers and status only.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id: { type: string, example: evt_0f3c... }
                type: { type: string, enum: [release.submitted, release.status_changed, composition.submitted, composition.status_changed, team.member_invited, team.member_removed, artist.created, artist.updated, upload.completed, upload.failed, royalties.statement_available, webhook.test] }
                createdAt: { type: string, format: date-time }
                data: { type: object, additionalProperties: true, example: { releaseId: clx..., previousStatus: PENDING, status: APPROVED } }
      responses:
        '200': { description: Acknowledged }
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: DistroVibe application API key
      description: >-
        A dv_live_ key issued for an approved application, or a dv_test_ key
        that acts on the application's sandbox (available while the
        application is reviewed). Sandbox releases are never delivered.
  parameters:
    Page: { name: page, in: query, schema: { type: integer, minimum: 1, default: 1 } }
    Limit: { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 20 } }
  schemas:
    AccountResponse:
      type: object
      properties:
        account: { type: object, additionalProperties: true }
        quota: { type: object, additionalProperties: true }
    ArtistList:
      type: object
      properties:
        artists: { type: array, items: { type: object, additionalProperties: true } }
        pagination: { $ref: '#/components/schemas/Pagination' }
    ReleaseList:
      type: object
      properties:
        releases: { type: array, items: { type: object, additionalProperties: true } }
        pagination: { $ref: '#/components/schemas/Pagination' }
    ArtistInput:
      type: object
      description: On create, name is required. Strings are trimmed; empty strings clear a field.
      properties:
        name: { type: string, minLength: 1, maxLength: 160 }
        spotifyUrl: { type: [string, 'null'], description: Official open.spotify.com/artist link }
        spotifyId: { type: [string, 'null'] }
        appleMusicUrl: { type: [string, 'null'], description: Official Apple Music artist link }
        imageUrl: { type: [string, 'null'], maxLength: 2048 }
        bio: { type: [string, 'null'], maxLength: 10000 }
        primaryGenre: { type: [string, 'null'], maxLength: 500 }
        secondaryGenre: { type: [string, 'null'], maxLength: 500 }
        language: { type: [string, 'null'], maxLength: 500 }
        instagram: { type: [string, 'null'], maxLength: 500 }
        twitter: { type: [string, 'null'], maxLength: 500 }
        facebookUrl: { type: [string, 'null'], maxLength: 2048 }
        youtubeUrl: { type: [string, 'null'], maxLength: 2048 }
        soundcloudUrl: { type: [string, 'null'], maxLength: 2048 }
        websiteUrl: { type: [string, 'null'], maxLength: 2048 }
        wikipediaUrl: { type: [string, 'null'], maxLength: 2048 }
        allmusicUrl: { type: [string, 'null'], maxLength: 2048 }
        cLine: { type: [string, 'null'], maxLength: 500 }
        pLine: { type: [string, 'null'], maxLength: 500 }
        ddexId: { type: [string, 'null'], maxLength: 500 }
        musicbrainzId: { type: [string, 'null'], maxLength: 500 }
        isni: { type: [string, 'null'], maxLength: 500 }
      additionalProperties: false
    ReleaseInput:
      type: object
      additionalProperties: false
      description: All fields optional on PATCH. Unknown fields are rejected.
      properties:
        title: { type: string, maxLength: 200 }
        artistId: { type: [string, 'null'], description: An artist you own or manage }
        type:
          type: string
          enum: [SINGLE, EP, ALBUM]
          deprecated: true
          description: Ignored. The type is derived from the track count (1–2 tracks SINGLE, 3–7 EP, 8+ ALBUM) when tracks are saved and again on submit. Accepted for compatibility.
        genre: { type: [string, 'null'] }
        subgenre: { type: [string, 'null'] }
        label: { type: [string, 'null'], description: Applied only for Label plans; revenue-share labels always release as DistroVibe }
        cLine: { type: [string, 'null'] }
        pLine: { type: [string, 'null'] }
        upc: { type: [string, 'null'], pattern: '^\d{12,13}$' }
        releaseDate: { type: [string, 'null'], format: date }
        originalReleaseDate: { type: [string, 'null'], format: date }
        additionalArtists: { type: array, maxItems: 20, items: { type: object, properties: { name: { type: string }, id: { type: string }, type: { type: string } }, required: [name] } }
        isCoverSong: { type: boolean }
        coverSongs: { type: array, maxItems: 50, items: { type: object } }
        coverSongFileUrl: { type: [string, 'null'], description: url from a completed document upload }
        isAiGenerated: { type: boolean }
        aiDocumentationUrl: { type: [string, 'null'], description: url from a completed document upload }
        platforms: { type: array, items: { type: string } }
        territories: { type: array, items: { type: string, pattern: '^[A-Z]{2}$' } }
        previewStart: { type: integer, minimum: 0 }
        coverArtUrl: { type: [string, 'null'], description: url from a completed cover_art upload }
        fastRelease: { type: boolean, description: Honoured for PRO and Label plans }
        tracks: { type: array, maxItems: 200, items: { $ref: '#/components/schemas/TrackInput' }, description: Create only }
    TrackInput:
      type: object
      additionalProperties: false
      properties:
        title: { type: string, maxLength: 200 }
        version: { type: [string, 'null'] }
        audioUrl: { type: [string, 'null'], description: url from a completed release_audio upload }
        duration: { type: [integer, 'null'], description: Seconds }
        isrc: { type: [string, 'null'], description: Your own ISRC; DistroVibe (GXLV9) codes are assigned at distribution }
        explicit: { type: boolean }
        language: { type: [string, 'null'] }
        lyrics: { type: [string, 'null'] }
        contributors: { type: array, maxItems: 50, items: { type: object, required: [name, role], properties: { name: { type: string }, role: { type: string }, type: { type: string } } } }
        volumeNumber: { type: integer, minimum: 1 }
    DraftReleaseResponse:
      type: object
      properties:
        release: { type: object, additionalProperties: true }
    CompositionInput:
      type: object
      required: [title, writers]
      properties:
        title: { type: string }
        iswc: { type: string }
        lyrics: { type: string }
        isrc: { type: string }
        performerName: { type: string }
        writers:
          type: array
          minItems: 1
          maxItems: 20
          items:
            type: object
            required: [name, share]
            properties:
              name: { type: string }
              share: { type: number, description: Percent; all writers total 100 }
              ipi: { type: string }
              proAffiliation: { type: string }
              collecting: { type: boolean }
        recordings: { type: array, items: { type: object } }
    WebhookInput:
      type: object
      properties:
        url: { type: string, format: uri }
        events: { type: array, items: { type: string, enum: [release.submitted, release.status_changed, composition.submitted, composition.status_changed, team.member_invited, team.member_removed, artist.created, artist.updated, upload.completed, upload.failed, royalties.statement_available] } }
        description: { type: string, maxLength: 500 }
    Pagination:
      type: object
      properties:
        page: { type: integer }
        limit: { type: integer }
        totalCount: { type: integer }
        totalPages: { type: integer }
    ApiError:
      type: object
      properties:
        error:
          type: object
          properties:
            code: { type: string }
            message: { type: string }
            status: { type: integer }
  responses:
    BadRequest: { description: Invalid input, content: { application/json: { schema: { $ref: '#/components/schemas/ApiError' } } } }
    Unauthorized: { description: Missing or invalid API key, content: { application/json: { schema: { $ref: '#/components/schemas/ApiError' } } } }
    Forbidden: { description: Application, plan, or scope does not permit access, content: { application/json: { schema: { $ref: '#/components/schemas/ApiError' } } } }
    RateLimited: { description: 'Per-account rate limit (60/min, shared by all keys), concurrency (3), or monthly quota exceeded', content: { application/json: { schema: { $ref: '#/components/schemas/ApiError' } } } }
    LimiterUnavailable: { description: Rate limits could not be checked; retry after the Retry-After interval, content: { application/json: { schema: { $ref: '#/components/schemas/ApiError' } } } }
