{
  "openapi": "3.1.0",
  "info": {
    "title": "Tesla Lock Sound Public API",
    "version": "1.0.0",
    "summary": "Read-only access to the Tesla Lock Sound catalog of custom LockChime.wav files.",
    "description": "The public, read-only half of teslalocksound.com. No API key, no account, no OAuth: every endpoint below is anonymous GET.\n\nUse it to search the catalog of Tesla lock sounds, read a single sound's metadata, list categories, and fetch the actual WAV file that installs on a Tesla USB drive as `Boombox/LockChime.wav`.\n\nEndpoints not listed here (submission, moderation, voting, cron, webhooks) are internal to the site and are not part of this contract; they may change without notice.\n\n## Versioning\n\nThe version is in the URL path. Pin `/api/v1/...` — that is the surface this document describes and the one that will keep its shape.\n\nThe unversioned `/api/...` paths resolve to the same handlers and are what the site's own client code calls. They are not versioned and are not part of this contract; an integration should use `/api/v1/`.\n\n## Deprecation policy\n\nA breaking change ships as a new major version beside the current one (`/api/v2/...`); `/api/v1/...` is never changed in place.\n\nWhen a version is scheduled for retirement its responses carry `Deprecation: true` and a `Sunset` header (RFC 8594) with the retirement date, at least 6 months out. Additive changes — a new optional field, a new endpoint — can land in v1 without notice, so parse defensively and ignore unknown fields.\n\n## Rate limiting\n\n60 requests per minute per client across all endpoints. Every response carries `RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset` (plus the legacy `X-RateLimit-*` names); a 429 adds `Retry-After`.\n\nCaveat: the list endpoints are shared-cached at the CDN, so on a cached response `RateLimit-Remaining` may reflect another client's budget. `RateLimit-Limit` and `RateLimit-Reset` always describe the policy; treat `Remaining` as advisory and rely on `Retry-After` when you are actually refused.\n\n## Errors\n\nEvery error is `application/json` — never an HTML page, including for an unrecognized `/api/` path. The body carries a stable `code` to branch on, a human-readable `message`, a `hint` naming the recovery step, and a `docs` URL.\n\n## Attribution\n\nSounds are free to download and install on your own vehicle. They are not licensed for redistribution or commercial use. Takedown requests go to dmca@teslalocksound.com.",
    "termsOfService": "https://teslalocksound.com/terms-of-service",
    "contact": {
      "name": "Tesla Lock Sound support",
      "email": "support@teslalocksound.com",
      "url": "https://teslalocksound.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://teslalocksound.com",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "Developer & agent documentation",
    "url": "https://teslalocksound.com/developers"
  },
  "tags": [
    {
      "name": "sounds",
      "description": "The lock sound catalog."
    },
    {
      "name": "categories",
      "description": "Catalog taxonomy."
    },
    {
      "name": "status",
      "description": "Service health."
    }
  ],
  "paths": {
    "/api/v1/sounds": {
      "get": {
        "tags": [
          "sounds"
        ],
        "operationId": "listSounds",
        "summary": "List and search lock sounds",
        "description": "Paginated catalog listing. Combine `search`, `category`, and `sort` to narrow it. Results are ordered by the requested sort key with a stable `id` tiebreaker, so paging never repeats or drops a row.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "1-based page number.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "description": "Rows per page. Values above 100 are clamped to 100.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Case-insensitive substring match against title and description. Max 100 characters. `q` is accepted as an alias.",
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "example": "vine boom"
          },
          {
            "name": "q",
            "in": "query",
            "description": "Alias for `search`.",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Exact category name, or a comma-separated union of up to 10 names. Names come from /api/categories.",
            "schema": {
              "type": "string",
              "maxLength": 400
            },
            "example": "Games,Modern Gaming"
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Sort key. Anything outside the enum falls back to `created_at`.",
            "schema": {
              "type": "string",
              "enum": [
                "created_at",
                "downloads",
                "title"
              ],
              "default": "created_at"
            }
          },
          {
            "name": "order",
            "in": "query",
            "description": "Sort direction. Only the literal `asc` selects ascending; anything else is descending.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of sounds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SoundListResponse"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Requests allowed per window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Requests left in the current window. Advisory on a CDN-cached response.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/sounds/{id}": {
      "get": {
        "tags": [
          "sounds"
        ],
        "operationId": "getSound",
        "summary": "Get one lock sound",
        "description": "Accepts either the sound's UUID or its URL slug. A sound removed for content moderation returns 404, identical to a sound that never existed.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The sound's UUID or its slug.",
            "schema": {
              "type": "string"
            },
            "example": "vine-boom"
          }
        ],
        "responses": {
          "200": {
            "description": "The sound.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SoundDetail"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Requests allowed per window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Requests left in the current window. Advisory on a CDN-cached response.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/api/v1/sounds/{id}/download-file": {
      "get": {
        "tags": [
          "sounds"
        ],
        "operationId": "downloadSoundFile",
        "summary": "Download the Tesla-ready WAV",
        "description": "Streams the audio as `LockChime.wav` — the exact file name a Tesla requires. Save it to the USB drive at `Boombox/LockChime.wav`. Unlike the other endpoints this one takes the UUID only, not the slug.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The sound's UUID. Slugs are rejected with 400.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The WAV file, with a Content-Disposition filename of LockChime.wav.",
            "content": {
              "audio/wav": {
                "schema": {
                  "$ref": "#/components/schemas/LockChimeAudio"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Requests allowed per window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Requests left in the current window. Advisory on a CDN-cached response.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "The id was not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/categories": {
      "get": {
        "tags": [
          "categories"
        ],
        "operationId": "listCategories",
        "summary": "List catalog categories",
        "description": "Every category name accepted by the `category` parameter of /api/sounds, sorted by name.",
        "responses": {
          "200": {
            "description": "All categories.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryListResponse"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Requests allowed per window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Requests left in the current window. Advisory on a CDN-cached response.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/health": {
      "get": {
        "tags": [
          "status"
        ],
        "operationId": "getHealth",
        "summary": "Service health",
        "description": "Liveness and dependency status. Returns 200 when healthy and 503 when a dependency is down.",
        "responses": {
          "200": {
            "description": "Healthy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Requests allowed per window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Requests left in the current window. Advisory on a CDN-cached response.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "503": {
            "description": "A dependency is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "NotFound": {
        "description": "No such resource.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "More than 60 requests in the last minute.",
        "headers": {
          "RateLimit-Limit": {
            "description": "Requests allowed per window.",
            "schema": {
              "type": "integer"
            }
          },
          "RateLimit-Remaining": {
            "description": "Requests left in the current window. Advisory on a CDN-cached response.",
            "schema": {
              "type": "integer"
            }
          },
          "RateLimit-Reset": {
            "description": "Seconds until the window resets.",
            "schema": {
              "type": "integer"
            }
          },
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Limit": {
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServerError": {
        "description": "Unexpected failure.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unavailable": {
        "description": "The catalog database is not reachable.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "Every non-2xx response from this API has this shape.",
        "required": [
          "error",
          "code",
          "message",
          "hint",
          "docs",
          "status"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable summary. Same text as `message`; kept for existing clients."
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable failure code. Branch on this.",
            "enum": [
              "invalid_request",
              "not_found",
              "rate_limited",
              "service_unavailable",
              "internal_error"
            ]
          },
          "message": {
            "type": "string",
            "description": "Human-readable summary."
          },
          "hint": {
            "type": "string",
            "description": "The concrete recovery step for this failure."
          },
          "docs": {
            "type": "string",
            "format": "uri",
            "description": "Where this contract is documented."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status, repeated in the body."
          }
        }
      },
      "Sound": {
        "type": "object",
        "required": [
          "id",
          "title",
          "category",
          "downloads",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "slug": {
            "type": [
              "string",
              "null"
            ],
            "description": "URL slug. Null for rows predating slug assignment."
          },
          "title": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "file_url": {
            "type": "string",
            "description": "Storage path or source URL. Prefer `audioUrl` for playback."
          },
          "downloads": {
            "type": "integer"
          },
          "duration": {
            "type": [
              "number",
              "null"
            ],
            "description": "Seconds. Historically unreliable for some rows; treat as advisory."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "waveform_data": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "number"
            },
            "description": "Amplitude buckets for rendering a waveform."
          },
          "compatible_models": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Tesla models this sound is offered for.",
            "example": [
              "Model 3",
              "Model Y",
              "Model S",
              "Model X",
              "Cybertruck"
            ]
          },
          "audioUrl": {
            "type": "string",
            "description": "Server-resolved playable URL. Omitted when resolution failed."
          }
        }
      },
      "SoundDetail": {
        "type": "object",
        "description": "A single sound with its full metadata. Superset of the list item.",
        "required": [
          "id",
          "title",
          "category",
          "downloads",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "slug": {
            "type": [
              "string",
              "null"
            ],
            "description": "URL slug. Null for rows predating slug assignment."
          },
          "title": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "file_url": {
            "type": "string",
            "description": "Storage path or source URL. Prefer `audioUrl` for playback."
          },
          "downloads": {
            "type": "integer"
          },
          "duration": {
            "type": [
              "number",
              "null"
            ],
            "description": "Seconds. Historically unreliable for some rows; treat as advisory."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "waveform_data": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "number"
            },
            "description": "Amplitude buckets for rendering a waveform."
          },
          "compatible_models": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Tesla models this sound is offered for.",
            "example": [
              "Model 3",
              "Model Y",
              "Model S",
              "Model X",
              "Cybertruck"
            ]
          },
          "audioUrl": {
            "type": "string",
            "description": "Server-resolved playable URL. Omitted when resolution failed."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the sound actually is, in a few words."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SoundListResponse": {
        "type": "object",
        "required": [
          "sounds",
          "total",
          "page",
          "per_page"
        ],
        "properties": {
          "sounds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Sound"
            }
          },
          "total": {
            "type": "integer",
            "description": "Total rows matching the filters."
          },
          "page": {
            "type": "integer"
          },
          "per_page": {
            "type": "integer"
          }
        }
      },
      "Category": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CategoryListResponse": {
        "type": "object",
        "required": [
          "categories"
        ],
        "properties": {
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          }
        }
      },
      "Health": {
        "type": "object",
        "description": "Liveness plus per-dependency status and the deployed commit.",
        "required": [
          "status",
          "timestamp",
          "version",
          "checks"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "healthy",
              "degraded",
              "unhealthy"
            ],
            "description": "Overall verdict. `unhealthy` is the only value served with a 503."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "version": {
            "type": "string",
            "description": "Deployed commit SHA, first 7 characters. `local` outside Vercel."
          },
          "checks": {
            "type": "object",
            "description": "Per-dependency detail.",
            "required": [
              "database",
              "environment",
              "rateLimit"
            ],
            "properties": {
              "database": {
                "type": "object",
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "ok",
                      "degraded",
                      "error"
                    ]
                  },
                  "latency": {
                    "type": "integer",
                    "description": "Round-trip milliseconds."
                  }
                }
              },
              "environment": {
                "type": "object",
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "ok",
                      "error"
                    ]
                  }
                }
              },
              "rateLimit": {
                "type": "object",
                "required": [
                  "distributed"
                ],
                "properties": {
                  "distributed": {
                    "type": "boolean",
                    "description": "True when the Redis-backed limiter is reachable; false means the in-memory fallback is in use."
                  }
                }
              }
            }
          }
        }
      },
      "LockChimeAudio": {
        "type": "string",
        "format": "binary",
        "description": "The raw WAV bytes, delivered with a Content-Disposition filename of LockChime.wav. Write them to the USB drive at Boombox/LockChime.wav."
      }
    }
  }
}
