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

# Generate a business policy description

> Writes a short description of a business policy, with AI. Nothing is saved.

Send the policy as it stands — finished or still being written — with its fields at the top level of the body, as you would send them to the create endpoint. Every field is optional, but at least one of `name`, `actions` and `conditions` must be present; unknown fields are ignored. The answer is a short text in Portuguese, at most 160 characters, ready to use as the policy's `description`.

Approvers are described by their current names, and each condition by its catalog label. The AI model never receives the value of a condition on the payment's counterparty (its document, name, Pix key or account), on a Pix copy-and-paste code, on user or wallet IDs, on a field outside the catalog or on a field with a `maskType` — the description only says such a condition exists. Other values are sent cleaned of invisible characters and shortened — text to 500 characters, and a very large policy is described from a shortened copy of its conditions.

It takes a few seconds. Only organization admins can generate descriptions.


## OpenAPI

````yaml /api-reference/ruleengine.openapi.json post /realms/{realmId}/organizations/{organizationId}/business-policies/generate-description
openapi: 3.0.3
info:
  title: Ruleengine
  version: 1.0.0
  description: >-
    Portão 3 ruleengine API. Every endpoint requires a bearer token in the
    Authorization header (Authorization: Bearer <token>) unless its page states
    otherwise; see the Authentication guide. That requirement is not repeated
    per endpoint. Generated by tools/openapi from code (routes + security) and
    the hand-written spec (request/response bodies). Confidence tiers:
    generated:typed=26 copied:manual=0 unknown=0.
servers:
  - url: https://api.ruleengine.v2.portao3.com.br/
    description: production
  - url: https://api.ruleengine.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Business Policies
  - name: Policy Requests
paths:
  /realms/{realmId}/organizations/{organizationId}/business-policies/generate-description:
    post:
      tags:
        - Business Policies
      summary: Generate a business policy description
      description: >-
        Writes a short description of a business policy, with AI. Nothing is
        saved.
      operationId: >-
        postRealmsByRealmIdOrganizationsByOrganizationIdBusinessPoliciesGenerateDescription
      parameters:
        - name: realmId
          in: path
          required: true
          description: |-
            ID of your realm.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: f495ff0c-ab54-4f99-8e92-ca8682e4de9b
        - name: organizationId
          in: path
          required: true
          description: |-
            ID of the organization the policy belongs to.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                context:
                  description: >-
                    The policy's `context`, which decides how its condition
                    fields are named in the description. Defaults to `PAYMENT`.
                  example: PAYMENT
                  type: string
                name:
                  description: The policy's name.
                  example: Payments over R$ 5,000
                  type: string
                description:
                  description: The current description, if any. It is not reused.
                  type: string
                order:
                  description: The policy's evaluation order.
                  example: 10
                  type: number
                status:
                  description: The policy's status.
                  example: ACTIVE
                  type: string
                actions:
                  description: The policy's `actions`, as on create.
                  type: object
                  properties:
                    hierarchy:
                      description: Whether the approvers decide one at a time.
                      example: false
                      type: boolean
                    autoAction:
                      description: '`APPROVE`, `DENY` or `NONE` (an approval request).'
                      example: NONE
                      type: string
                    moveBalance:
                      description: The policy's `moveBalance`, as on create.
                      type: object
                      additionalProperties: {}
                    approvals:
                      description: The policy's approvers — at most 50.
                      maxItems: 50
                      type: array
                      items:
                        type: object
                        properties:
                          type:
                            description: '`USER` or `GROUP`.'
                            example: GROUP
                            type: string
                          id:
                            description: >-
                              ID of the user or group. Its current name is
                              looked up and used in the description; an approver
                              that cannot be found is described as incomplete.
                            example: 8b0e4c2a-1f6d-4e3b-a9c7-2d5f8e1b6c30
                            type: string
                          name:
                            description: >-
                              Accepted, unlike on create and update, but never
                              used: the name is always looked up by `id`.
                            type: string
                conditions:
                  description: >-
                    The policy's `conditions`, as on create. Incomplete
                    conditions are fine: each item is described as far as it
                    goes.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  description:
                    type: string
                    description: >-
                      A short description of the policy in Portuguese, at most
                      160 characters.
                    example: >-
                      Pagamentos acima de R$ 5.000,00 precisam da aprovação do
                      grupo Financeiro, com saldo da conta principal.
                required:
                  - description
                description: A generated description of the policy.
        '403':
          description: >-
            `BUSINESS_POLICY_FORBIDDEN` — You are not an admin of the
            organization.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - BUSINESS_POLICY_FORBIDDEN
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - RULE_ENGINE
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: BUSINESS_POLICY_FORBIDDEN
                origin: RULE_ENGINE
                message: You do not have permission to manage business policies
        '422':
          description: >-
            `BAD_REQUEST` — A path parameter is invalid, a field has the wrong
            type, or there is nothing to describe (none of `name`, `actions` and
            `conditions`); `fields` lists each problem.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - BAD_REQUEST
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - RULE_ENGINE
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                  fields:
                    type: array
                    description: >-
                      One entry per invalid request field (validation errors
                      only).
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                          description: >-
                            Path of the invalid field, e.g. `label` or
                            `values[0].value`.
                          example: label
                        message:
                          type: string
                          description: Why the field was rejected.
                          example: label is required
                        code:
                          type: string
                          description: >-
                            `<FIELD>_<REASON>` — e.g. `LABEL_REQUIRED`,
                            `TYPE_ONE_OF`, `VALUES_VALUE_TYPE_ERROR`.
                          example: LABEL_REQUIRED
                        values:
                          type: array
                          items:
                            type: string
                          description: >-
                            The accepted values, when the field is an
                            enumeration.
                      required:
                        - field
                        - message
                        - code
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: BAD_REQUEST
                origin: RULE_ENGINE
                message: >-
                  Bad Request: Your request is invalid or incomplete. Please
                  make sure you are requesting with the right fields.
                fields:
                  - field: order
                    message: 'Invalid input: expected number, received string'
                    code: ORDER_TYPE_ERROR
        '500':
          description: >-
            `DESCRIPTION_GENERATION_FAILED` — The description could not be
            generated right now; try again.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - DESCRIPTION_GENERATION_FAILED
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - RULE_ENGINE
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: DESCRIPTION_GENERATION_FAILED
                origin: RULE_ENGINE
                message: Description generation failed

````

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