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

# Validate Ruc

> Validate an issuer RUC against SRI catastro and return contributor data.

This endpoint is used during the onboarding company step to validate the RUC
before saving the draft. It performs a live SRI lookup and autofills legalName
and address when those fields are empty.

Requires an active onboarding session (validated via onboarding_ticket).

Returns ValidateRucResponse with:
- valid=true when RUC is found and contributor is active
- valid=false with error code when RUC is not found, inactive, or SRI is unavailable



## OpenAPI

````yaml /openapi.json post /auth/onboarding/ruc-validate
openapi: 3.1.0
info:
  title: Factio SRI API
  description: >-
    Plataforma headless, multi-tenant, API-first para emitir comprobantes
    electrónicos válidos ante el SRI de Ecuador.


    ## Autenticación


    Soporta tres métodos:

    - **JWT Bearer por Google OAuth**: `/auth/google/callback`

    - **JWT Bearer por email/password**: `/auth/login`

    - **API Key**: header `X-API-Key` con clave generada en `/auth/api-keys`


    ## Multi-tenant


    El aislamiento por tenant combina PostgreSQL RLS y validaciones explícitas
    en backend. El `tenant_id` se resuelve desde el contexto de autenticación.


    ## Flujo de Emisión


    1. `POST /documents` — reserva secuencial y encola el documento (responde
    202)

    2. `GET /documents/{id}` — consulta el estado actual por polling

    3. Cuando `status = AUTHORIZED`, el campo `authorization_number` contiene la
    clave de autorización del SRI


    Documentación completa en https://docs.factioapp.com
  version: 0.1.0
servers:
  - url: http://localhost:8000
    description: Local
  - url: https://api.factioapp.com
    description: Producción
  - url: https://api.staging.factioapp.com
    description: Sandbox (datos de prueba, sin efecto fiscal real)
security: []
paths:
  /auth/onboarding/ruc-validate:
    post:
      tags:
        - Authentication
      summary: Validate Ruc
      description: >-
        Validate an issuer RUC against SRI catastro and return contributor data.


        This endpoint is used during the onboarding company step to validate the
        RUC

        before saving the draft. It performs a live SRI lookup and autofills
        legalName

        and address when those fields are empty.


        Requires an active onboarding session (validated via onboarding_ticket).


        Returns ValidateRucResponse with:

        - valid=true when RUC is found and contributor is active

        - valid=false with error code when RUC is not found, inactive, or SRI is
        unavailable
      operationId: validate_ruc_auth_onboarding_ruc_validate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidateRucRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidateRucResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ValidateRucRequest:
      properties:
        ruc:
          type: string
          pattern: ^\d{13}$
          title: Ruc
          description: RUC to validate against SRI
        onboarding_ticket:
          type: string
          title: Onboarding Ticket
          description: Short-lived onboarding ticket to validate session
      type: object
      required:
        - ruc
        - onboarding_ticket
      title: ValidateRucRequest
    ValidateRucResponse:
      properties:
        valid:
          type: boolean
          title: Valid
          description: Whether the RUC was found and is active
        source:
          type: string
          enum:
            - sri_cache
            - sri_live
            - not_found
          title: Source
          description: Lookup source
        ruc:
          type: string
          title: Ruc
          description: The validated RUC
        legal_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Legal Name
          description: Razón social from SRI
        trade_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Trade Name
          description: Nombre comercial from SRI
        address:
          anyOf:
            - type: string
            - type: 'null'
          title: Address
          description: DirecciónCompleta from SRI
        contributor_status:
          anyOf:
            - type: string
            - type: 'null'
          title: Contributor Status
          description: EstadoContribuyenteRuc from SRI
        contributor_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Contributor Type
          description: TipoContribuyente from SRI
        legal_representative_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Legal Representative Name
          description: Primer representante legal del contribuyente
        sri_data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Sri Data
          description: Raw payload returned by SRI catastro
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: >-
            Error code if validation failed: not_found, inactive,
            sri_unavailable
        establishments:
          items:
            $ref: '#/components/schemas/IssuerLookupEstablishmentResponse'
          type: array
          title: Establishments
          description: Establecimientos asociados al RUC
      type: object
      required:
        - valid
        - source
        - ruc
      title: ValidateRucResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    IssuerLookupEstablishmentResponse:
      properties:
        number:
          type: string
          title: Number
          description: Número de establecimiento SRI
        type:
          anyOf:
            - type: string
            - type: 'null'
          title: Type
          description: Tipo de establecimiento
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Nombre comercial del establecimiento
        address:
          anyOf:
            - type: string
            - type: 'null'
          title: Address
          description: Dirección completa del establecimiento
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
          description: Estado del establecimiento
        is_matrix:
          type: boolean
          title: Is Matrix
          description: Indica si es la matriz
        sri_data:
          additionalProperties: true
          type: object
          title: Sri Data
          description: Payload crudo devuelto por SRI
      type: object
      required:
        - number
        - is_matrix
      title: IssuerLookupEstablishmentResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````