All connectors
AssessFirst
Official
AssessFirst
Let agents follow assessment completion, read scores and reports, and compare candidates with your predictive models. Write also permits invitations, voice assessments, group changes and webhooks.
Completion status hides scores and reports but still exposes candidate names and emails. Assessment results are personal data; limit who can use the connection. Obtain consent before adding candidates without an invitation.
The token covers your company's data. Production and test environments are supported; AssessFirst's API remains in open beta.
Setup instructions
Setup instructions
Connect AssessFirst
Requires an Administrator with a Recruiter licence and API access. AssessFirst keeps one token per company; coordinate with other integrations before replacing it.
- In AssessFirst, open your profile's Integration → AssessFirst API → Activate → Generate token. If unavailable, ask your AssessFirst contact to enable API access.
- Paste it into Houston's API token and choose Production.
- For Access, choose Read, Completion status to hide scores and reports, or Write for invitations and changes. Save the connection and share it only with people allowed to see candidate data.
Advanced
- Completion status still exposes names, email addresses, groups and predictive models. Group candidates in AssessFirst to track completion; the API has no campaigns. The token itself retains company-wide access.
- Writes: invitations send email. Obtain consent before adding a candidate without an invitation. Voice assessments and OnePager reports require their respective AssessFirst options.
- Sandbox: request access from AssessFirst support, create a token at simu.assessfirst.com and choose Test. Tokens work only in the environment where they were created.
Files
Files
connector.luau
-- AssessFirst API v2 (open beta). Arguments and results keep AssessFirst's native snake_case field names. type Options = {[string]: any} type Endpoint = {method: string, path: string, query: {string}?, body: {string}?, required: {string}?, array: boolean?, pdf: boolean?, access: string?, status: {string}?, about: string} local API = "https://" .. config.api_host .. "/betty-V2" -- The Completion status level keeps only the ungated status endpoints. local COMPLETION_ONLY = not houston.allows("data:read") local DOCS = "https://documenter.getpostman.com/view/12154847/2sB2qWGjNX" local NULL = json.decode("null") local NONE: {string} = table.freeze({}) local EVENTS = {"assessment.finished", "user.linked", "user.completed", "user.deleted"} local PREDICTIVE_REPORTS = {17, 18, 35} local PAGE = {"page", "per_page"} local CANDIDATE = {"email", "first_name", "last_name", "gender", "recruiter_email"} local function list(...: {string}): {string} local fields: {string} = {} for _, group in {...} do table.move(group, 1, #group, #fields + 1, fields) end return fields end -- Paths are relative to API. Only GET reads; path {fields}, query and body fields come from one options object. -- access names the level a record needs; status lists the fields the Completion status level keeps of an ungated record. local endpoints: {[string]: Endpoint} = { listLocales = {method = "GET", path = "/locales", access = "data:read", array = true, about = "Languages the API speaks: {{name, iso_code_639, flag}}. Pass iso_code_639 as locale."}, listRecruiters = {method = "GET", path = "/recruiters", access = "data:read", query = list({"uuid", "email"}, PAGE), about = "Recruiters of your company: {data={{uuid, first_name, last_name, email, created_at}}, meta}. email matches partially."}, listCandidates = {method = "GET", path = "/candidates", query = list({"uuid", "email"}, PAGE), status = {"uuid", "first_name", "last_name", "email", "created_at"}, about = "Candidates available to your company: {data={{uuid, first_name, last_name, email, created_at}}, meta}. email matches partially: pick the entry whose email equals the address."}, getCandidate = {method = "GET", path = "/candidate/{candidate_uuid}", access = "data:read", about = "A candidate: {uuid, email, first_name, last_name, locale, status, aplayer_score, remote_score, candidate_url, assessments={{id, name, status, end_date}}}. Assessment ids are not report_ids."}, listCandidateReports = {method = "GET", path = "/candidate/{candidate_uuid}/reports", access = "data:read", array = true, about = "Reports available for the candidate: {{id, name, assessment, web_link}}; web_link opens the report on AssessFirst's report site."}, downloadCandidateReport = {method = "GET", path = "/candidate/{candidate_uuid}/report/{report_id}", access = "data:read", query = {"pm_uuid"}, pdf = true, about = "Saves a report PDF to the session file path and returns {path, size, url, contentType}; url is Houston's signed download link. report_id: 1, 2, 3 personality (Swipe) in-depth, summary, key behaviors; 13, 15 motivations (Drive) in-depth, summary; 8, 10 reasoning (Brain) in-depth, summary; 20 complete summary; 50 HR report; 51 report for recruiters and managers; 17, 18 fit with a predictive model, full and short; 35 voice. 17, 18 and 35 require pm_uuid."}, getCandidateAdequacies = {method = "GET", path = "/candidate/{candidate_uuid}/adequacies/{pm_uuid}", access = "data:read", about = "Fit with a predictive model: {adequacies={global_adequacy, success_adequacy, fulfillment_adequacy, adequacy_shape, adequacy_drive, adequacy_brain} (percentages), reports={{id, name, web_link}}, voice={{score, status, skill_label, skill_definition, skill_type, skill_level, user_level, web_link}}, predict_success_url}. predict_success_url opens the fit in AssessFirst for signed-in recruiters."}, getCandidateCompletion = {method = "GET", path = "/candidate/{candidate_uuid}/completion", query = {"pm_uuid"}, status = {"assessments", "is_completed"}, about = "Which assessments are done: {assessments={swipe='finish', drive='finish', voice='todo', ...}, is_completed}. Checked against pm_uuid's assessments, or your company's default set without it. Check each assessment's status: is_completed can be true while voice is still todo."}, getCandidateScores = {method = "GET", path = "/candidate/{candidate_uuid}/scores", access = "data:read", array = true, about = "Scores for every AssessFirst dimension: {{id, label, name, score, min, max}}. Scales differ by dimension (1..10, 0..100, -4..4, ...), so read each item's min and max; name can be null and scores decimal."}, getCandidateSynthesis = {method = "GET", path = "/candidate/{candidate_uuid}/synthesis", access = "data:read", about = "Written synthesis of the Swipe (as shape), Drive and Brain results: categories and behaviours with labels, descriptions, scores, success and fulfillment tips. Large."}, getCandidateTopCareers = {method = "GET", path = "/candidate/{candidate_uuid}/career/top", access = "data:read", query = {"type"}, about = "The 10 jobs that best match the candidate. type='full' is the only documented value."}, getCandidateOnePager = {method = "GET", path = "/onepager/candidate/{candidate_uuid}/results", access = "data:read", query = {"pm_uuid"}, about = "A OnePager library link whose token, valid for 15 minutes, lets anyone who has it open all the candidate's reports without signing in; share it only with people entitled to see them. AssessFirst enables OnePager per company."}, getVoiceStatus = {method = "GET", path = "/candidate/{candidate_uuid}/init-voice/{pm_uuid}", access = "data:read", about = "The candidate's voice assessment for a voice predictive model: {uuid, candidate_uuid, predictive_model_uuid}. Needs AssessFirst's Voice option."}, listPredictiveModels = {method = "GET", path = "/predictive-models", query = list({"name", "uuid", "is_public"}, PAGE), status = {"uuid", "name", "assessments", "is_public", "created_at"}, about = "Your predictive models, the job profiles candidates are matched against: {data={{uuid, name, assessments={swipe, drive, brain, voice}, is_public, created_at}}, meta}. name matches partially. Create and edit them in AssessFirst."}, listBenchmarks = {method = "GET", path = "/benchmarks", access = "data:read", query = {"name"}, about = "AssessFirst's library of benchmark predictive models by job title: {data={{uuid, name, assessments, created_at}}}. name matches partially."}, listWebhooks = {method = "GET", path = "/webhooks", access = "data:read", query = list({"name", "url", "actions"}, PAGE), about = "Your webhooks: {data={{uuid, name, url, actions, created_at}}, meta}. name and url match partially; actions filters by an array of events."}, listGroups = {method = "GET", path = "/groups", query = PAGE, status = {"uuid", "label", "color", "created_at"}, about = "Candidate groups: {data={{uuid, label, color, created_at}}, meta}. Paging here is undocumented: stop if meta.current_page is not the page you asked for."}, listGroupUsers = {method = "GET", path = "/groups/{group_uuid}/users", query = PAGE, status = {"uuid", "first_name", "last_name", "email"}, about = "Candidates in a group: {data={{uuid, first_name, last_name, email}}, meta}. Paging here is undocumented: stop if meta.current_page is not the page you asked for."}, sendInvitation = {method = "POST", path = "/candidate/send-invitation", access = "data:write", body = list(CANDIDATE, {"message", "predictive_model_uuid"}), required = {"email"}, about = "AssessFirst emails the candidate an invitation to take the assessments, or to share existing results with your company. gender is 'f', 'n' (default) or 'm'; recruiter_email defaults to your company's ATS recruiter; message is added to the email; predictive_model_uuid (recommended) picks the assessments and starts voice when the model has it. Returns {uuid, last_invited_at, status}: invitation_sent, ask_share, reminder_sent, assessment_reminder, already_completed, added_to_network, or user_already_invited_24_hours_ago (one invitation per email address a day)."}, createCandidate = {method = "POST", path = "/candidate", access = "data:write", body = CANDIDATE, required = {"email"}, about = "Adds a candidate to your company without asking them; you are responsible for their GDPR consent. Returns {uuid, status}: added_to_network or already_in_sharepool."}, startVoiceAssessment = {method = "POST", path = "/candidate/{candidate_uuid}/init-voice/{pm_uuid}", access = "data:write", about = "Creates the candidate's voice assessment for a voice predictive model; sendInvitation with predictive_model_uuid already does this. Returns {uuid, candidate_uuid, predictive_model_uuid}."}, createWebhook = {method = "POST", path = "/webhooks", access = "data:write", body = {"name", "url", "actions"}, required = {"name", "url", "actions"}, about = "actions is an array of assessment.finished, user.linked, user.completed and user.deleted. AssessFirst then POSTs {data={user={uuid, email, assessment?}}, webhook={uuid, name, action}} to url, a receiver you control. AssessFirst documents no payload signature, so the receiver should read the candidate again rather than trust the payload. AssessFirst recommends assessment.finished and user.linked, then getCandidateCompletion on each event; candidates who were already_completed or added_to_network send none. Returns {uuid, name, url, actions}."}, deleteWebhook = {method = "DELETE", path = "/webhooks/{webhook_uuid}", access = "data:write", about = "Deletes a webhook."}, createGroup = {method = "POST", path = "/groups", access = "data:write", body = {"label", "color"}, required = {"label"}, about = "Creates a candidate group; color is hex such as '#000000'. Returns the group with its uuid."}, deleteGroup = {method = "DELETE", path = "/groups/{group_uuid}", access = "data:write", about = "Deletes a group."}, addGroupUser = {method = "POST", path = "/groups/{group_uuid}/user/{user_uuid}", access = "data:write", about = "Adds a candidate to a group. Returns {user, group}."}, removeGroupUser = {method = "DELETE", path = "/groups/{group_uuid}/user/{user_uuid}", access = "data:write", about = "Removes a candidate from a group."}, } local function options(input: Options?): Options if input == nil then return {} end assert(type(input) == "table", "opts must be an object") for key in input do assert(type(key) == "string", "opts must have named fields") end return table.clone(input) end local function text(value: any, field: string): string assert(type(value) == "string" and value ~= "", field .. " must be a nonempty string") return value end -- AssessFirst UUIDs are hexadecimal, usually 32 characters without dashes. local function uuid(value: any, field: string): string assert(type(value) == "string" and #value <= 64 and string.match(value, "^[%x%-]+$"), field .. " must be an AssessFirst UUID") return value end local function integer(value: any, field: string, maximum: number): number assert(type(value) == "number" and value % 1 == 0 and value >= 1 and value <= maximum, field .. " must be an integer from 1 to " .. string.format("%d", maximum)) return value end local function events(value: any, field: string): {string} assert(type(value) == "table" and #value > 0, field .. " must be a nonempty array of events") local count = 0 for _, event in value do count += 1 assert(table.find(EVENTS, event), field .. " must contain only " .. table.concat(EVENTS, ", ")) end assert(count == #value, field .. " must be an array, not an object") return value end -- Each query or body value as AssessFirst expects it; other fields are nonempty strings. local FIELDS: {[string]: (any, string) -> any} = { uuid = uuid, pm_uuid = uuid, predictive_model_uuid = uuid, actions = events, page = function(value: any, field: string): any return integer(value, field, 1e9) end, per_page = function(value: any, field: string): any return integer(value, field, 50) end, is_public = function(value: any, field: string): any assert(type(value) == "boolean", field .. " must be a boolean") return if value then 1 else 0 end, gender = function(value: any, field: string): any assert(value == "f" or value == "n" or value == "m", field .. " must be 'f', 'n' or 'm'") return value end, locale = function(value: any, field: string): any assert(type(value) == "string" and #value <= 16 and string.match(value, "^%a%a[%w%-]*$"), field .. " must be a locale such as 'fr-FR'") return value end, } local function check(field: string, value: any): any local validate = FIELDS[field] if validate then return validate(value, field) end return text(value, field) end -- Withheld from every response and error: the iframe token takes assessments as the candidate, and an -- sso parameter, such as predict_success_url's, signs in whoever opens the link. local function withhold(value: any) if type(value) ~= "table" then return end for key, item in value do if key == "iframe_candidate_token" then value[key] = nil elseif type(item) == "string" and string.find(item, "sso=", 1, true) then local link, removed = string.gsub(item, "[?&]sso=[^&#]*", "") -- Removing the first parameter leaves the next one after an &. if removed > 0 and not string.find(link, "?", 1, true) then link = string.gsub(link, "&", "?", 1) end value[key] = link else withhold(item) end end end -- A Completion status connection returns only the listed fields of a record, or of each record of a -- list, so a result AssessFirst adds to these answers stays out. local function keep(value: any, fields: {string}): any local function record(item: any): Options local kept: Options = {} if type(item) == "table" then for _, field in fields do kept[field] = item[field] end end return kept end if type(value.data) ~= "table" then return record(value) end for index, item in value.data do value.data[index] = record(item) end return {data = value.data, meta = value.meta} end local function fail(name: string, response: HttpResponse, message: string, retryable: boolean?): never return houston.fail({operation = name, layer = "upstream", upstream_status = response.statusCode, retryable = retryable == true, message = message}) end -- AssessFirst errors are {code, message, data, status}; validation errors may add errors={field={...}}. local function failStatus(name: string, endpoint: Endpoint, response: HttpResponse): never local ok, value = pcall(json.decode, await(response.body:readPrefix(16 * 1024))) local message = "AssessFirst HTTP " .. tostring(response.statusCode) local revoked = false if ok and type(value) == "table" then withhold(value) if type(value.message) == "string" then message ..= ": " .. string.sub(value.message, 1, 600) end if type(value.errors) == "table" then message ..= " " .. string.sub(json.encode(value.errors), 1, 600) end revoked = response.statusCode == 500 and value.message == "an error occured" if revoked then message ..= " (AssessFirst also answers this way when the API token is invalid or revoked; check the token and the connection's Environment)" end end local retry = response.headers["retry-after"] if retry and retry[1] then message ..= "; Retry-After: " .. retry[1] end -- A throttled request was refused; a failed write may already have applied, and a revoked token stays revoked. local retryable = response.statusCode == 429 or (response.statusCode >= 500 and endpoint.method == "GET" and not revoked) return fail(name, response, message, retryable) end local function download(name: string, endpoint: Endpoint, response: HttpResponse, path: string): Options local contentType = (response.headers["content-type"] or NONE)[1] or "" local mediaType = string.lower(string.match(contentType, "^%s*([^;%s]*)") or "") -- A report that cannot be produced is explained in JSON; other types are sign-in or error pages. PHP labels PDFs variously. if string.find(mediaType, "json", 1, true) then failStatus(name, endpoint, response) end if not (string.find(mediaType, "pdf", 1, true) or mediaType == "application/octet-stream" or mediaType == "application/force-download") then response.body:close() fail(name, response, "AssessFirst returned " .. (if mediaType == "" then "an untyped response" else mediaType) .. " instead of a PDF") end local file = fs.open(path, "w") file:write(response.body) await(file:close()) return {path = path, size = await(fs.stat(path)).size, url = await(fs.signedGetUrl(path)), contentType = contentType} end local function decode(name: string, endpoint: Endpoint, response: HttpResponse): any local raw = await(response.body:readAll()) if endpoint.method ~= "GET" and string.match(raw, "^%s*$") then return {} end local ok, value = pcall(json.decode, raw) local array = string.match(raw, "^%s*%[") ~= nil -- PHP encodes an empty object as [], so only array endpoints insist on the shape. if not ok or type(value) ~= "table" or (endpoint.array and not array) then fail(name, response, "AssessFirst returned an invalid JSON " .. (if endpoint.array then "array" else "object")) end withhold(value) if COMPLETION_ONLY then return keep(value, endpoint.status or NONE) end return value end local function request(name: string, endpoint: Endpoint, input: Options?): any local args = options(input) if endpoint.pdf and table.find(PREDICTIVE_REPORTS, args.report_id) then assert(args.pm_uuid ~= nil and args.pm_uuid ~= NULL, "report_id " .. tostring(args.report_id) .. " requires pm_uuid") end for _, field in endpoint.required or NONE do assert(args[field] ~= nil and args[field] ~= NULL, field .. " is required") end local path = string.gsub(endpoint.path, "{([%w_]+)}", function(field: string) local value = if field == "report_id" then string.format("%d", integer(args[field], field, 9999)) else uuid(args[field], field) args[field] = nil return value end) local query: {string} = {} for _, field in list(endpoint.query or NONE, {"locale"}) do local value = args[field] args[field] = nil if value ~= nil and value ~= NULL then if field == "actions" then for _, event in events(value, field) do table.insert(query, "actions%5B%5D=" .. url.encode(event)) end else table.insert(query, field .. "=" .. url.encode(check(field, value))) end end end if #query > 0 then path ..= "?" .. table.concat(query, "&") end local destination: string? = nil if endpoint.pdf then destination = text(args.path, "path") args.path = nil end -- Like AssessFirst's examples, PDFs are requested with the default Accept; errors are JSON either way. local headers: HttpHeaders = if endpoint.pdf then {} else {Accept = {"application/json"}} local body: string? = nil if endpoint.body then local fields: Options = {} for _, field in endpoint.body do if args[field] ~= nil and args[field] ~= NULL then fields[field] = check(field, args[field]) end args[field] = nil end headers["Content-Type"] = {"application/json"} body = json.encode(fields) end local unknown = next(args) assert(unknown == nil, name .. " has no option " .. tostring(unknown)) local response = await(http.request({method = endpoint.method, url = API .. path, headers = headers, body = body})) if response.statusCode < 200 or response.statusCode >= 300 then failStatus(name, endpoint, response) end if destination then return download(name, endpoint, response, destination) end return decode(name, endpoint, response) end local function signature(endpoint: Endpoint): string local fields: {string} = {} for field in string.gmatch(endpoint.path, "{([%w_]+)}") do table.insert(fields, field) end if endpoint.pdf then table.insert(fields, "path") end for _, field in list(endpoint.query or NONE, endpoint.body or NONE) do table.insert(fields, if table.find(endpoint.required or NONE, field) then field else field .. "?") end return "({" .. table.concat(fields, ", ") .. "})" end local exports: {[string]: any} = {} for name, endpoint in endpoints do if endpoint.access == nil or houston.allows(endpoint.access) then exports[name] = function(args: Options?): any return request(name, endpoint, args) end end end exports.help = function(): string local names: {string} = {} for name in exports do if name ~= "help" then table.insert(names, name) end end table.sort(names) local lines = { "AssessFirst API v2, an open beta AssessFirst may still change (" .. DOCS .. "). Every function takes one named options object with AssessFirst's snake_case names; ? marks optional fields. Every function also takes locale?, such as 'fr-FR' (default en-US" .. (if exports.listLocales then ", see listLocales" else "") .. "), for the language of returned text, reports and emails. Results are AssessFirst's JSON unchanged, except that the connector withholds iframe_candidate_token (it lets anyone take assessments as the candidate) and removes sso single sign-on parameters from links. Connector calls return completed values: use them directly, without await.", "Candidates, predictive models (pm_uuid, predictive_model_uuid), groups, users and webhooks have 32-character hexadecimal UUIDs; report_id is a number. Lists date records as 'YYYY-MM-DD hh:mm:ss'; writes may answer with ISO 8601 or Unix seconds. Swipe measures personality, Drive motivations and Brain reasoning; a predictive model scores candidates against a job.", "Paging: lists with page (from 1) and per_page (1..50) return {data, meta={total, current_page, per_page, previous_page, next_page, last_page}}, one page per call; continue while meta.current_page < meta.last_page.", "To follow a candidate: listCandidates({email='[email protected]'}) finds their uuid; getCandidateCompletion({candidate_uuid=uuid, pm_uuid=pm}) tells whether they finished" .. (if COMPLETION_ONLY then "" else "; then getCandidateAdequacies({candidate_uuid=uuid, pm_uuid=pm}), getCandidateScores({candidate_uuid=uuid}) or downloadCandidateReport({candidate_uuid=uuid, report_id=20, path='ana-summary.pdf'})") .. ". pm is a predictive model uuid from listPredictiveModels({name='Sales'}).", "Candidates' data is personal: share it only with people entitled to see it. Predictive models, campaigns, consents and API tokens are managed in the AssessFirst app.", "No automatic retries except Houston's for short 429 waits; AssessFirst allows about 100 requests a minute. Errors report the HTTP status and AssessFirst's message, and retryable is true only for 429 and for failed reads. AssessFirst also answers an invalid or revoked API token with HTTP 500 'an error occured', and probably a token from the other environment too: ask an administrator to check the connection's token and Environment rather than retrying.", } if config.api_host == "simu.assessfirst.com" then table.insert(lines, "This connection uses AssessFirst's test environment, " .. config.api_host .. ": its candidates and results are test data, not the company's production AssessFirst account.") end if COMPLETION_ONLY then table.insert(lines, 2, "This connection only follows assessment completion: it has just the functions below, and their records keep only the fields listed. Scores, synthesis, reports, fit with a predictive model and every change are out of reach, so do not offer them: they need another Access level, which a connection administrator sets. AssessFirst's API has no campaigns: follow candidates by group (listGroups, listGroupUsers({group_uuid=g}), then getCandidateCompletion for each candidate, one request each) or check them against a predictive model with pm_uuid.") elseif exports.sendInvitation then table.insert(lines, "To invite: sendInvitation({email='[email protected]', first_name='Ana', last_name='Silva', predictive_model_uuid=pm}) emails the candidate. Status ask_share means they already have an AssessFirst account and must accept to share their results with you; wait for that before reading them. createCandidate adds a person without asking them, so collect their consent first. Deletions return {}. After a timeout or 5xx, read the candidate, group or webhook again before repeating a write.") else table.insert(lines, "This connection is read-only: inviting candidates and managing groups and webhooks need Write access.") end for _, name in names do local endpoint = endpoints[name] table.insert(lines, name .. signature(endpoint) .. ": " .. endpoint.about .. " " .. endpoint.method .. " " .. endpoint.path) end return table.concat(lines, "\n") end return exportshouston.json
{ "schema_version": 2, "name": "AssessFirst", "files": [ "connector.luau" ], "icon": "icon.png", "access": [ { "name": "data", "label": "Access", "description": "Completion status shows agents which assessments each candidate has finished, with names and emails; Houston refuses every request for scores, reports and other results on that level, and every change. Houston sends no changes on Read. The AssessFirst API token itself has full access to your company's AssessFirst data.", "levels": [ { "value": "status", "label": "Completion status" }, { "value": "read", "label": "Read" }, { "value": "write", "label": "Write" } ], "default": "read" } ], "config": { "api_host": { "default": "app.assessfirst.com", "description": "Use Test only with a token generated on simu.assessfirst.com, AssessFirst's test environment.", "label": "Environment", "options": [ { "label": "Production", "value": "app.assessfirst.com" }, { "label": "Test", "value": "simu.assessfirst.com" } ], "type": "string" } }, "auth": { "token": { "config": { "token": { "label": "API token", "max_length": 512, "required": true, "type": "secret" } }, "label": "AssessFirst API token", "type": "manual" } }, "proxy": [ { "action": { "headers": { "set": { "AF-Token": "{{auth.token.token}}" } } }, "match": { "host": [ "{{config.api_host}}" ], "method": [ "GET" ], "path": [ "/betty-V2/candidate/{candidate_uuid}/completion", "/betty-V2/candidates", "/betty-V2/groups", "/betty-V2/groups/{group_uuid}/users", "/betty-V2/predictive-models" ], "protocol": "http" } }, { "action": { "headers": { "set": { "AF-Token": "{{auth.token.token}}" } } }, "if": "{{ allows access.data \"read\" }}", "match": { "host": [ "{{config.api_host}}" ], "method": [ "GET" ], "path": [ "/betty-V2/benchmarks", "/betty-V2/candidate/{candidate_uuid}", "/betty-V2/candidate/{candidate_uuid}/adequacies/{pm_uuid}", "/betty-V2/candidate/{candidate_uuid}/career/top", "/betty-V2/candidate/{candidate_uuid}/init-voice/{pm_uuid}", "/betty-V2/candidate/{candidate_uuid}/report/{report_id}", "/betty-V2/candidate/{candidate_uuid}/reports", "/betty-V2/candidate/{candidate_uuid}/scores", "/betty-V2/candidate/{candidate_uuid}/synthesis", "/betty-V2/locales", "/betty-V2/onepager/candidate/{candidate_uuid}/results", "/betty-V2/recruiters", "/betty-V2/webhooks" ], "protocol": "http" } }, { "action": { "headers": { "set": { "AF-Token": "{{auth.token.token}}" } } }, "if": "{{ allows access.data \"write\" }}", "match": { "host": [ "{{config.api_host}}" ], "method": [ "POST" ], "path": [ "/betty-V2/candidate", "/betty-V2/candidate/send-invitation", "/betty-V2/candidate/{candidate_uuid}/init-voice/{pm_uuid}", "/betty-V2/groups", "/betty-V2/groups/{group_uuid}/user/{user_uuid}", "/betty-V2/webhooks" ], "protocol": "http" } }, { "action": { "headers": { "set": { "AF-Token": "{{auth.token.token}}" } } }, "if": "{{ allows access.data \"write\" }}", "match": { "host": [ "{{config.api_host}}" ], "method": [ "DELETE" ], "path": [ "/betty-V2/groups/{group_uuid}", "/betty-V2/groups/{group_uuid}/user/{user_uuid}", "/betty-V2/webhooks/{webhook_uuid}" ], "protocol": "http" } } ] }icon.png

README.md
--- description: Follow candidates' AssessFirst assessments, read their results and fit with your jobs, and send invitations. --- # AssessFirst Let agents follow assessment completion, read scores and reports, and compare candidates with your predictive models. **Write** also permits invitations, voice assessments, group changes and webhooks. > **Completion status** hides scores and reports but still exposes candidate > names and emails. Assessment results are personal data; limit who can use the > connection. Obtain consent before adding candidates without an invitation. The token covers your company's data. Production and test environments are supported; AssessFirst's API remains in open beta. [Connect AssessFirst](SETUP.md).SETUP.md
# Connect AssessFirst > Requires an Administrator with a Recruiter licence and API access. AssessFirst > keeps one token per company; coordinate with other integrations before replacing it. 1. In [AssessFirst](https://app.assessfirst.com), open your profile's **Integration → AssessFirst API → Activate → Generate token**. If unavailable, ask your AssessFirst contact to enable API access. 2. Paste it into Houston's **API token** and choose **Production**. 3. For **Access**, choose **Read**, **Completion status** to hide scores and reports, or **Write** for invitations and changes. Save the connection and share it only with people allowed to see candidate data. [Official token guide](https://help.assessfirst.com/en/knowledge/how-to-get-your-api-token). ## Advanced - **Completion status** still exposes names, email addresses, groups and predictive models. Group candidates in AssessFirst to track completion; the API has no campaigns. The token itself retains company-wide access. - **Writes:** invitations send email. Obtain consent before adding a candidate without an invitation. Voice assessments and OnePager reports require their respective AssessFirst options. - **Sandbox:** request access from [AssessFirst support](mailto:[email protected]), create a token at [simu.assessfirst.com](https://simu.assessfirst.com) and choose **Test**. Tokens work only in the environment where they were created.tests
authentication.luau
return { contract = function(m) m.authentication({ { auth = { token = "synthetic-method-secret" }, config = {}, endpoint = { "GET", "https://app.assessfirst.com/betty-V2/locales" }, expected = "synthetic-method-secret", header = "AF-Token", method = "token", publisher = {}, }, }) end, }completion_only.luau
local API = "https://app.assessfirst.com/betty-V2" local C = "ab4699c9169d469c81082accfbe91584" local PM = "1d9c92277e264fe49a4ce330e51e6ac7" local G = "786a70ccd1454e83bfae271ffa721c0d" local META = '"meta":{"total":1,"current_page":1,"per_page":50,"previous_page":null,"next_page":1,"last_page":1}}' return { -- The Completion status level has no writes. scenario = {publisher = {}, access = {data = "status"}, config = {}, auth_method = "token", auth_config = {token = "fixture-private-assessfirst-token"}}, configure = function() calls = 0 payload = "{}" http = {request = function(req) calls += 1 request = req assert(req.method == "GET" and req.body == nil, "completion only sent " .. req.method) assert(req.headers.Authorization == nil and req.headers["AF-Token"] == nil, "connector set credentials") return fixture.operation({statusCode = 200, headers = {["content-type"] = {"application/json"}}, body = fixture.reader(payload)}) end} end, run = function(af) local names = {} for name in af do table.insert(names, name) end table.sort(names) assert(table.concat(names, ",") == "getCandidateCompletion,listCandidates,listGroupUsers,listGroups,listPredictiveModels", "wrong completion-only surface: " .. table.concat(names, ",")) local function get(name, args, url, body) payload = body local result = af[name](args) assert(request.url == url, name .. " requested " .. request.url) return result end -- Following a group: its candidates, then each one's completion against a predictive model. local group = get("listGroups", nil, API .. "/groups", '{"data":[{"uuid":"' .. G .. '","label":"Sales 2026","color":"#000000"}],' .. META).data[1] local member = get("listGroupUsers", {group_uuid = group.uuid}, API .. "/groups/" .. G .. "/users", '{"data":[{"uuid":"' .. C .. '","first_name":"Ana","last_name":"Silva","email":"[email protected]"}],' .. META).data[1] local model = get("listPredictiveModels", {name = "Sales"}, API .. "/predictive-models?name=Sales", '{"data":[{"uuid":"' .. PM .. '","name":"Sales","assessments":{"swipe":true,"drive":true,"brain":false,"voice":true}}],' .. META).data[1] local completion = get("getCandidateCompletion", {candidate_uuid = member.uuid, pm_uuid = model.uuid}, API .. "/candidate/" .. C .. "/completion?pm_uuid=" .. PM, '{"assessments":{"swipe":"finish","drive":"finish","voice":"todo"},"is_completed":true,"scores":[{"label":"lead","score":3}]}') assert(member.email == "[email protected]" and completion.is_completed and completion.assessments.voice == "todo") assert(completion.scores == nil, "completion kept a field outside its list") local page = get("listCandidates", {email = "[email protected]"}, API .. "/candidates?email=ana%40example.com", '{"data":[{"uuid":"' .. C .. '","first_name":"Ana","email":"[email protected]","aplayer_score":16,"iframe_candidate_token":"secret-iframe-token"}],"scores":[],' .. META) -- Only the listed fields of each record come back, so a result AssessFirst adds later stays out. assert(page.data[1].uuid == C and page.data[1].email == "[email protected]" and page.meta.last_page == 1) assert(page.data[1].aplayer_score == nil and page.data[1].iframe_candidate_token == nil and page.scores == nil, "candidate list kept a field outside its list") assert(json.encode(get("listCandidates", nil, API .. "/candidates", '{"data":[],' .. META).data) == "[]", "empty candidate array lost") assert(calls == 6) end, }endpoints.luau
return { contract = function(m) m.endpointRules() end, }errors.luau
local C = "dad17c50ff5d44e7a5b772fe636291a0" return { scenario = {publisher = {}, access = {data = "write"}, config = {}, auth_method = "token", auth_config = {token = "fixture-private-assessfirst-token"}}, configure = function() calls = 0 status = 200 payload = "{}" responseHeaders = {} http = {request = function(req) calls += 1 return fixture.operation({statusCode = status, headers = responseHeaders, body = fixture.reader(payload)}) end} end, run = function(af) local function upstream(fn, code, body, headers, expected, absent) status, payload, responseHeaders = code, body, headers local before = calls local ok, err = pcall(fn) for _, text in expected do assert(not ok and string.find(tostring(err), text, 1, true), "missing " .. text .. " in " .. tostring(err)) end if absent then assert(not string.find(tostring(err), absent, 1, true), "unexpected " .. absent .. " in " .. tostring(err)) end assert(calls == before + 1, "failed request was retried") end local function invite() af.sendInvitation({email = "[email protected]"}) end local function candidate() af.getCandidate({candidate_uuid = C}) end local function scores() af.getCandidateScores({candidate_uuid = C}) end upstream(invite, 500, '{"code":0,"message":"an error occured","data":[],"status":500}', {}, {"AssessFirst HTTP 500: an error occured", "invalid or revoked", '"retryable":false', '"upstream_status":500', '"operation":"sendInvitation"'}) -- A revoked token stays revoked, and a failed write may already have applied. upstream(candidate, 500, '{"code":0,"message":"an error occured","data":[],"status":500}', {}, {"invalid or revoked", '"retryable":false'}) upstream(invite, 502, "<html>Bad gateway</html>", {}, {"AssessFirst HTTP 502", '"retryable":false'}) upstream(invite, 429, '{"message":"Too Many Attempts."}', {["retry-after"] = {"60"}}, {"HTTP 429", "Retry-After: 60", '"retryable":true'}) upstream(invite, 422, '{"message":"The email field must be a valid email address.","errors":{"email":["The email field must be a valid email address."]}}', {}, {"HTTP 422: The email field must be a valid email address.", 'email address. {\\"email\\":[\\"The email field', '"retryable":false'}, "revoked") upstream(candidate, 404, '{"code":0,"message":"candidate_not_found","data":[],"status":404}', {}, {"HTTP 404: candidate_not_found", '"retryable":false'}) upstream(candidate, 422, '{"message":"invalid","errors":{"user":{"iframe_candidate_token":"secret-iframe-token","url":"https://app.assessfirst.com/p?sso=6db2e7"}}}', {}, {"HTTP 422: invalid", "https://app.assessfirst.com/p"}, "secret-iframe-token") upstream(candidate, 422, '{"message":"See https://app.assessfirst.com/p?sso=6db2e7","errors":{}}', {}, {"HTTP 422: See https://app.assessfirst.com/p"}, "6db2e7") upstream(candidate, 401, '{"code":401,"status":"error","message":"Unauthenticated."}', {}, {"HTTP 401: Unauthenticated."}) upstream(candidate, 400, json.encode({message = string.rep("x", 5000), errors = {uuid = {"invalid"}}}), {}, {"HTTP 400", '{\\"uuid\\":[\\"invalid\\"]}'}, string.rep("x", 601)) upstream(candidate, 429, '{"message":"Too Many Attempts."}', {["retry-after"] = {"60"}}, {"HTTP 429: Too Many Attempts.", "Retry-After: 60", '"retryable":true'}) upstream(candidate, 503, "<html>Cloudflare</html>", {}, {"AssessFirst HTTP 503", '"retryable":true'}) upstream(candidate, 200, "<html>Maintenance</html>", {}, {"invalid JSON object", '"upstream_status":200', '"retryable":false'}) upstream(candidate, 200, '"ok"', {}, {"invalid JSON object"}) upstream(scores, 200, '{"data":[]}', {}, {"invalid JSON array"}) end, }manifest.luau
return { contract = function(m) -- TestAssessFirstAccessRoutes do local token = "fixture-af-token" local c, pm, g = "/ab4699c9169d469c81082accfbe91584", "/1d9c92277e264fe49a4ce330e51e6ac7", "/786a70ccd1454e83bfae271ffa721c0d" do local _, err = m.resolve(nil, nil, nil, "token") if err == nil then m.fail("accepted missing token") end end do local _, err = m.resolve(nil, { api_host = "attacker.example" }, { token = token }, "token") if (err == nil) or not (string.find(tostring(err), "api_host", 1, true) ~= nil) then m.fail("accepted an environment host outside the options: %s", err) end end for _, hosts in { { "app.assessfirst.com", "simu.assessfirst.com" }, { "simu.assessfirst.com", "app.assessfirst.com" }, } do local host, other = hosts[1], hosts[2] local api = "https://" .. host .. "/betty-V2" for _, access in { "status", "read", "write" } do local r, err = m.resolve( nil, { api_host = host }, { token = token }, "token", { data = access } ) assert(not err, tostring(err)) if (m.count(r.PublicConfig) ~= 1) or (r.PublicConfig["api_host"] ~= host) then m.fail("unexpected Lua config: %s", r.PublicConfig) end local assert = function(allowed, ...) local routes = { ... } for _, route in routes do local method, url, _ = m.cut(route, " ") local recipe, err = m.recipe(r, method, url, nil) if (err == nil) ~= allowed then m.fail("%s %s allowed=%s: %s", access, route, (err == nil), err) end if err ~= nil then continue end m.rejectPreparedOverrides(recipe, r.Context, access .. " " .. route) local headers, err = m.prepare(recipe, r.Context, { ["Af-Token"] = { "forged" } }) if (err ~= nil) or (m.header(headers, "AF-Token") ~= token) then m.fail("credential injection for %s: %s %s", route, headers, err) end end end assert( true, "GET " .. api .. "/candidates?email=a%40example.com&page=2", "GET " .. api .. "/candidate" .. c .. "/completion?pm_uuid=x", "GET " .. api .. "/predictive-models", "GET " .. api .. "/groups", "GET " .. api .. "/groups" .. g .. "/users" ) assert( (access ~= "status"), "GET " .. api .. "/locales", "GET " .. api .. "/candidate" .. c, "GET " .. api .. "/candidate" .. c .. "/scores", "GET " .. api .. "/candidate" .. c .. "/synthesis", "GET " .. api .. "/candidate" .. c .. "/reports", "GET " .. api .. "/candidate" .. c .. "/report/20?pm_uuid=x", "GET " .. api .. "/candidate" .. c .. "/adequacies" .. pm, "GET " .. api .. "/candidate" .. c .. "/career/top", "GET " .. api .. "/candidate" .. c .. "/init-voice" .. pm, "GET " .. api .. "/onepager/candidate" .. c .. "/results", "GET " .. api .. "/benchmarks", "GET " .. api .. "/recruiters", "GET " .. api .. "/webhooks" ) assert( (access == "write"), "POST " .. api .. "/candidate/send-invitation", "POST " .. api .. "/candidate", "POST " .. api .. "/candidate" .. c .. "/init-voice" .. pm, "POST " .. api .. "/webhooks", "DELETE " .. api .. "/webhooks" .. g, "POST " .. api .. "/groups", "DELETE " .. api .. "/groups" .. g, "POST " .. api .. "/groups" .. g .. "/user" .. c, "DELETE " .. api .. "/groups" .. g .. "/user" .. c ) assert( false, "GET " .. api .. "/candidate/iframe/token/assessment", "GET https://" .. host .. "/betty/consents", "POST https://" .. host .. "/betty/users", "GET https://" .. other .. "/betty-V2/locales", "GET https://report.assessfirst.com/report/summary_report" .. c, "GET https://" .. host .. ".attacker.test/betty-V2/locales", "GET http://" .. host .. "/betty-V2/locales", "GET https://" .. host .. ":8443/betty-V2/locales", "PUT " .. api .. "/groups" .. g, "PATCH " .. api .. "/webhooks" .. g, "DELETE " .. api .. "/candidate" .. c, "GET " .. api .. "/candidate/%2e%2e/recruiters" ) end end end end, }read_only.luau
local API = "https://app.assessfirst.com/betty-V2" return { scenario = {publisher = {}, config = {}, auth_method = "token", auth_config = {token = "fixture-private-assessfirst-token"}}, configure = function() calls = 0 responses = {} http = {request = function(req) calls += 1 assert(req.method == "GET" and req.body == nil, "read-only sent " .. req.method) assert(req.headers.Authorization == nil and req.headers["AF-Token"] == nil, "connector set credentials") assert(req.headers.Accept[1] == "application/json") local body = responses[req.url] assert(body, "unexpected URL " .. req.url) return fixture.operation({statusCode = 200, headers = {["content-type"] = {"application/json"}}, body = fixture.reader(body)}) end} end, run = function(af) local names = {} for name in af do table.insert(names, name) end table.sort(names) assert(table.concat(names, ",") == "downloadCandidateReport,getCandidate,getCandidateAdequacies,getCandidateCompletion,getCandidateOnePager," .. "getCandidateScores,getCandidateSynthesis,getCandidateTopCareers,getVoiceStatus,listBenchmarks,listCandidateReports,listCandidates," .. "listGroupUsers,listGroups,listLocales,listPredictiveModels,listRecruiters,listWebhooks", "wrong read-only surface: " .. table.concat(names, ",")) responses[API .. "/locales"] = "[]" assert(json.encode(af.listLocales()) == "[]", "empty locale array lost") responses[API .. "/locales"] = '[{"name":"language_french","iso_code_639":"fr-FR","flag":"fr"}]' assert(af.listLocales()[1].iso_code_639 == "fr-FR") local uuid = "ab4699c9169d469c81082accfbe91584" responses[API .. "/candidates?email=ana%2Bjob%40example.com&page=2&per_page=50&locale=fr-FR"] = '{"data":[{"uuid":"' .. uuid .. '","first_name":"Ana","email":"ana+[email protected]","iframe_candidate_token":"secret-iframe-token"}],"meta":{"total":51,"current_page":2,"per_page":50,"previous_page":1,"next_page":null,"last_page":2}}' local page = af.listCandidates({email = "ana+[email protected]", page = 2, per_page = 50, locale = "fr-FR"}) assert(page.data[1].uuid == uuid and page.meta.last_page == 2 and page.meta.next_page == json.decode("null")) assert(page.data[1].iframe_candidate_token == nil, "listed candidate iframe token exposed") responses[API .. "/candidates"] = '{"data":[],"meta":{"total":0,"current_page":1,"per_page":50,"previous_page":null,"next_page":1,"last_page":1}}' assert(json.encode(af.listCandidates().data) == "[]", "empty candidate array lost") responses[API .. "/candidate/" .. uuid] = '{"uuid":"' .. uuid .. '","status":"ENABLED","aplayer_score":16,"iframe_candidate_token":"secret-iframe-token",' .. '"candidate_url":"https://my.assessfirst.com/recruiter/profile/' .. uuid .. '/synthesis","assessments":[{"id":8,"name":"Shape","status":"finish"}]}' local candidate = af.getCandidate({candidate_uuid = uuid}) assert(candidate.iframe_candidate_token == nil, "candidate iframe token exposed") assert(candidate.aplayer_score == 16 and candidate.assessments[1].status == "finish" and string.find(candidate.candidate_url, uuid, 1, true)) responses[API .. "/candidate/" .. uuid .. "/scores"] = "[]" assert(json.encode(af.getCandidateScores({candidate_uuid = uuid})) == "[]", "empty score array lost") responses[API .. "/candidate/" .. uuid .. "/scores"] = '[{"id":1,"label":"lead","name":"Assertive with others","score":3,"min":1,"max":10}]' assert(af.getCandidateScores({candidate_uuid = uuid})[1].label == "lead") responses[API .. "/webhooks?actions%5B%5D=user.linked&actions%5B%5D=assessment.finished"] = '{"data":[{"uuid":"d21e1601bd6c498aba228e0f54438f7d","url":"https://hooks.example.com/af","actions":["user.linked"]}],"meta":{}}' assert(af.listWebhooks({actions = {"user.linked", "assessment.finished"}}).data[1].actions[1] == "user.linked") local ok, err = pcall(af.listCandidates, {_method = "DELETE"}) assert(not ok and string.find(tostring(err), "listCandidates has no option _method", 1, true), tostring(err)) assert(calls == 8) end, }reads.luau
local API = "https://app.assessfirst.com/betty-V2" local C = "ab4699c9169d469c81082accfbe91584" local PM = "1d9c92277e264fe49a4ce330e51e6ac7" local G = "786a70ccd1454e83bfae271ffa721c0d" return { scenario = {publisher = {}, access = {data = "write"}, config = {}, auth_method = "token", auth_config = {token = "fixture-private-assessfirst-token"}}, configure = function() calls = 0 status = 200 payload = "{}" contentType = "application/json" fs = fixture.files() http = {request = function(req) calls += 1 request = req return fixture.operation({statusCode = status, headers = {["content-type"] = {contentType}}, body = fixture.reader(payload)}) end} end, run = function(af) local function get(name, args, url, body) payload = body or "{}" local result = af[name](args) assert(request.method == "GET" and request.url == url, name .. " requested " .. request.method .. " " .. request.url) assert(request.body == nil and request.headers.Authorization == nil and request.headers["AF-Token"] == nil) return result end get("listRecruiters", {uuid = C, email = "[email protected]", page = 1, per_page = 1}, API .. "/recruiters?uuid=" .. C .. "&email=rh%40example.com&page=1&per_page=1") assert(json.encode(get("listCandidateReports", {candidate_uuid = C}, API .. "/candidate/" .. C .. "/reports", "[]")) == "[]", "empty report array lost") local reports = get("listCandidateReports", {candidate_uuid = C}, API .. "/candidate/" .. C .. "/reports", '[{"id":20,"name":"Summary of findings","assessment":"All assessments","web_link":"https://report.assessfirst.com/report/summary_report/' .. C .. '?from=api"}]') assert(reports[1].id == 20 and string.find(reports[1].web_link, "?from=api", 1, true)) -- The sso parameter may sign whoever opens the link in to AssessFirst. local profile = "https://app.assessfirst.com/recruiter/profile/" .. C .. "/predict/" .. PM for _, link in {{profile .. "?sso=6db2e7", profile}, {profile .. "?sso=6db2e7&tab=voice", profile .. "?tab=voice"}, {profile .. "?tab=voice&sso=6db2e7", profile .. "?tab=voice"}, {profile .. "?tab=voice&sso=6db2e7#top", profile .. "?tab=voice#top"}, {profile .. "?sso=a&sso=b", profile}, {profile .. "?a=1&sso=a&sso=b&c=2", profile .. "?a=1&c=2"}, {"Why use sso=1? Is it safe?", "Why use sso=1? Is it safe?"}} do local fit = get("getCandidateAdequacies", {candidate_uuid = C, pm_uuid = PM, locale = "en-GB"}, API .. "/candidate/" .. C .. "/adequacies/" .. PM .. "?locale=en-GB", json.encode({adequacies = {global_adequacy = 14.29}, predict_success_url = link[1]})) assert(fit.predict_success_url == link[2] and fit.adequacies.global_adequacy == 14.29, "kept " .. fit.predict_success_url) end get("getCandidateCompletion", {candidate_uuid = C}, API .. "/candidate/" .. C .. "/completion") get("getCandidateCompletion", {candidate_uuid = C, pm_uuid = json.decode("null")}, API .. "/candidate/" .. C .. "/completion") local completion = get("getCandidateCompletion", {candidate_uuid = C, pm_uuid = PM}, API .. "/candidate/" .. C .. "/completion?pm_uuid=" .. PM, '{"assessments":{"swipe":"finish","voice":"todo"},"is_completed":false}') assert(completion.assessments.voice == "todo" and completion.is_completed == false) get("getCandidateSynthesis", {candidate_uuid = C}, API .. "/candidate/" .. C .. "/synthesis") -- PHP answers an empty object as [], which object endpoints pass through. assert(json.encode(get("getCandidateSynthesis", {candidate_uuid = C}, API .. "/candidate/" .. C .. "/synthesis", "[]")) == "[]") get("getCandidateTopCareers", {candidate_uuid = C, type = "full"}, API .. "/candidate/" .. C .. "/career/top?type=full") get("getCandidateOnePager", {candidate_uuid = C, pm_uuid = PM}, API .. "/onepager/candidate/" .. C .. "/results?pm_uuid=" .. PM) get("getVoiceStatus", {candidate_uuid = C, pm_uuid = PM}, API .. "/candidate/" .. C .. "/init-voice/" .. PM) get("listPredictiveModels", {name = "Sales & Ops", is_public = true}, API .. "/predictive-models?name=Sales%20%26%20Ops&is_public=1") get("listPredictiveModels", {is_public = false, page = 3}, API .. "/predictive-models?is_public=0&page=3") get("listBenchmarks", {name = "Director"}, API .. "/benchmarks?name=Director") get("listWebhooks", {name = "ATS", url = "https://hooks.example.com/af?x=1"}, API .. "/webhooks?name=ATS&url=https%3A%2F%2Fhooks.example.com%2Faf%3Fx%3D1") get("listGroups", {per_page = 10}, API .. "/groups?per_page=10") get("listGroupUsers", {group_uuid = G}, API .. "/groups/" .. G .. "/users") contentType = "application/pdf" payload = "%PDF-1.7 report" local report = af.downloadCandidateReport({candidate_uuid = C, report_id = 20, path = "reports/ana.pdf", locale = "fr-FR"}) assert(request.url == API .. "/candidate/" .. C .. "/report/20?locale=fr-FR" and request.headers.Accept == nil) assert(report.path == "reports/ana.pdf" and report.size == #payload and report.contentType == "application/pdf" and type(report.url) == "string") local file = fs.open("reports/ana.pdf", "r") assert(await(file:readAll()) == payload) await(file:close()) af.downloadCandidateReport({candidate_uuid = C, report_id = 17, pm_uuid = PM, path = "fit.pdf"}) assert(request.url == API .. "/candidate/" .. C .. "/report/17?pm_uuid=" .. PM) contentType = "application/json; charset=utf-8" payload = '{"code":0,"message":"report_not_available","data":[],"status":200}' local ok, err = pcall(af.downloadCandidateReport, {candidate_uuid = C, report_id = 8, path = "brain.pdf"}) assert(not ok and string.find(tostring(err), "HTTP 200: report_not_available", 1, true), tostring(err)) assert(not await(fs.exists("brain.pdf")), "JSON explanation saved as a PDF") for _, kind in {"text/html; charset=UTF-8", "text/plain", "", "application/xhtml+xml", "image/png"} do contentType = kind payload = "<html>Sign in to AssessFirst</html>" local ok, err = pcall(af.downloadCandidateReport, {candidate_uuid = C, report_id = 10, path = "login.pdf"}) assert(not ok and string.find(tostring(err), "instead of a PDF", 1, true) and string.find(tostring(err), '"retryable":false', 1, true), tostring(err)) assert(not await(fs.exists("login.pdf")), kind .. " page saved as a PDF") end payload = "%PDF-1.7 binary" for _, kind in {"application/octet-stream", "application/x-pdf", "application/force-download"} do contentType = kind assert(af.downloadCandidateReport({candidate_uuid = C, report_id = 10, path = "brain.pdf"}).size == #payload, kind) end local function rejected(fn, expected) local before = calls local ok, err = pcall(fn) assert(not ok and string.find(tostring(err), expected, 1, true), "wrong validation error: " .. tostring(err)) assert(calls == before, "invalid input reached AssessFirst") end rejected(function() af.getCandidate() end, "candidate_uuid must be an AssessFirst UUID") rejected(function() af.getCandidate({candidate_uuid = "../recruiters"}) end, "candidate_uuid must be an AssessFirst UUID") rejected(function() af.getCandidate({candidate_uuid = C .. "/reports"}) end, "candidate_uuid") rejected(function() af.getCandidate({candidate_uuid = 42}) end, "candidate_uuid") rejected(function() af.getCandidate({candidate_uuid = C, extra = true}) end, "getCandidate has no option extra") rejected(function() af.getCandidate("ab4699c9") end, "opts must be an object") rejected(function() af.getCandidateCompletion({candidate_uuid = C, pm_uuid = "web designer"}) end, "pm_uuid") for _, size in {0, 51, 1.5, "10"} do rejected(function() af.listCandidates({per_page = size}) end, "per_page must be an integer from 1 to 50") end rejected(function() af.listCandidates({page = 0}) end, "page must be an integer") rejected(function() af.listCandidates({page = 1e15}) end, "page must be an integer from 1 to 1000000000") rejected(function() af.listCandidates({email = ""}) end, "email must be a nonempty string") rejected(function() af.listPredictiveModels({is_public = 1}) end, "is_public must be a boolean") rejected(function() af.listWebhooks({actions = "user.linked"}) end, "actions must be a nonempty array") rejected(function() af.listWebhooks({actions = json.decode("[]")}) end, "actions must be a nonempty array") rejected(function() af.listWebhooks({actions = {"user.created"}}) end, "actions must contain only") rejected(function() af.listLocales({locale = "fr-FR&page=2"}) end, "locale must be a locale") rejected(function() af.downloadCandidateReport({candidate_uuid = C, report_id = 20}) end, "path must be a nonempty string") rejected(function() af.downloadCandidateReport({candidate_uuid = C, report_id = 18, path = "fit.pdf"}) end, "report_id 18 requires pm_uuid") rejected(function() af.downloadCandidateReport({candidate_uuid = C, report_id = 17, pm_uuid = json.decode("null"), path = "fit.pdf"}) end, "report_id 17 requires pm_uuid") rejected(function() af.downloadCandidateReport({candidate_uuid = C, report_id = "20", path = "x.pdf"}) end, "report_id must be an integer") rejected(function() af.downloadCandidateReport({candidate_uuid = C, report_id = 0, path = "x.pdf"}) end, "report_id must be an integer") end, }test_environment.luau
local API = "https://simu.assessfirst.com/betty-V2" return { scenario = {publisher = {}, access = {data = "write"}, config = {api_host = "simu.assessfirst.com"}, auth_method = "token", auth_config = {token = "fixture-simu-assessfirst-token"}}, configure = function() payload = "{}" http = {request = function(req) request = req return fixture.operation({statusCode = 200, headers = {["content-type"] = {"application/json"}}, body = fixture.reader(payload)}) end} end, run = function(af) payload = "[]" assert(json.encode(af.listLocales()) == "[]") assert(request.method == "GET" and request.url == API .. "/locales", "test environment not used: " .. request.url) assert(request.headers.Authorization == nil and request.headers["AF-Token"] == nil, "connector set credentials") payload = '{"uuid":"dad17c50ff5d44e7a5b772fe636291a0","status":"invitation_sent"}' assert(af.sendInvitation({email = "[email protected]"}).status == "invitation_sent") assert(request.method == "POST" and request.url == API .. "/candidate/send-invitation", "test environment not used: " .. request.url) end, }writes.luau
local API = "https://app.assessfirst.com/betty-V2" local C = "dad17c50ff5d44e7a5b772fe636291a0" local PM = "ae5d8fe1546e45569a6364455e9f8bbb" local G = "786a70ccd1454e83bfae271ffa721c0d" local W = "f4128a0183594722a58f9ccb96e7633d" return { scenario = {publisher = {}, access = {data = "write"}, config = {}, auth_method = "token", auth_config = {token = "fixture-private-assessfirst-token"}}, configure = function() calls = 0 status = 200 payload = "{}" http = {request = function(req) calls += 1 request = req return fixture.operation({statusCode = status, headers = {}, body = fixture.reader(payload)}) end} end, run = function(af) local names = {} for name in af do table.insert(names, name) end assert(#names == 27, "wrong read-write surface") -- Sends method and URL, and the JSON body exactly when expected. local function write(name, args, method, url, body, code, response) status, payload = code or 200, response or "{}" local result = af[name](args) assert(request.method == method and request.url == url, name .. " requested " .. request.method .. " " .. request.url) assert(request.headers.Authorization == nil and request.headers["AF-Token"] == nil, "connector set credentials") if body then assert(request.headers["Content-Type"][1] == "application/json") local sent = json.decode(request.body) for key, value in body do assert(json.encode(sent[key]) == json.encode(value), name .. " sent " .. key .. "=" .. json.encode(sent[key])) end for key in sent do assert(body[key] ~= nil, name .. " sent unexpected " .. key) end else assert(request.body == nil and request.headers["Content-Type"] == nil, name .. " sent a body") end return result end local invited = write("sendInvitation", {email = "[email protected]", first_name = "Ana", last_name = "Silva", gender = "f", recruiter_email = "[email protected]", message = "Bonjour Ana", predictive_model_uuid = PM, locale = "fr-FR"}, "POST", API .. "/candidate/send-invitation?locale=fr-FR", {email = "[email protected]", first_name = "Ana", last_name = "Silva", gender = "f", recruiter_email = "[email protected]", message = "Bonjour Ana", predictive_model_uuid = PM}, 200, '{"uuid":"' .. C .. '","last_invited_at":"2025-05-16T09:15:43.000000Z","status":"invitation_sent"}') assert(invited.uuid == C and invited.status == "invitation_sent") local again = write("sendInvitation", {email = "[email protected]", first_name = json.decode("null")}, "POST", API .. "/candidate/send-invitation", {email = "[email protected]"}, 200, '{"uuid":"' .. C .. '","status":"user_already_invited_24_hours_ago"}') assert(again.status == "user_already_invited_24_hours_ago") local added = write("createCandidate", {email = "[email protected]", gender = "n"}, "POST", API .. "/candidate", {email = "[email protected]", gender = "n"}, 201, '{"uuid":"' .. C .. '","status":"added_to_network"}') assert(added.status == "added_to_network") write("startVoiceAssessment", {candidate_uuid = C, pm_uuid = PM}, "POST", API .. "/candidate/" .. C .. "/init-voice/" .. PM, nil, 201, '{"uuid":"33a9d4f816df4718818a28f04f8e23ef","candidate_uuid":"' .. C .. '","predictive_model_uuid":"' .. PM .. '"}') local hook = write("createWebhook", {name = "ATS", url = "https://hooks.example.com/af", actions = {"assessment.finished", "user.linked"}}, "POST", API .. "/webhooks", {name = "ATS", url = "https://hooks.example.com/af", actions = {"assessment.finished", "user.linked"}}, 201, '{"uuid":"' .. W .. '","name":"ATS","actions":["assessment.finished","user.linked"]}') assert(hook.uuid == W and hook.actions[2] == "user.linked") assert(json.encode(write("deleteWebhook", {webhook_uuid = W}, "DELETE", API .. "/webhooks/" .. W, nil, 200, "{}")) == "{}") local group = write("createGroup", {label = "Finalists", color = "#FF0088"}, "POST", API .. "/groups", {label = "Finalists", color = "#FF0088"}, 201, '{"uuid":"' .. G .. '","label":"Finalists","color":"#FF0088","id":38679}') assert(group.uuid == G) local member = write("addGroupUser", {group_uuid = G, user_uuid = C}, "POST", API .. "/groups/" .. G .. "/user/" .. C, nil, 201, '{"user":{"uuid":"' .. C .. '","iframe_candidate_token":"secret-iframe-token","profile_url":"https://app.assessfirst.com/recruiter/profile/' .. C .. '?sso=6db2e7"},"group":{"uuid":"' .. G .. '"}}') assert(member.user.uuid == C and member.group.uuid == G) assert(member.user.iframe_candidate_token == nil and member.user.profile_url == "https://app.assessfirst.com/recruiter/profile/" .. C, "nested secrets exposed") assert(json.encode(write("removeGroupUser", {group_uuid = G, user_uuid = C}, "DELETE", API .. "/groups/" .. G .. "/user/" .. C, nil, 204, "")) == "{}") assert(json.encode(write("deleteGroup", {group_uuid = G}, "DELETE", API .. "/groups/" .. G, nil, 204, "")) == "{}") assert(json.encode(write("startVoiceAssessment", {candidate_uuid = C, pm_uuid = PM}, "POST", API .. "/candidate/" .. C .. "/init-voice/" .. PM, nil, 204, "")) == "{}") assert(calls == 11) local function rejected(fn, expected) local before = calls local ok, err = pcall(fn) assert(not ok and string.find(tostring(err), expected, 1, true), "wrong validation error: " .. tostring(err)) assert(calls == before, "invalid input reached AssessFirst") end rejected(function() af.sendInvitation({first_name = "Ana"}) end, "email is required") rejected(function() af.sendInvitation({email = json.decode("null")}) end, "email is required") rejected(function() af.sendInvitation({email = "[email protected]", gender = "female"}) end, "gender must be 'f', 'n' or 'm'") rejected(function() af.sendInvitation({email = "[email protected]", predictive_model_uuid = "web designer"}) end, "predictive_model_uuid") rejected(function() af.sendInvitation({email = "[email protected]", first_name = 7}) end, "first_name must be a nonempty string") rejected(function() af.createCandidate({email = "[email protected]", message = "Hi"}) end, "createCandidate has no option message") rejected(function() af.createWebhook({name = "ATS", url = "https://hooks.example.com/af"}) end, "actions is required") rejected(function() af.createWebhook({name = "ATS", url = "https://hooks.example.com/af", actions = {"user.deleted", "user.created"}}) end, "actions must contain only") rejected(function() af.createWebhook({name = "ATS", url = "https://hooks.example.com/af", actions = {one = "user.linked"}}) end, "actions must be a nonempty array") rejected(function() af.createGroup({color = "#000000"}) end, "label is required") -- Laravel reads _method from the query or body; the allow-lists never send it. rejected(function() af.sendInvitation({email = "[email protected]", _method = "DELETE"}) end, "sendInvitation has no option _method") rejected(function() af.addGroupUser({group_uuid = G, user_uuid = C, _method = "DELETE"}) end, "addGroupUser has no option _method") rejected(function() af.addGroupUser({group_uuid = G}) end, "user_uuid must be an AssessFirst UUID") rejected(function() af.deleteGroup({group_uuid = G .. "/user/" .. C}) end, "group_uuid") rejected(function() af.deleteWebhook({webhook_uuid = "%2e%2e"}) end, "webhook_uuid") end, }