post: operationId: AcceptMyInvitation summary: Accept the current terms and disclose the selected contacts. description: |- Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and an Idempotency-Key. The candidate comes from the session. Only an acceptance of the current terms version with the consent C4 creates access to contacts (PRD FR12). The body names the `terms_version` the candidate read and accepts, the `expected_version` of the invitation, and `consent_c4`: the C4 text version that the candidate saw, `accepted: true`, and the contact fields the candidate selected. At least one field is required and nothing is preselected or defaulted, so a grant never covers a field the candidate did not choose. The fields come only from the candidate's profile; the request never carries contact values. Allowed in `delivered` and `viewed` before `response_deadline_at`; accepting directly from `delivered` is allowed, as in the PRD FR12 transition table. In one transaction the server moves the invitation to `accepted`, records the consent C4 in the consent ledger with the organization, the fields, the invitation, the terms version, and the text version and its hash, creates the contact grant for exactly those fields, and writes the audit event. The response is the invitation with `contact_grant`. The acceptance never publishes the profile (C2) and never bypasses a profile hidden from the organization: the grant alone does not guarantee a read, and the organization reads only while the visibility allows it. 412 or 409: a `terms_version` or `expected_version` that is not current answers 412 version_conflict, the repository status for a stale version, and records nothing; this is the stale terms case, for example after the organization raised the salary, and the client reads the invitation again and shows the new terms for a new decision. A state that does not allow an acceptance answers 409 state_conflict: `withdrawn`, `expired`, `declined`, `cancelled_by_candidate`, the planned `counter`, or a command received at the deadline or later, which is late. A terminal state and a passed deadline are checked before the versions: the server first applies the due expiry, and the client then gets 409 for a withdrawn, expired, or late invitation even when its versions are stale, so it shows the final state instead of rereading and retrying. The repository rule keeps 412 for any stale version, so clients branch on `version_conflict` to reread and on `state_conflict` to show the final state. Repeats return the same result: a retry with the same Idempotency-Key replays the stored response, and an acceptance of an invitation that is already `accepted` whose `terms_version` and set of fields equal those of its `contact_grant`, the terms version and fields that the candidate accepted, answers 200 with it even with a new key, an older `expected_version`, or a current `terms_version` that a later raise advanced; no second consent, grant, or audit event is created. A different terms version or field set on an accepted invitation answers 409 state_conflict; changing the disclosed fields is a matter of the consent operations. Of two concurrent acceptances only one makes the transition. Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for an employer), the Idempotency-Key (422, 409 idempotency_in_progress, replay), the invitation (404 not_found, after any due expiry), the repeat on an accepted invitation (200), a terminal state or a passed deadline (409 state_conflict, whatever the versions), the versions (412), any other state that does not allow an acceptance (409 state_conflict), then the consent rules (400 with the pointer `/consent_c4/text_version` for a text version that is not the published one, or `/consent_c4/fields/0` for a field that the profile does not hold). The schema rejects a missing `terms_version`, an empty or repeated field list, an unknown field kind, `accepted` other than true, and unknown fields such as `email` or `phone`. The general rate limit can answer 429 with Retry-After before any check. 404 and 409 state_conflict are stored under the key; 400, 412, and 429 are not. security: - sessionCookie: [] sessionCsrf: [] tags: - invitation parameters: - $ref: ../components/parameters.yml#/MyInvitationId - $ref: ../components/parameters.yml#/IdempotencyKey requestBody: required: true content: application/json: schema: $ref: ../components/schemas.yml#/InvitationAcceptance examples: email_only: $ref: ../components/examples.yml#/InvitationAcceptEmailOnly stale_terms: $ref: ../components/examples.yml#/InvitationAcceptStaleTerms responses: "200": description: >- The accepted invitation with the contact grant, or the same invitation when this acceptance was already made. headers: Cache-Control: $ref: ../components/headers.yml#/CacheControlNoStore content: application/json: schema: $ref: ../components/schemas.yml#/CandidateInvitation examples: accepted: $ref: ../components/examples.yml#/CandidateInvitationAccepted visibility_blocked: $ref: ../components/examples.yml#/CandidateInvitationAcceptedVisibilityBlocked "400": $ref: ../components/responses.yml#/InvitationAcceptValidationFailed "401": $ref: ../components/responses.yml#/Unauthenticated "403": $ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden "404": $ref: ../components/responses.yml#/NotFound "409": $ref: ../components/responses.yml#/InvitationCommandConflict "412": $ref: ../components/responses.yml#/InvitationVersionConflict "422": $ref: ../components/responses.yml#/UnprocessableContent "429": $ref: ../components/responses.yml#/TooManyRequests default: $ref: ../components/responses.yml#/Problem