{
  "openapi": "3.1.0",
  "info": {
    "title": "HiveRef API",
    "version": "1.0.0",
    "summary": "Reference checks for hiring teams: read checks, send candidate referee requests and subscribe to check events.",
    "description": "The HiveRef public API, used by the HiveRef Zapier and Make apps and for direct integrations.\n\nEvery request is scoped to the HiveRef organisation that owns the API key. Keys are created by an organisation admin in HiveRef under Settings > API (`/dashboard/settings/api`) and look like `hr_live_` followed by 32 hex characters. Send the key as `Authorization: Bearer <key>` (preferred) or `X-API-KEY: <key>`.\n\nCandidate emails that HiveRef does not know are returned as `null`. Referee answers and report contents are never returned by this API; responses link back to the report in HiveRef instead.\n\nThe same handlers are also served under `/api/zapier`, which the Zapier app uses.",
    "contact": {
      "name": "HiveRef support",
      "url": "https://www.hiveref.com/contact"
    },
    "termsOfService": "https://www.hiveref.com/terms"
  },
  "externalDocs": {
    "description": "API guide",
    "url": "https://www.hiveref.com/integrations/make"
  },
  "servers": [
    {
      "url": "https://www.hiveref.com/api/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerApiKey": []
    },
    {
      "headerApiKey": []
    }
  ],
  "tags": [
    {
      "name": "Account",
      "description": "Check the key and see which organisation it belongs to."
    },
    {
      "name": "Checks",
      "description": "Reference checks in the key's organisation."
    },
    {
      "name": "Templates",
      "description": "Question templates a new check can use."
    },
    {
      "name": "Webhooks",
      "description": "REST hook subscriptions for check events (Zapier and Make hook URLs only)."
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "tags": ["Account"],
        "summary": "Test the API key",
        "description": "Returns the organisation the API key belongs to. Use it to test a connection.",
        "responses": {
          "200": {
            "description": "The key is valid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/checks/recent": {
      "get": {
        "operationId": "listRecentChecks",
        "tags": ["Checks"],
        "summary": "List recent checks",
        "description": "Up to 50 of the organisation's newest checks of any status (drafts included), newest `created_at` first. Takes no parameters.",
        "responses": {
          "200": {
            "description": "Checks, newest first. Empty array when there are none.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "maxItems": 50,
                  "items": {
                    "$ref": "#/components/schemas/CheckSummary"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/checks/completed": {
      "get": {
        "operationId": "listCompletedChecks",
        "tags": ["Checks"],
        "summary": "List completed checks",
        "description": "Up to 50 of the organisation's completed checks, newest `completed_at` first. Takes no parameters.",
        "responses": {
          "200": {
            "description": "Completed checks, newest first. Empty array when there are none.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "maxItems": 50,
                  "items": {
                    "$ref": "#/components/schemas/CompletedCheck"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/checks": {
      "post": {
        "operationId": "sendCandidateRefereeRequest",
        "tags": ["Checks"],
        "summary": "Send a candidate referee request",
        "description": "Creates a reference check in candidate self-service mode and emails the candidate a secure link to add their referees. This uses one of the organisation's reference checks, exactly as creating a check in the dashboard does.\n\nThe check is created as the HiveRef member who generated the API key (keys created before 30 Oct 2026 act as the organisation's primary account owner). That member must be active and allowed to create checks, and the organisation must have finished compliance setup.\n\nRate limits: 30 requests per organisation per minute and 300 per day.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendCandidateRequestInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The check was created and the candidate email is being sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CandidateRequestCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, a field failed validation, the question template was not found, or a question failed the compliance scan. `field` names the field when there is one (`custom_questions` for a custom question).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The key's member is inactive or cannot create checks, compliance setup is unfinished, or the organisation has no reference checks left.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 30 checks were sent by this organisation in the last minute, or 300 in the last day.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "description": "The rate limiter or HiveRef's question compliance check is unavailable, so nothing was sent. Try again shortly.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/questions/suggest": {
      "post": {
        "operationId": "suggestReferenceQuestions",
        "tags": ["Checks"],
        "summary": "Suggest reference questions from a job description",
        "description": "Suggests reference-check questions for a role using the same question writer as the dashboard. Creates and sends nothing: show the questions to the user to edit, then send the agreed list with `POST /checks` `custom_questions`, which runs the compliance scan.\n\nRate limits: 10 requests per organisation per minute and 100 per day.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SuggestQuestionsInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Suggested questions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuggestedQuestions"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or a field failed validation. `field` names it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "description": "More than 10 suggestions for this organisation in the last minute, or 100 in the last day.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "description": "The question writer or the rate limiter is unavailable. Try again shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/prefill": {
      "post": {
        "operationId": "buildWizardLink",
        "tags": ["Checks"],
        "summary": "Build a pre-filled check wizard link",
        "description": "Returns a link to the HiveRef single-check wizard with the candidate's details filled in. Creates nothing and sends nothing; a HiveRef user opens the link and finishes the check.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrefillInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The wizard link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrefillResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or a field failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/question-templates": {
      "get": {
        "operationId": "listQuestionTemplates",
        "tags": ["Templates"],
        "summary": "List question templates",
        "description": "HiveRef's role templates (names start with \"HiveRef: \") followed by the organisation's saved, non-archived templates, most recently updated first. If the organisation's templates cannot be loaded, the HiveRef templates are still returned.",
        "responses": {
          "200": {
            "description": "Templates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QuestionTemplate"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/hooks": {
      "post": {
        "operationId": "subscribeWebhook",
        "tags": ["Webhooks"],
        "summary": "Subscribe to a check event",
        "description": "Registers a hook URL to receive `check_created` or `check_completed` events for the organisation. Only `https://hooks.zapier.com/...` and Make hook URLs (`https://hook.<zone>.make.com/...`, for example `hook.eu1.make.com`) on the default port are accepted. Subscribing the same event and URL again returns the existing subscription.\n\nDeliveries are a JSON POST with a 10 second timeout, no retries and no signature. A `410 Gone` reply removes the subscription.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HookSubscribeInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The subscription (new or existing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HookSubscription"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, unknown `event_type`, or a `target_url` that is not a Zapier or Make hook URL.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "callbacks": {
          "checkEvent": {
            "{$request.body#/target_url}": {
              "post": {
                "summary": "Check event delivery",
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "oneOf": [
                          {
                            "$ref": "#/components/schemas/CheckCreatedEvent"
                          },
                          {
                            "$ref": "#/components/schemas/CompletedCheck"
                          }
                        ]
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "Received."
                  },
                  "410": {
                    "description": "The hook no longer exists; HiveRef deletes the subscription."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "unsubscribeWebhook",
        "tags": ["Webhooks"],
        "summary": "Unsubscribe",
        "description": "Removes a subscription by id. Idempotent: an id that is unknown or already removed still returns 200, with `already_removed: true`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["id"],
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "The subscription id returned when subscribing."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Removed, or already gone.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "already_removed": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or missing `id`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "`Authorization: Bearer hr_live_...`. Checked before X-API-KEY."
      },
      "headerApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-KEY"
      }
    },
    "headers": {
      "RetryAfter": {
        "description": "Seconds to wait before retrying.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "`Missing API key` when no key was sent, `Invalid API key` when it is unknown or revoked.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "missing": {
                "value": {
                  "error": "Missing API key"
                }
              },
              "invalid": {
                "value": {
                  "error": "Invalid API key"
                }
              }
            }
          }
        }
      },
      "ServerError": {
        "description": "Unexpected error. HiveRef is alerted.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Internal server error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "string",
            "description": "A message that can be shown to the user."
          }
        }
      },
      "FieldError": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "string"
          },
          "field": {
            "type": "string",
            "description": "The request field that caused the error, when there is one."
          }
        }
      },
      "Me": {
        "type": "object",
        "required": ["organisation_id", "organisation_name", "plan"],
        "properties": {
          "organisation_id": {
            "type": "string",
            "format": "uuid"
          },
          "organisation_name": {
            "type": "string",
            "description": "\"Unknown\" if the organisation has no name."
          },
          "plan": {
            "type": "string",
            "description": "Selected plan slug, or \"none\".",
            "examples": ["growth", "none"]
          }
        }
      },
      "CheckStatus": {
        "type": "string",
        "description": "Check status. Current values: `draft`, `awaiting_candidate_referees`, `invites_pending`, `in_progress`, `completed`, `cancelled`, `failed`, `consent_required`, `consent_withdrawn`. New values may be added; treat unknown ones as in progress.",
        "examples": ["draft", "invites_pending", "completed"]
      },
      "CheckSummary": {
        "type": "object",
        "required": [
          "id",
          "candidate_name",
          "candidate_email",
          "role_title",
          "status",
          "created_at",
          "organisation_id",
          "check_url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "candidate_name": {
            "type": ["string", "null"],
            "description": "Full name, else first and last name joined; null if unknown."
          },
          "candidate_email": {
            "type": ["string", "null"],
            "format": "email"
          },
          "role_title": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/CheckStatus"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "organisation_id": {
            "type": "string",
            "format": "uuid"
          },
          "check_url": {
            "type": "string",
            "format": "uri",
            "description": "The check's report page in HiveRef (sign-in required)."
          }
        }
      },
      "CompletedCheck": {
        "type": "object",
        "description": "Also the `check_completed` webhook payload.",
        "required": [
          "id",
          "candidate_name",
          "candidate_email",
          "role_title",
          "completed_at",
          "organisation_id",
          "report_url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "candidate_name": {
            "type": ["string", "null"]
          },
          "candidate_email": {
            "type": ["string", "null"],
            "format": "email"
          },
          "role_title": {
            "type": "string"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time"
          },
          "organisation_id": {
            "type": "string",
            "format": "uuid"
          },
          "report_url": {
            "type": "string",
            "format": "uri",
            "description": "The report in HiveRef (sign-in required)."
          }
        }
      },
      "CheckCreatedEvent": {
        "type": "object",
        "description": "The `check_created` webhook payload. Fires for dashboard-created checks (drafts included) and for checks sent through the API.",
        "required": [
          "id",
          "candidate_name",
          "candidate_email",
          "role_title",
          "status",
          "created_at",
          "organisation_id",
          "check_url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "candidate_name": {
            "type": ["string", "null"]
          },
          "candidate_email": {
            "type": ["string", "null"],
            "format": "email"
          },
          "role_title": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/CheckStatus"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "organisation_id": {
            "type": "string",
            "format": "uuid"
          },
          "check_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "SendCandidateRequestInput": {
        "type": "object",
        "required": [
          "candidate_first_name",
          "candidate_last_name",
          "candidate_email",
          "role_title"
        ],
        "properties": {
          "candidate_first_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "Trimmed before validation."
          },
          "candidate_last_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "candidate_email": {
            "type": "string",
            "format": "email",
            "maxLength": 254,
            "description": "Lower-cased. The candidate receives their secure link here."
          },
          "role_title": {
            "type": "string",
            "minLength": 2,
            "maxLength": 180
          },
          "target_referees_count": {
            "type": ["integer", "string", "null"],
            "minimum": 1,
            "maximum": 6,
            "default": 2,
            "description": "Whole number from 1 to 6. Omitted, null or an empty string means 2. Numeric strings are accepted."
          },
          "question_template_id": {
            "type": "string",
            "maxLength": 100,
            "default": "hiveref-general",
            "description": "An id from `GET /question-templates`. Omitted or blank means `hiveref-general`. Do not send together with `custom_questions`."
          },
          "custom_questions": {
            "type": "array",
            "minItems": 1,
            "maxItems": 40,
            "items": {
              "type": "string",
              "minLength": 5,
              "maxLength": 1000
            },
            "description": "Written questions to send instead of a template, for example from `POST /questions/suggest` after the user has reviewed them. Each becomes a required long-text question. They pass the same compliance scan as the dashboard; a question that fails returns 400 with `field: custom_questions` and its number in `error`. Send either this or `question_template_id`, not both."
          },
          "job_context": {
            "type": "string",
            "maxLength": 15000,
            "description": "Optional job description. Only used with `custom_questions`, to help the compliance scan judge them (the first 200 characters are used)."
          }
        }
      },
      "CandidateRequestCreated": {
        "type": "object",
        "required": [
          "id",
          "candidate_name",
          "candidate_email",
          "role_title",
          "status",
          "target_referees",
          "question_template",
          "created_at",
          "organisation_id",
          "check_url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "candidate_name": {
            "type": "string"
          },
          "candidate_email": {
            "type": "string",
            "format": "email"
          },
          "role_title": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "const": "invites_pending"
          },
          "target_referees": {
            "type": "integer",
            "minimum": 1,
            "maximum": 6
          },
          "question_template": {
            "type": "string",
            "description": "Name of the template used, or `Custom questions` when `custom_questions` were sent."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "organisation_id": {
            "type": "string",
            "format": "uuid"
          },
          "check_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "PrefillInput": {
        "type": "object",
        "required": [
          "candidate_first_name",
          "candidate_last_name",
          "role_title"
        ],
        "properties": {
          "candidate_first_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "candidate_last_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "candidate_email": {
            "type": "string",
            "format": "email",
            "maxLength": 254,
            "description": "Optional; blank is ignored."
          },
          "role_title": {
            "type": "string",
            "minLength": 2,
            "maxLength": 180
          }
        }
      },
      "PrefillResult": {
        "type": "object",
        "required": ["wizard_url", "candidate_name", "role_title"],
        "properties": {
          "wizard_url": {
            "type": "string",
            "format": "uri",
            "description": "`https://www.hiveref.com/dashboard/checks/new/single?prefill=<token>`. The token is opaque and encrypted, expires after 7 days, and only opens with the details for a signed-in member of the API key's organisation."
          },
          "candidate_name": {
            "type": "string"
          },
          "role_title": {
            "type": "string"
          }
        }
      },
      "QuestionTemplate": {
        "type": "object",
        "required": ["id", "name"],
        "properties": {
          "id": {
            "type": "string",
            "description": "A HiveRef template id (for example `hiveref-general`) or a saved template's UUID."
          },
          "name": {
            "type": "string"
          }
        }
      },
      "HookSubscribeInput": {
        "type": "object",
        "required": ["event_type", "target_url"],
        "properties": {
          "event_type": {
            "type": "string",
            "enum": ["check_created", "check_completed"]
          },
          "target_url": {
            "type": "string",
            "format": "uri",
            "description": "A `https://hooks.zapier.com/...` or `https://hook.<zone>.make.com/...` URL."
          }
        }
      },
      "HookSubscription": {
        "type": "object",
        "required": ["id", "event_type", "target_url", "created_at"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "event_type": {
            "type": "string",
            "enum": ["check_created", "check_completed"]
          },
          "target_url": {
            "type": "string",
            "format": "uri"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SuggestQuestionsInput": {
        "type": "object",
        "required": ["role_title", "job_description"],
        "properties": {
          "role_title": {
            "type": "string",
            "minLength": 2,
            "maxLength": 180,
            "description": "Must not contain links or email addresses."
          },
          "job_description": {
            "type": "string",
            "minLength": 20,
            "maxLength": 15000
          },
          "response_format": {
            "type": "string",
            "enum": ["long_text", "rating_1_10"],
            "default": "long_text",
            "description": "Answer type for every suggested question. `custom_questions` on `POST /checks` are always long text."
          }
        }
      },
      "SuggestedQuestions": {
        "type": "object",
        "required": ["role_title", "questions"],
        "properties": {
          "role_title": {
            "type": "string"
          },
          "questions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["prompt", "response_format", "question_type"],
              "properties": {
                "prompt": {
                  "type": "string"
                },
                "response_format": {
                  "type": "string",
                  "enum": ["long_text", "rating_1_10"]
                },
                "question_type": {
                  "type": "string",
                  "enum": ["factual", "evaluative"]
                }
              }
            }
          }
        }
      }
    }
  }
}
