{
 "openapi": "3.1.0",
 "info": {
  "title": "JobChanges.com Signals API",
  "version": "1.0.0",
  "description": "Look up anyone's latest job change, watch lists for changes, and clean records. Pre-release specification."
 },
 "servers": [
  {
   "url": "https://api.jobchanges.com/v1"
  }
 ],
 "security": [
  {
   "bearer": []
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "Person": {
    "type": "object",
    "properties": {
     "name": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "company": {
      "type": "string"
     },
     "email": {
      "type": "string",
      "format": "email"
     },
     "profile_url": {
      "type": "string"
     }
    }
   },
   "Job": {
    "type": "object",
    "properties": {
     "company": {
      "type": "string"
     },
     "domain": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "seniority": {
      "type": "string"
     },
     "started": {
      "type": "string",
      "format": "date"
     }
    }
   },
   "LookupResult": {
    "type": "object",
    "properties": {
     "match": {
      "type": "string",
      "enum": [
       "high",
       "medium",
       "low",
       "none"
      ]
     },
     "confidence": {
      "type": "number"
     },
     "changed": {
      "type": "boolean"
     },
     "change_type": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "new_hire",
       "promotion",
       "departure",
       null
      ]
     },
     "detected_at": {
      "type": "string",
      "format": "date"
     },
     "previous": {
      "$ref": "#/components/schemas/Job"
     },
     "current": {
      "$ref": "#/components/schemas/Job"
     },
     "contact": {
      "type": "object",
      "properties": {
       "work_email": {
        "type": "string"
       },
       "email_status": {
        "type": "string"
       },
       "mobile": {
        "type": "string"
       },
       "direct_dial": {
        "type": "string"
       },
       "dnc": {
        "type": "boolean"
       }
      }
     }
    }
   }
  }
 },
 "paths": {
  "/lookup": {
   "post": {
    "summary": "Latest job change for one person",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "allOf": [
         {
          "$ref": "#/components/schemas/Person"
         },
         {
          "type": "object",
          "properties": {
           "include": {
            "type": "array",
            "items": {
             "type": "string",
             "enum": [
              "email",
              "phone"
             ]
            }
           }
          }
         }
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/LookupResult"
        }
       }
      }
     }
    }
   }
  },
  "/lookup/bulk": {
   "post": {
    "summary": "Up to 10,000 lookups per call",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "people"
        ],
        "properties": {
         "people": {
          "type": "array",
          "maxItems": 10000,
          "items": {
           "$ref": "#/components/schemas/Person"
          }
         },
         "webhook_url": {
          "type": "string"
         },
         "include": {
          "type": "array",
          "items": {
           "type": "string",
           "enum": [
            "email",
            "phone"
           ]
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Results in input order",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "results": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/LookupResult"
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/people/{person_id}/history": {
   "get": {
    "summary": "Full job history",
    "parameters": [
     {
      "name": "person_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Job history",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "jobs": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Job"
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/monitors": {
   "post": {
    "summary": "Watch people or accounts; webhook on change",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "name",
         "webhook_url"
        ],
        "properties": {
         "name": {
          "type": "string"
         },
         "people": {
          "type": "array",
          "items": {
           "$ref": "#/components/schemas/Person"
          }
         },
         "accounts": {
          "type": "array",
          "items": {
           "type": "string",
           "description": "company domain"
          }
         },
         "events": {
          "type": "array",
          "items": {
           "type": "string",
           "enum": [
            "new_hire",
            "promotion",
            "departure",
            "new_leader"
           ]
          }
         },
         "webhook_url": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Monitor created"
     }
    }
   }
  },
  "/monitors/{id}/events": {
   "get": {
    "summary": "Changes detected on a watch list",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Events"
     }
    }
   }
  },
  "/refresh": {
   "post": {
    "summary": "Diagnose (dry_run) or clean a list; pay per researched record",
    "parameters": [
     {
      "name": "dry_run",
      "in": "query",
      "schema": {
       "type": "boolean"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "records": {
          "type": "array",
          "items": {
           "$ref": "#/components/schemas/Person"
          }
         },
         "job_id": {
          "type": "string"
         },
         "webhook_url": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Diagnosis or job status"
     }
    }
   }
  },
  "/usage": {
   "get": {
    "summary": "Usage and spend cap this month",
    "responses": {
     "200": {
      "description": "Usage"
     }
    }
   }
  }
 }
}