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

104 lines
7.9 KiB
YAML

get:
operationId: ListOrganizationInvitations
summary: List the invitations 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 invitations, as with needs; the other roles of the PRD FR07 matrix are planned and change no field of this contract.
Returns a page of invitation summaries in every state, drafts included, newest first by creation time with the identifier as the tie-breaker, with cursor pagination. A summary names the candidate only by the opaque `candidate_handle` and has the state, the versions, the role, the salary range, the deadline, and the contact access without any contact value. A declined invitation shows the state `declined` without the reason or the comment. Filters by state and need are planned and add optional parameters.
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 invitations answers 403 forbidden. A malformed `org_id`, `limit`, or `cursor` answers 400 validation_failed.
security:
- sessionCookie: []
tags:
- invitation
parameters:
- $ref: ../components/parameters.yml#/OrganizationId
- $ref: ../components/parameters.yml#/PageLimit
- $ref: ../components/parameters.yml#/PageCursor
responses:
"200":
description: A page of the invitations of the organization.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/OrganizationInvitationList
examples:
last_page:
$ref: ../components/examples.yml#/OrganizationInvitationListPage
"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: CreateOrganizationInvitation
summary: Create an invitation draft for one candidate.
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 an invitation.
The draft is addressed to one person from a search result of this organization: `candidate_handle` is the opaque handle of that card, never an email address, a phone number, or an account identifier. The server resolves the handle for this organization only. An unknown handle, a handle of another organization, and a profile that the organization may no longer see, because the candidate revoked the publication C2 or hid the profile from it, all answer 400 with the pointer `/candidate_handle`, so a handle never reveals which case applies. `need` is optional: a direct invitation has none, and a need given must be a need of the organization with a `requirements_version` that it has had, otherwise 400 with the pointer `/need`. `response_period_days` is 3, 7, or 14 and defaults to 7.
The terms are complete from the start (PRD FR12): the role, the specialization and the grade, the offer type, the tasks, the team, the technology stack, the work formats and the place of work, the communication method, the salary range in RUB with its tax basis, and the package. Each package condition is either `provided` with a description or explicitly `not_provided`; leaving one out fails validation. A draft without the tax basis or the communication method therefore cannot exist. The draft is created as version 1 with terms version 1, and the candidate does not see it until SendOrganizationInvitation.
Salary: SalaryRange applies the same rules as for a need: whole rubles, positive multiples of 1000, `salary_from < salary_to`, and a width from 10% to 40% of the midpoint, checked by the server in integer arithmetic. The response carries `salary_fit`, the coarse indicator of PRD FR13 against the candidate's hidden minimum; the exact minimum appears in no response. The server never rejects a range because of the minimum, since a rejection would reveal it. Creating a draft is an indicator-relevant setting: it counts against the limit shared by the whole organization with the ranges of needs, at most three settings a day, and against the withheld counter, after five settings within seven days the indicator is `withheld` for seven days from the fifth, on every draft and invitation of the organization (PRD FR13, enforcement planned; see InvitationSalaryFit). Over the limit the server answers 429 with Retry-After and creates nothing.
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 draft. A different body with the same key answers 422 idempotency_key_reused. 400 and 429 are never stored.
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: `/candidate_handle`, `/need`, `/terms/salary/salary_to` for a reversed range or a width outside 10-40%, `/terms/location` for the `office` or `hybrid` format without a place of work, or `/terms/tech_stack/1` for a repeated technology), then the salary limit (429). The schema already rejects a missing term or package condition, a salary bound that is not a positive multiple of 1000, an unknown currency, period, or tax basis, and unknown fields such as `state`, `version`, `salary_fit`, `candidate_email`, or `salary_minimum`. The general rate limit can answer 429 with Retry-After before any check.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- invitation
parameters:
- $ref: ../components/parameters.yml#/OrganizationId
- $ref: ../components/parameters.yml#/IdempotencyKey
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/OrganizationInvitationCreate
examples:
valid_invitation:
$ref: ../components/examples.yml#/InvitationCreateFromNeed
responses:
"201":
description: >-
The draft was created as version 1 with terms 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#/OrganizationInvitation
examples:
draft:
$ref: ../components/examples.yml#/OrganizationInvitationDraft
"400":
$ref: ../components/responses.yml#/InvitationValidationFailed
"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