{
  "openapi": "3.1.0",
  "info": {
    "title": "MyIRL Streaming App Connections",
    "version": "0.1.0-design",
    "description": "Design contract. OAuth and API endpoints are not enabled. Approved apps and per-app ingest lease revocation are required before production."
  },
  "x-myirl-status": "design-contract-not-enabled",
  "servers": [
    {
      "url": "https://app.myirl.live/api/connect/v1"
    }
  ],
  "paths": {
    "/stations": {
      "get": {
        "summary": "List stations explicitly selected by the owner",
        "security": [
          {
            "MyIRLConnect": [
              "stations:read"
            ]
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "List stations explicitly selected by the owner"
          },
          "403": {
            "description": "Current ownership, consent, plan or allowance does not permit access"
          }
        }
      }
    },
    "/stations/{station_id}/feeds": {
      "get": {
        "summary": "List feed metadata without credentials or infrastructure",
        "security": [
          {
            "MyIRLConnect": [
              "feeds:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "station_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List feed metadata without credentials or infrastructure",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "feeds": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Feed"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current ownership, consent, plan or allowance does not permit access"
          }
        }
      }
    },
    "/stations/{station_id}/feeds/{feed_id}/connection-lease": {
      "post": {
        "summary": "Request an app-specific, expiring, revocable publishing lease",
        "security": [
          {
            "MyIRLConnect": [
              "ingest:connect"
            ]
          }
        ],
        "parameters": [
          {
            "name": "station_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "feed_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Request an app-specific, expiring, revocable publishing lease"
          },
          "403": {
            "description": "Current ownership, consent, plan or allowance does not permit access"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "MyIRLConnect": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://app.myirl.live/connect/authorize",
            "tokenUrl": "https://app.myirl.live/connect/token",
            "scopes": {
              "stations:read": "List approved stations",
              "feeds:read": "List feed choices, without secrets",
              "ingest:connect": "Request a revocable publishing lease"
            }
          }
        },
        "description": "Mandatory PKCE S256; no password grant or embedded login"
      }
    },
    "schemas": {
      "Feed": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "protocols",
          "profile"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "protocols": {
            "type": "array",
            "items": {
              "enum": [
                "srt",
                "rtmp"
              ]
            }
          },
          "profile": {
            "type": "object",
            "properties": {
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "fps": {
                "type": "integer"
              },
              "video_codec": {
                "type": "string"
              },
              "audio_codec": {
                "type": "string"
              },
              "max_video_bitrate_kbps": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  }
}