> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stax.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Recalculate census eligibility

> Recalculate eligibility, entry dates, and other census calculations for a client. Optionally resets census data, scrubs data, filters by employee, and returns census for specific plan year.



## OpenAPI

````yaml /api-reference/cx/swagger.json post /packages/retirement/census/_calculate_eligibility
openapi: 3.0.0
info:
  description: CX API.
  title: CX API
  contact:
    name: API Support
    url: https://stax.ai
    email: support@stax.ai
  version: '1.0'
servers:
  - url: https://api.cx.stax.ai
security: []
paths:
  /packages/retirement/census/_calculate_eligibility:
    post:
      tags:
        - packages
      summary: Recalculate census eligibility
      description: >-
        Recalculate eligibility, entry dates, and other census calculations for
        a client. Optionally resets census data, scrubs data, filters by
        employee, and returns census for specific plan year.
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/pkg_routes_packages_retirement_census.RecalculateCensusRequest
        description: >-
          Recalculate request (client required; reset, scrub, employee,
          return_plan_year optional)
        required: true
      responses:
        '200':
          description: Recalculation result with census data and issues
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/pkg_routes_packages_retirement_census.RecalculateCensusResponse
        '400':
          description: Bad request - invalid request body, client ID, or client not found
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
components:
  schemas:
    pkg_routes_packages_retirement_census.RecalculateCensusRequest:
      type: object
      properties:
        async:
          description: >-
            If true, fire the recalc in the background and return immediately
            without census data
          type: boolean
        client:
          type: string
        employee:
          description: Optional field
          type: string
        ignore_previous_service:
          description: If set, ignores previous service when calculating eligibility
          type: boolean
        mode:
          description: '"ensure_only": create missing census rows and return'
          type: string
        reset:
          type: boolean
        return_plan_year:
          description: If set, returns the census for the specified plan year
          type: integer
        scrub:
          type: boolean
    pkg_routes_packages_retirement_census.RecalculateCensusResponse:
      type: object
      properties:
        employeeCensus:
          type: array
          items:
            $ref: '#/components/schemas/types.EmployeeCensus'
        issues:
          type: array
          items:
            $ref: '#/components/schemas/types.EmployeeCensusIssue'
        ok:
          type: boolean
    types.EmployeeCensus:
      type: object
      properties:
        _id:
          type: string
        activity:
          description: Keep track of activity
          type: array
          items:
            $ref: '#/components/schemas/types.Activity'
        address:
          $ref: '#/components/schemas/types.Address'
        birth_date:
          description: Dates
          type: string
        cleared:
          description: >-
            Keep track of the cleared errors so they don't show up again for the
            TPA or the client
          type: array
          items:
            type: string
        client:
          type: string
        created_at:
          type: string
        ct_group_code:
          description: Control-group testing
          type: string
        deleted_at:
          type: string
        edits:
          description: >-
            If a user manually edits a value, we record the original value here
            and replace the transaction with the new value
          type: object
          additionalProperties: true
        email:
          type: string
        employee:
          type: string
        employment_category:
          type: string
        employment_type:
          type: string
        errors:
          description: Recorded census scrubbing errors
          type: array
          items:
            $ref: '#/components/schemas/types.ShortEmployeeCensusError'
        ethnicity:
          type: string
        first_name:
          type: string
        gender:
          type: string
        group:
          description: Division Code
          type: string
        hire_date:
          type: string
        is_officer:
          type: boolean
        last_name:
          type: string
        loan_amount:
          type: number
        loan_balance:
          type: number
        loan_disbursement_date:
          description: Loan data
          type: string
        loan_installment:
          type: number
        loan_payments:
          type: array
          items:
            $ref: '#/components/schemas/types.EmployeeLoanPayment'
        location_code:
          type: string
        middle_name:
          description: Other data we're collecting in case we need them
          type: string
        not_employee:
          type: boolean
        other_employers:
          description: Are they employed by any other entities?
          type: array
          items:
            type: string
        owner_kind:
          description: |-
            OwnerKind is "individual" or "business" when set by the Ownership
            questionnaire question type (ENG-8548).
          type: string
        ownership_percentage:
          description: Ownership/Family
          type: number
        phone:
          type: string
        plans_data:
          description: Plan Data
          type: array
          items:
            $ref: '#/components/schemas/types.PlanData'
        possible_termination_date:
          description: >-
            In case we don't have a termination date, we can provide a possible
            termination date based on the last payroll.
          type: string
        preferred_name:
          type: string
        principal:
          type: string
        py:
          type: integer
        rehire_date:
          type: string
        relationship:
          type: string
        skipped:
          description: Keep track of skipped fields for overrides
          type: object
          additionalProperties:
            type: boolean
        ssn:
          description: Personal details
          type: string
        status_override:
          type: string
        team:
          type: string
        termination_date:
          type: string
        termination_reason:
          type: string
        title:
          type: string
        w2_sources:
          description: >-
            W2Sources holds one entry per accepted tax document (W-2, Schedule
            C,

            K-1) for this plan year, keyed by the uploaded file. An S-corp owner

            needs both a W-2 and a K-1, and some employees have several W-2s, so

            a single slot would let one document overwrite another.
          type: array
          items:
            $ref: '#/components/schemas/types.EmployeeCensusW2Source'
    types.EmployeeCensusIssue:
      type: object
      properties:
        employee:
          type: string
        errors:
          type: array
          items:
            $ref: '#/components/schemas/types.EmployeeCensusCheckError'
    types.Activity:
      type: object
      properties:
        _id:
          type: string
        action:
          type: string
        changes:
          type: array
          items:
            $ref: '#/components/schemas/types.Change'
        client:
          type: string
        on_id:
          type: string
        on_py:
          type: integer
        on_type:
          type: string
        team:
          type: string
        timestamp:
          type: string
        user:
          type: string
    types.Address:
      type: object
      properties:
        attn:
          type: string
        city:
          type: string
        country:
          type: string
        desc:
          type: string
        state:
          type: string
        street:
          type: string
        street2:
          type: string
        unit:
          type: string
        zip:
          type: string
    types.ShortEmployeeCensusError:
      type: object
      properties:
        custom:
          description: >-
            Set to nil if this is not a custom issue, otherwise set to a random
            ID for tracking
          type: string
        detail:
          type: string
        field_names:
          type: array
          items:
            type: string
        path:
          type: array
          items:
            type: string
        plan:
          type: string
        reason:
          type: string
        reviewed:
          type: boolean
    types.EmployeeLoanPayment:
      type: object
      properties:
        _id:
          type: string
        amount:
          description: >-
            Amount intentionally has no omitempty: a $0 payment with a future
            date

            is a valid pending entry, and the UI needs to render it (not the

            "enter amount" placeholder) when the user re-opens the participant.
          type: number
        date:
          type: string
        loan_id:
          type: string
        payroll:
          type: string
        source:
          type: string
    types.PlanData:
      type: object
      properties:
        eligibility_date:
          $ref: '#/components/schemas/types.PlanDates'
        eligibility_reason:
          $ref: '#/components/schemas/types.MoneyTypeStrings'
        eligibility_status:
          $ref: '#/components/schemas/types.MoneyTypeStrings'
        eligible_gross_pay:
          $ref: '#/components/schemas/types.PlanCompensation'
        entry_date:
          $ref: '#/components/schemas/types.PlanDates'
        exclusions:
          $ref: '#/components/schemas/types.Exclusions'
        plan_compensation:
          $ref: '#/components/schemas/types.PlanCompensation'
        plan_id:
          type: string
        plan_type:
          type: string
        transactions:
          $ref: '#/components/schemas/types.Transactions'
        vesting:
          $ref: '#/components/schemas/types.Vesting'
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/types.Warning'
    types.EmployeeCensusW2Source:
      type: object
      properties:
        boxes:
          $ref: '#/components/schemas/types.EmployeeCensusW2Boxes'
        compensation_applicable:
          type: boolean
        confidence:
          type: number
        document_type:
          type: string
        employee_address:
          $ref: '#/components/schemas/types.Address'
        employee_name:
          type: string
        employer_ein:
          type: string
        employer_name:
          type: string
        error_code:
          type: string
        file:
          type: string
        form_status:
          type: string
        gross_income:
          type: string
        gross_receipts:
          type: string
        guaranteed_payments_services:
          type: string
        net_profit:
          type: string
        ordinary_income:
          type: string
        parsed_at:
          type: string
        retirement_plan:
          type: boolean
        self_employment_earnings:
          type: string
        ssn_last_four:
          type: string
        status:
          $ref: '#/components/schemas/sharedtypes.W2ParseStatus'
        tax_year:
          type: integer
        total_expenses:
          type: string
        warning:
          type: string
    types.EmployeeCensusCheckError:
      type: object
      properties:
        custom:
          type: string
        detail:
          type: string
        duplicate:
          type: boolean
        employee_census_path:
          type: array
          items:
            type: string
        employee_path:
          type: array
          items:
            type: string
        field_names:
          description: >-
            Based on specific data paths, we can render the appropriate UI (eg.
            name should separate first and last name, address should have a full
            address editor, SSN and emails should have validation built-in)
          type: array
          items:
            type: string
        force:
          type: boolean
        instruction:
          type: string
        last_year_value: {}
        plan:
          type: string
        reason:
          type: string
        reviewed:
          type: boolean
    types.Change:
      type: object
      properties:
        data:
          type: string
        field:
          type: string
        from:
          type: string
        to:
          type: string
    types.PlanDates:
      type: object
      properties:
        calculated:
          $ref: '#/components/schemas/types.MoneyTypeDates'
        ee:
          type: string
        er:
          type: string
        er_match:
          type: string
        er_non_elective:
          type: string
        er_safe_harbor:
          type: string
        given:
          $ref: '#/components/schemas/types.MoneyTypeDates'
        overrides:
          $ref: '#/components/schemas/types.MoneyTypeDates'
    types.MoneyTypeStrings:
      type: object
      properties:
        ee:
          type: string
        er:
          type: string
        er_match:
          type: string
        er_non_elective:
          type: string
        er_safe_harbor:
          type: string
    types.PlanCompensation:
      type: object
      properties:
        calculated:
          $ref: '#/components/schemas/types.MoneyTypeFloats'
        ee:
          type: number
        er:
          type: number
        er_match:
          type: number
        er_non_elective:
          type: number
        er_safe_harbor:
          type: number
        given:
          $ref: '#/components/schemas/types.MoneyTypeFloats'
        overrides:
          $ref: '#/components/schemas/types.MoneyTypeFloats'
    types.Exclusions:
      type: object
      properties:
        ee:
          type: boolean
        er_match:
          type: boolean
        er_non_elective:
          type: boolean
        er_safe_harbor:
          type: boolean
    types.Transactions:
      type: object
      properties:
        calculated:
          $ref: '#/components/schemas/types.TransactionFloats'
        ee_pre_tax:
          description: Employee Contributions
          type: number
        ee_roth:
          type: number
        er_match:
          description: Employer Contributions
          type: number
        er_non_elective:
          type: number
        er_qaca_match:
          type: number
        er_safe_harbor_match:
          type: number
        er_safe_harbor_non_elective:
          type: number
        given:
          $ref: '#/components/schemas/types.TransactionFloats'
        gross_minus_exclusions:
          description: Gross pay minus exclusions
          type: number
        gross_pay:
          type: number
        hours_worked:
          type: number
        hpi_compensation:
          type: number
        new_compensation_group:
          type: string
        overrides:
          $ref: '#/components/schemas/types.TransactionFloats'
        prevailing_wage:
          type: number
        statutory_compensation:
          type: number
    types.Vesting:
      type: object
      properties:
        date:
          $ref: '#/components/schemas/types.MoneyTypeDates'
        historical_hos:
          type: number
        nra:
          description: Normal Retirement Age Date
          type: string
        nra_met:
          type: boolean
        status:
          $ref: '#/components/schemas/types.MoneyTypeStrings'
        vested:
          $ref: '#/components/schemas/types.MoneyTypeFloats'
        yos:
          type: integer
    types.Warning:
      type: object
      properties:
        dismiss:
          type: boolean
        fields:
          description: Which fields have triggered this warning
          type: array
          items:
            type: string
        money_type:
          description: Track by money type
          type: string
        reason:
          type: string
    types.EmployeeCensusW2Boxes:
      type: object
      properties:
        box_1:
          type: string
        box_10:
          type: string
        box_11:
          type: string
        box_12:
          type: array
          items:
            $ref: '#/components/schemas/types.EmployeeCensusW2Code'
        box_13_retirement_plan:
          type: boolean
        box_13_statutory_employee:
          type: boolean
        box_13_third_party_sick_pay:
          type: boolean
        box_14:
          type: array
          items:
            $ref: '#/components/schemas/types.EmployeeCensusW2Other'
        box_2:
          type: string
        box_3:
          type: string
        box_4:
          type: string
        box_5:
          type: string
        box_6:
          type: string
        box_7:
          type: string
        box_8:
          type: string
        state_local:
          type: array
          items:
            $ref: '#/components/schemas/types.EmployeeCensusW2StateLocal'
    sharedtypes.W2ParseStatus:
      type: string
      enum:
        - uploaded
        - processing
        - matched
        - needs_review
        - wrong_year
        - failed
      x-enum-varnames:
        - W2ParseStatusUploaded
        - W2ParseStatusProcessing
        - W2ParseStatusMatched
        - W2ParseStatusNeedsReview
        - W2ParseStatusWrongYear
        - W2ParseStatusFailed
    types.MoneyTypeDates:
      type: object
      properties:
        ee:
          type: string
        er:
          type: string
        er_match:
          type: string
        er_non_elective:
          type: string
        er_safe_harbor:
          type: string
    types.MoneyTypeFloats:
      type: object
      properties:
        ee:
          type: number
        er:
          type: number
        er_match:
          type: number
        er_non_elective:
          type: number
        er_safe_harbor:
          type: number
    types.TransactionFloats:
      type: object
      properties:
        ee_pre_tax:
          description: Employee Contributions
          type: number
        ee_roth:
          type: number
        er_match:
          description: Employer Contributions
          type: number
        er_non_elective:
          type: number
        er_qaca_match:
          type: number
        er_safe_harbor_match:
          type: number
        er_safe_harbor_non_elective:
          type: number
        gross_minus_exclusions:
          description: Gross pay minus exclusions
          type: number
        gross_pay:
          type: number
        hours_worked:
          type: number
        hpi_compensation:
          type: number
        prevailing_wage:
          type: number
        statutory_compensation:
          type: number
    types.EmployeeCensusW2Code:
      type: object
      properties:
        amount:
          type: string
        code:
          type: string
    types.EmployeeCensusW2Other:
      type: object
      properties:
        amount:
          type: string
        label:
          type: string
    types.EmployeeCensusW2StateLocal:
      type: object
      properties:
        employer_state_id:
          type: string
        local_income_tax:
          type: string
        local_wages_tips:
          type: string
        locality_name:
          type: string
        state:
          type: string
        state_income_tax:
          type: string
        state_wages_tips:
          type: string
  securitySchemes:
    ApiKeyAuth:
      description: CX API key. Create one in CX under Settings → Advanced → API Keys.
      in: header
      name: x-api-key
      type: apiKey

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.