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

# Simular política

> O que uma fonte veria de um perfil, item a item, antes de você liberar o acesso.



## OpenAPI

````yaml openapi/pt/cell.json POST /v1/policy/simulate
openapi: 3.1.0
info:
  title: API de dados da Niadra
  version: '1'
  description: >-
    Escrita, contexto, histórico, objetos, identidade, privacidade e governança
    de um espaço. Cada espaço tem um endereço estável, com o espaço e a região
    no nome.
servers:
  - url: https://{space}.{region}.api.niadra.com
    variables:
      space:
        default: acme-prod
        description: O espaço, que vem na chave de fonte.
      region:
        default: us-east-1
        description: A região do espaço, que também vem na chave.
security: []
paths:
  /v1/policy/simulate:
    post:
      tags:
        - governance
      summary: Simular política
      description: >-
        Mostra o que uma fonte ou uma audiência receberia de um perfil, item a
        item, antes de você liberar o acesso: o efeito da política em cada item
        (`allow`, `mask` ou `deny`), a regra que decidiu e o texto que o agente
        receberia. Nada é entregue e nenhum comprovante de leitura é gravado; a
        simulação em si fica registrada como ação administrativa.


        **Autenticação.** Token de pessoa do Console com o papel `security` (ou
        admin), ou chave de fonte com o escopo `admin`.
      operationId: simulate_v1_policy_simulate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SimulateRequest'
            example:
              profile_id: 0192f7a0-3b2e-7d41-8c5a-2e9f4b7a1c03
              source_id: 0192f79e-11aa-7b20-9f3e-6c1d2e4f5a60
              verification: V1
              view: voice
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimulateResponse'
              example:
                audience: customer_agent
                verification: V1
                policy_version: pol-14
                items:
                  - id: act_01J8ZK
                    kind: action
                    category: billing
                    effect: allow
                    delivered: true
                    rule: billing-to-service
                    reason: null
                  - id: fct_doc
                    kind: fact
                    category: document
                    effect: deny
                    delivered: false
                    rule: document-needs-v3
                    reason: verification
                withheld:
                  verification: 1
                text: >-
                  <context source="niadra" version="1" view="voice" level="V1"
                  withheld="1">...</context>
          description: Os itens simulados, os retidos por motivo e o texto resultante.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: O pedido não bate com o contrato.
      security:
        - sourceKey: []
        - personToken: []
components:
  schemas:
    SimulateRequest:
      additionalProperties: false
      properties:
        audience:
          anyOf:
            - $ref: '#/components/schemas/Audience'
            - type: 'null'
        profile_id:
          format: uuid
          title: Profile Id
          type: string
        purposes:
          items:
            maxLength: 256
            minLength: 1
            type: string
          title: Purposes
          type: array
        source_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          description: Simula como esta fonte; ou informe a audiência e as finalidades.
          title: Source Id
        verification:
          $ref: '#/components/schemas/Verification'
          default: V1
        view:
          default: chat
          pattern: >-
            ^(voice|chat|brief|full|custom|account|partner|task:[a-z0-9_]{1,40})$
          title: View
          type: string
      required:
        - profile_id
      title: SimulateRequest
      type: object
    SimulateResponse:
      additionalProperties: false
      properties:
        audience:
          $ref: '#/components/schemas/Audience'
        items:
          items:
            $ref: '#/components/schemas/SimulatedItem'
          title: Items
          type: array
        policy_version:
          title: Policy Version
          type: string
        text:
          description: O contexto que quem lê receberia.
          title: Text
          type: string
        verification:
          $ref: '#/components/schemas/Verification'
        withheld:
          additionalProperties:
            type: integer
          title: Withheld
          type: object
      required:
        - policy_version
        - verification
        - audience
        - items
        - withheld
        - text
      title: SimulateResponse
      type: object
    Problem:
      additionalProperties: false
      description: >-
        Detalhes do problema no formato da RFC 9457; `code` vem do catálogo de
        erros versionado.
      properties:
        code:
          title: Code
          type: string
        detail:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Detail
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Request Id
        status:
          title: Status
          type: integer
        title:
          title: Title
          type: string
        type:
          default: about:blank
          title: Type
          type: string
      required:
        - title
        - status
        - code
      title: Problem
      type: object
    Audience:
      enum:
        - customer_agent
        - internal_agent
        - human
        - reviewer
        - analyst
        - trigger_target
        - export
      title: Audience
      type: string
    Verification:
      description: >-
        Nível de verificação da sessão. V0 autodeclarado, V1 plausível pelo
        canal, V2 atestado pelo canal, V3 desafiado (OTP ou login), V4 conferido
        com um sistema de registro ou por um atendente. `no_customer` vale para
        tarefas sem cliente presente e só é aceito de fontes de agente interno.
      enum:
        - V0
        - V1
        - V2
        - V3
        - V4
        - no_customer
      title: Verification
      type: string
    SimulatedItem:
      additionalProperties: false
      properties:
        category:
          title: Category
          type: string
        delivered:
          description: Falso quando o item é permitido, mas ficou de fora pelo orçamento.
          title: Delivered
          type: boolean
        effect:
          enum:
            - allow
            - mask
            - deny
          title: Effect
          type: string
        id:
          title: Id
          type: string
        kind:
          title: Kind
          type: string
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
        rule:
          anyOf:
            - type: string
            - type: 'null'
          title: Rule
      required:
        - id
        - kind
        - category
        - effect
        - delivered
      title: SimulatedItem
      type: object
  securitySchemes:
    sourceKey:
      type: http
      scheme: bearer
      description: nia_sk_...
    personToken:
      type: http
      scheme: bearer
      bearerFormat: JWT

````