{
  "openapi": "3.1.0",
  "info": {"title": "Media List API", "version": "1.0.0", "description": "API for active paid accounts: search and read, and unlock emails with keys the owner allows to."},
  "servers": [{"url": "https://medialist.com/api/v1"}],
  "security": [{"bearerAuth": []}],
  "components": {
    "securitySchemes": {"bearerAuth": {"type": "http", "scheme": "bearer"}},
    "parameters": {
      "page": {"name": "page", "in": "query", "schema": {"type": "integer", "minimum": 1}},
      "per_page": {"name": "per_page", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 50}}
    },
    "schemas": {
      "Error": {"type": "object", "required": ["error"], "properties": {"error": {"type": "object", "required": ["code", "message", "docs_url"], "properties": {"code": {"type": "string"}, "message": {"type": "string"}, "docs_url": {"type": "string", "format": "uri"}}}}},
      "Contact": {"type": "object", "required": ["id", "name", "email", "email_locked", "email_preview"], "properties": {"id": {"type": "string"}, "name": {"type": "string"}, "title": {"type": ["string", "null"]}, "outlet": {"type": ["string", "null"]}, "outlet_domain": {"type": ["string", "null"]}, "location": {"type": ["string", "null"]}, "type": {"type": ["string", "null"]}, "topics": {"type": "array", "items": {"type": "string"}}, "email_verified": {"type": "boolean"}, "email": {"type": ["string", "null"]}, "email_locked": {"type": "boolean"}, "email_preview": {"type": ["string", "null"]}}},
      "ContactPage": {"type": "object", "required": ["data", "meta"], "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Contact"}}, "meta": {"type": "object", "required": ["page", "per_page", "total", "has_more"], "properties": {"page": {"type": "integer"}, "per_page": {"type": "integer"}, "total": {"type": "integer"}, "has_more": {"type": "boolean"}}}}},
      "Page": {"type": "object", "required": ["data", "meta"], "properties": {"data": {"type": "array"}, "meta": {"type": "object", "required": ["page", "per_page", "has_more"], "properties": {"page": {"type": "integer"}, "per_page": {"type": "integer"}, "has_more": {"type": "boolean"}}}}}
    }
  },
  "paths": {
    "/health": {"get": {"security": [], "responses": {"200": {"description": "Service available"}, "429": {"description": "Rate limited", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}},
    "/me": {"get": {"responses": {"200": {"description": "Account, plan, export and API limits, and unlock: {available, key_allowed, per_day} (whether this key can unlock emails)"}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Access not approved or paid plan paused", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}},
    "/facets": {"get": {"responses": {"200": {"description": "Search facet options"}}}},
    "/contacts": {"get": {"parameters": [
      {"name": "q", "in": "query", "schema": {"type": "string", "minLength": 2}}, {"$ref": "#/components/parameters/page"}, {"$ref": "#/components/parameters/per_page"},
      {"name": "title", "in": "query", "schema": {"type": "string", "minLength": 2}}, {"name": "outlet", "in": "query", "schema": {"type": "string", "minLength": 2}}, {"name": "location", "in": "query", "schema": {"type": "string", "minLength": 2}},
      {"name": "category", "in": "query", "schema": {"type": "string", "minLength": 2}}, {"name": "industry", "in": "query", "schema": {"type": "string", "minLength": 2}}, {"name": "beat", "in": "query", "schema": {"type": "string", "minLength": 2}},
      {"name": "topic", "in": "query", "schema": {"type": "string"}}, {"name": "state", "in": "query", "schema": {"type": "string", "pattern": "^[A-Z]{2}$"}}, {"name": "country", "in": "query", "schema": {"type": "string", "pattern": "^[A-Z]{2}$"}},
      {"name": "type", "in": "query", "schema": {"type": "string"}}, {"name": "media", "in": "query", "schema": {"type": "string"}}, {"name": "lang", "in": "query", "schema": {"type": "string"}}, {"name": "deliverable", "in": "query", "schema": {"type": "string", "enum": ["1"]}}, {"name": "audience", "in": "query", "description": "Minimum subscribers, YouTube channels only: applies only with type=youtube, ignored otherwise.", "schema": {"type": "string", "enum": ["1000", "10000", "100000", "1000000"]}}, {"name": "list", "in": "query", "schema": {"type": "string", "minLength": 2}}
    ], "responses": {"200": {"description": "Masked or unlocked contacts", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ContactPage"}}}}, "422": {"description": "Selective filter required", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate or daily row limit", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}},
    "/contacts/{id}": {"get": {"parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer", "minimum": 1}}], "responses": {"200": {"description": "Contact", "content": {"application/json": {"schema": {"type": "object", "required": ["data"], "properties": {"data": {"$ref": "#/components/schemas/Contact"}}}}}}, "404": {"description": "No sellable contact", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}},
    "/contacts/{id}/unlock": {"post": {"summary": "Unlock one contact's email", "description": "Unlocks the email of one contact, the same as Unlock in the dashboard. A contact your account already unlocked is free; a new one uses one export from your plan. Only API keys the account owner allowed to unlock can call this.", "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer", "minimum": 1}}], "responses": {"200": {"description": "Unlocked", "content": {"application/json": {"schema": {"type": "object", "required": ["data", "meta"], "properties": {"data": {"type": "object", "properties": {"id": {"type": "string"}, "email": {"type": "string"}, "already_unlocked": {"type": "boolean", "description": "true when no export was used"}}}, "meta": {"type": "object", "properties": {"exports_left": {"type": "integer"}}}}}}}}, "402": {"description": "no_exports_left: the plan's export allowance is used up for now", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "unlock_not_permitted (key not allowed or a connected app), unlock_not_available, plan_required", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "contact_not_found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "rate_limited or unlock_daily_limit", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}},
    "/outlets": {"get": {"parameters": [{"name": "q", "in": "query", "required": true, "schema": {"type": "string", "minLength": 2}}, {"$ref": "#/components/parameters/page"}, {"$ref": "#/components/parameters/per_page"}], "responses": {"200": {"description": "Outlet search", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Page"}}}}, "422": {"description": "q required", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}},
    "/lists": {"get": {"responses": {"200": {"description": "Owned lists"}}}},
    "/lists/{id}": {"get": {"parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}], "responses": {"200": {"description": "Owned list"}, "404": {"description": "Not found"}}}},
    "/lists/{id}/contacts": {"get": {"parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"$ref": "#/components/parameters/page"}, {"$ref": "#/components/parameters/per_page"}], "responses": {"200": {"description": "Owned list contacts", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ContactPage"}}}}, "404": {"description": "Not found"}}}},
    "/campaigns": {"get": {"responses": {"200": {"description": "Owned campaign summaries"}}}},
    "/campaigns/{id}": {"get": {"parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}], "responses": {"200": {"description": "Owned campaign"}, "404": {"description": "Not found"}}}}
  }
}
