Files
lincodex/api/core/routes/organization_needs.yml
T

110 lines
7.9 KiB
YAML

get:
operationId: ListOrganizationNeeds
summary: List the needs of an organization.
description: |-
Requires the session cookie of an employer account with an active membership in `org_id`. The organization and the role come from the membership that the server holds for the session account, never from the request. In the MVP only the owner of the organization works with needs; the other roles of the PRD FR07 matrix (recruiter, hiring manager and technical expert for assigned needs) are planned and change no field of this contract. The list holds only the needs that the role may read.
Returns a page of need summaries, newest first by creation time with the identifier as the tie-breaker, with cursor pagination. A summary has the current version, the target specialization and grade with their confirmation state, and the readiness; GetOrganizationNeed returns the requirements and the recommendations.
Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account answers 403 forbidden; an account without an active membership in the organization and an unknown organization both answer 404 not_found, so organizations cannot be enumerated; a member whose role does not allow reading needs answers 403 forbidden. A malformed `org_id`, `limit`, or `cursor` answers 400 validation_failed.
security:
- sessionCookie: []
tags:
- need
parameters:
- $ref: ../components/parameters.yml#/OrganizationId
- $ref: ../components/parameters.yml#/PageLimit
- $ref: ../components/parameters.yml#/PageCursor
responses:
"200":
description: A page of the needs of the organization.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/NeedList
examples:
last_page:
$ref: ../components/examples.yml#/NeedListPage
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/Forbidden
"404":
$ref: ../components/responses.yml#/NotFound
default:
$ref: ../components/responses.yml#/Problem
post:
operationId: CreateOrganizationNeed
summary: Create a need of an organization from a form, a text, or both.
description: |-
Requires the session cookie of an employer account with an active membership in `org_id`, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and an Idempotency-Key. The organization comes from the path and the server-side membership; the body has no organization, membership, or role field. In the MVP only the owner of the organization may create a need; the other roles of PRD FR07 are planned.
A need does not require a vacancy: `vacancy_id` is optional and nullable. When it is given, it must name a vacancy of the same organization; until vacancies exist in the contract, any vacancy identifier answers 400 with the pointer `/vacancy_id`, the same for an unknown vacancy and one of another organization.
Only `title` is required. A field is sent as a decision `{value, status}` and a list item as `{name or text, status}`; on creation the status must be `confirmed`, and the value becomes a confirmed manual value. When `source_text` is given, the server extracts suggestions for the absent fields with deterministic rules and a dictionary before it answers, so creation works while the ML service is disabled; every suggestion has the status `extracted`, the origin extracted_from_text, a quote where the extractor found one, and the extractor version, and it waits for a member to confirm it. A field that the text does not state stays `unknown` with null value and source; the server never guesses a grade, a format, or a salary. ML suggestions with quotes are planned as an asynchronous addition that creates a new version and never overwrites a confirmed value.
The need is saved even when critical fields are missing: the response is 201 with version 1, and `readiness.missing_fields` names each critical field without a confirmed value with a specific question. `recommendations` is computed by the server from the confirmed requirements only; the request cannot set a recommendation, its score, or its components. Creating a need never contacts a candidate or sends an invitation.
Salary limit: setting a salary range counts against a limit shared by the whole organization, every member and every need, on creation as on a change: at most three range settings a day (PRD FR13, planned in TASK-211). Over the limit the server answers 429 with Retry-After and creates nothing. After five settings within seven days the money component of the recommendations is `withheld` for seven days. The limit keeps an organization from probing hidden candidate minimums with new needs instead of edits; repeated range changes also feed the private risk signals of TASK-319.
Idempotency: a retry with the same key and body within 24 hours replays the stored 201 and creates nothing, so a lost response never creates a second need. A different body with the same key answers 422 idempotency_key_reused. 400 is never stored, so a corrected retry is evaluated again.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for a candidate), membership (404 not_found) and role (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay), domain rules (400 with a pointer: `/salary/value/salary_to` for a range whose lower bound is not below the upper one or whose width is outside 10-40%, `/required_skills/1/name` for a repeated skill, `/grade/status` or `/required_skills/0/status` for `extracted`, which a new need cannot have, or `/vacancy_id`), then the salary limit (429). The schema already rejects unknown fields such as `rec_score`, `members`, or `candidate_minimum`, a field sent as a bare value instead of `{value, status}`, a salary bound that is not a positive multiple of 1000, and an unknown currency, period, or tax basis. The general rate limit can answer 429 with Retry-After before any check. 429 is never stored.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- need
parameters:
- $ref: ../components/parameters.yml#/OrganizationId
- $ref: ../components/parameters.yml#/IdempotencyKey
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/NeedCreate
examples:
manual_without_vacancy:
$ref: ../components/examples.yml#/NeedCreateManual
from_text:
$ref: ../components/examples.yml#/NeedCreateFromText
responses:
"201":
description: >-
The need was created as version 1, or a retry with the same
Idempotency-Key replayed its creation.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/Need
examples:
manual_without_vacancy:
$ref: ../components/examples.yml#/NeedManualWithoutVacancy
from_text_with_unknown_skill:
$ref: ../components/examples.yml#/NeedExtractedWithUnknownSkill
"400":
$ref: ../components/responses.yml#/NeedValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden
"404":
$ref: ../components/responses.yml#/NotFound
"409":
$ref: ../components/responses.yml#/IdempotencyInProgress
"422":
$ref: ../components/responses.yml#/UnprocessableContent
"429":
$ref: ../components/responses.yml#/TooManyRequests
default:
$ref: ../components/responses.yml#/Problem