{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nopaque-co-uk/json-schema/nopaque-co-uk-audio-object-schema.json",
  "title": "AudioObject",
  "description": "Audio metadata record returned by `GET /audio`, `GET /audio/{id}`. The\nbytes themselves live in S3 — fetch via `GET /audio/download-url?id=`.\n",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nopaque-co-uk-audio-api-openapi.yml#/components/schemas/AudioObject",
  "type": "object",
  "required": [
    "id",
    "workspaceId",
    "category",
    "associatedId",
    "filename",
    "s3Key",
    "contentType",
    "sizeBytes",
    "createdAt",
    "createdBy"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Audio metadata identifier."
    },
    "workspaceId": {
      "type": "string",
      "format": "uuid",
      "description": "Workspace that owns this audio."
    },
    "category": {
      "$ref": "#/$defs/AudioCategory"
    },
    "associatedId": {
      "type": "string",
      "description": "Owning entity id — `runId` for `test`/`map` category, `voiceId` for `voice`\ncategory. Defaults to the audio id when no parent is supplied at upload time.\n"
    },
    "filename": {
      "type": "string",
      "description": "Original client-supplied filename (sanitised for the S3 key)."
    },
    "s3Key": {
      "type": "string",
      "description": "S3 object key inside the audio bucket. Treat as opaque and never rebuild it from\nother fields: new uploads get a key that is unique per upload, while rows created\nbefore that change keep their original key.\n"
    },
    "contentType": {
      "type": "string",
      "description": "MIME type captured at upload time."
    },
    "sizeBytes": {
      "type": "integer",
      "minimum": 0,
      "description": "Declared object size in bytes. Rows created before `sizeBytes` became required\non upload may hold 0.\n"
    },
    "durationSecs": {
      "type": "number",
      "description": "Audio duration in seconds (optional — may be 0 or absent)."
    },
    "format": {
      "type": "string",
      "description": "Lowercase file extension derived from filename. Optional."
    },
    "sampleRate": {
      "type": "integer",
      "description": "Sample rate in Hz, when known."
    },
    "channels": {
      "type": "integer",
      "description": "Channel count (1=mono, 2=stereo), when known."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO-8601 timestamp of metadata creation."
    },
    "createdBy": {
      "type": "string",
      "description": "User id that initiated the upload."
    },
    "expiresAt": {
      "type": "integer",
      "description": "Optional TTL (epoch seconds). Audio with `expiresAt` will be auto-deleted by\nDynamoDB TTL — present only on ephemeral/test audio.\n"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": true,
      "description": "Arbitrary client-supplied metadata captured at upload time."
    }
  },
  "$defs": {
    "AudioCategory": {
      "type": "string",
      "enum": [
        "test",
        "map",
        "voice",
        "transcript"
      ],
      "description": "Bucket used by the upload-URL handler to derive the S3 key. Audio files\nfor test runs live under `tests/`, mapping recordings under `maps/`, voice\nprofiles under `voices/`, and transcript audio under `transcripts/`.\n"
    }
  }
}