> ## 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.

# Create Issuer

> Create a new Issuer.

Creates a new fiscal issuer associated with the active tenant.
Requires tenant_admin role or higher.

All database operations use async/await for non-blocking I/O.

Args:
    payload: Issuer creation data
    db: Async database session
    tenant_id: Active tenant ID from authentication context

Returns:
    IssuerResponse: Created issuer data

Raises:
    HTTPException 422: If validation fails



## OpenAPI

````yaml /openapi.json post /issuers
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:
  /issuers:
    post:
      tags:
        - issuers
      summary: Create Issuer
      description: |-
        Create a new Issuer.

        Creates a new fiscal issuer associated with the active tenant.
        Requires tenant_admin role or higher.

        All database operations use async/await for non-blocking I/O.

        Args:
            payload: Issuer creation data
            db: Async database session
            tenant_id: Active tenant ID from authentication context

        Returns:
            IssuerResponse: Created issuer data

        Raises:
            HTTPException 422: If validation fails
      operationId: create_issuer_issuers_post
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
        - name: x-tenant-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Tenant-Id
        - name: factio_access_token
          in: cookie
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Factio Access Token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IssuerCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IssuerResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    IssuerCreate:
      properties:
        ruc:
          type: string
          maxLength: 13
          minLength: 13
          pattern: ^\d{13}$
          title: Ruc
          description: RUC (Registro Único de Contribuyentes) - 13 digits
        razon_social:
          type: string
          maxLength: 300
          minLength: 1
          title: Razon Social
          description: Legal business name (razón social)
        nombre_comercial:
          anyOf:
            - type: string
              maxLength: 300
            - type: 'null'
          title: Nombre Comercial
          description: Trade name (nombre comercial)
        legal_representative:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Legal Representative
          description: Legal representative name
        direccion_matriz:
          type: string
          minLength: 1
          title: Direccion Matriz
          description: Main office address
        tipo_contribuyente:
          type: string
          maxLength: 50
          minLength: 1
          title: Tipo Contribuyente
          description: Taxpayer type (e.g., 'RISE', 'RIMPE', 'General')
        sri_environment:
          $ref: '#/components/schemas/SRIEnvironment'
          description: 'SRI environment: TEST or PRODUCTION'
      type: object
      required:
        - ruc
        - razon_social
        - direccion_matriz
        - tipo_contribuyente
        - sri_environment
      title: IssuerCreate
      description: Schema for creating a new Issuer.
      example:
        direccion_matriz: Av. Principal 123 y Secundaria, Quito, Ecuador
        legal_representative: Jane Doe
        nombre_comercial: Ejemplo Corp
        razon_social: EMPRESA EJEMPLO S.A.
        ruc: '1234567890001'
        sri_environment: TEST
        tipo_contribuyente: General
    IssuerResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        tenant_id:
          type: string
          format: uuid
          title: Tenant Id
        ruc:
          type: string
          title: Ruc
        razon_social:
          type: string
          title: Razon Social
        nombre_comercial:
          anyOf:
            - type: string
            - type: 'null'
          title: Nombre Comercial
        legal_representative:
          anyOf:
            - type: string
            - type: 'null'
          title: Legal Representative
        direccion_matriz:
          type: string
          title: Direccion Matriz
        tipo_contribuyente:
          type: string
          title: Tipo Contribuyente
        sri_environment:
          $ref: '#/components/schemas/SRIEnvironment'
        is_active:
          type: boolean
          title: Is Active
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - tenant_id
        - ruc
        - razon_social
        - nombre_comercial
        - legal_representative
        - direccion_matriz
        - tipo_contribuyente
        - sri_environment
        - is_active
        - created_at
        - updated_at
      title: IssuerResponse
      description: Schema for Issuer response.
      example:
        created_at: '2024-01-01T00:00:00Z'
        direccion_matriz: Av. Principal 123 y Secundaria, Quito, Ecuador
        id: 550e8400-e29b-41d4-a716-446655440000
        is_active: true
        legal_representative: Jane Doe
        nombre_comercial: Ejemplo Corp
        razon_social: EMPRESA EJEMPLO S.A.
        ruc: '1234567890001'
        sri_environment: TEST
        tenant_id: 660e8400-e29b-41d4-a716-446655440000
        tipo_contribuyente: General
        updated_at: '2024-01-01T00:00:00Z'
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SRIEnvironment:
      type: string
      enum:
        - TEST
        - PRODUCTION
      title: SRIEnvironment
      description: SRI environment types.
    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

````