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

# Switch the institution's result channel (Mensageria or DIRECT)

> Switches the channel an institution's results take back to Sisbajud. A human platform-administrator action (institution_channel:write, never held by M2M): an application token or a tenant-carrying token is refused with 403. Every attempt, accepted or refused with 403/409/422, is recorded append-only in the audit trail. 422: DIRECT in a multi-tenant deployment, DIRECT with PLUGIN_AUTH_ENABLED=false, or DIRECT while the stored institution_code is not the 8-character CNPJ root of the RESPONSIBLE GROUPING (CNPJ_INSTITUICAO_RESPONSAVEL), ^[A-Z0-9]{8}$ exactly as stored, never the executing institution's CNPJ. 409: the institution has any open order (in either direction); 409 SBJ-0060: the institution's execution owner is not this executor's M2M subject (another executor's institution, also when the current channel is requested): set the owner before switching. 404: unknown institution. 400: channel is not DIRECT or MENSAGERIA. Requesting the current channel answers 200 with changed=false.



## OpenAPI

````yaml /es/openapi/v3-current/sisbajud-executor.yaml put /v1/institutions/{institutionId}/channel
openapi: 3.1.0
info:
  description: >-
    API for the Lerian SISBAJUD executor, which runs judicial orders on Midaz.
    It covers institution and Midaz connector configuration, orders that need
    attention, ledger-routing checks, credential key rotation and audit
    verification.
  title: Lerian SISBAJUD Executor API
  version: 1.0.0
servers:
  - url: https://api.example.com
    description: >-
      Replace the example host with the URL provided during environment
      onboarding.
security:
  - BearerAuth: []
tags:
  - description: >-
      Institution configuration lifecycle: create (with key provisioning), read,
      and partial update of a connector configuration addressed by institution
      id.
    name: Institution
  - description: >-
      Rotation of the key that wraps an institution's stored connector
      credentials, addressed by institution id.
    name: Security
  - description: 'Admin API: audit-trail integrity verification.'
    name: Admin
paths:
  /v1/institutions/{institutionId}/channel:
    put:
      tags:
        - Institution
      summary: Switch the institution's result channel (Mensageria or DIRECT)
      description: >-
        Switches the channel an institution's results take back to Sisbajud. A
        human platform-administrator action (institution_channel:write, never
        held by M2M): an application token or a tenant-carrying token is refused
        with 403. Every attempt, accepted or refused with 403/409/422, is
        recorded append-only in the audit trail. 422: DIRECT in a multi-tenant
        deployment, DIRECT with PLUGIN_AUTH_ENABLED=false, or DIRECT while the
        stored institution_code is not the 8-character CNPJ root of the
        RESPONSIBLE GROUPING (CNPJ_INSTITUICAO_RESPONSAVEL), ^[A-Z0-9]{8}$
        exactly as stored, never the executing institution's CNPJ. 409: the
        institution has any open order (in either direction); 409 SBJ-0060: the
        institution's execution owner is not this executor's M2M subject
        (another executor's institution, also when the current channel is
        requested): set the owner before switching. 404: unknown institution.
        400: channel is not DIRECT or MENSAGERIA. Requesting the current channel
        answers 200 with changed=false.
      operationId: put-institution-channel
      parameters:
        - description: The institution's unique identifier (UUID).
          in: path
          name: institutionId
          required: true
          schema:
            description: The institution's unique identifier (UUID).
            examples:
              - 550e8400-e29b-41d4-a716-446655440000
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PutInstitutionChannelRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InstitutionChannelResponse'
          description: OK
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Forbidden
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Not Found
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Conflict
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Request Entity Too Large
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Too Many Requests
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Internal Server Error
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Service Unavailable
components:
  schemas:
    PutInstitutionChannelRequest:
      additionalProperties: false
      properties:
        channel:
          description: 'Target channel: DIRECT or MENSAGERIA (exact, upper case).'
          examples:
            - DIRECT
          type: string
      required:
        - channel
      type: object
    InstitutionChannelResponse:
      additionalProperties: false
      properties:
        changed:
          description: False when the institution was already on the requested channel.
          type: boolean
        changedAt:
          description: Instant of the request (UTC).
          format: date-time
          type: string
        changedBy:
          description: Subject of the platform administrator who made the request.
          type: string
        channel:
          description: The channel now in charge.
          type: string
        institutionId:
          description: The institution's unique identifier.
          type: string
        previousChannel:
          description: >-
            The channel before the request (equal to channel when nothing
            changed).
          type: string
      required:
        - institutionId
        - channel
        - previousChannel
        - changed
        - changedBy
        - changedAt
      type: object
    Detail:
      additionalProperties: true
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    ErrorResponse:
      additionalProperties: false
      properties:
        code:
          type: string
        details:
          additionalProperties: {}
          type: object
        message:
          type: string
        title:
          type: string
      required:
        - code
        - title
        - message
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    Upstream:
      additionalProperties: false
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````

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