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

# Bind a policy to a ledger scenario

> Use this endpoint to attach a policy to the transactions of a ledger its selector matches, with one instruction per control (rules, limits): ENFORCE, ADVISORY, AUDIT, OFF or INHERIT. Bindings of one policy in one ledger are ordered by position; for each control the first binding that matches and does not INHERIT is the one that decides, and with none the ledger's fallback mode applies (GET /bindings/effective shows the resolution). A binding has no draft and no history. A taken position answers 409 (0592). OFF evaluates nothing on an advisory fallback; on an enforce fallback it runs as AUDIT (evaluated and recorded, never refuses). The ledger's decide resolves each control of every published policy this way.



## OpenAPI

````yaml /pt/openapi/v3-current/tracer.yaml post /v1/bindings
openapi: 3.1.0
info:
  title: Midaz Tracer API
  description: >-
    Reference for Midaz Tracer transaction validation, fraud rules, spending
    limits, policies and bindings, and audit events.
  version: 4.0.0
servers:
  - url: https://tracer.sandbox.lerian.net
security: []
tags:
  - name: Validations API
  - name: Rules API
  - name: Limits API
  - name: Policies API
  - name: Bindings API
  - name: Audit Events API
  - name: Dashboards API
paths:
  /v1/bindings:
    post:
      tags:
        - Bindings API
      summary: Bind a policy to a ledger scenario
      description: >-
        Use this endpoint to attach a policy to the transactions of a ledger its
        selector matches, with one instruction per control (rules, limits):
        ENFORCE, ADVISORY, AUDIT, OFF or INHERIT. Bindings of one policy in one
        ledger are ordered by position; for each control the first binding that
        matches and does not INHERIT is the one that decides, and with none the
        ledger's fallback mode applies (GET /bindings/effective shows the
        resolution). A binding has no draft and no history. A taken position
        answers 409 (0592). OFF evaluates nothing on an advisory fallback; on an
        enforce fallback it runs as AUDIT (evaluated and recorded, never
        refuses). The ledger's decide resolves each control of every published
        policy this way.
      operationId: createBinding
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBindingRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BindingResponse'
          description: Created
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Internal Server Error
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    CreateBindingRequest:
      additionalProperties: false
      properties:
        ledgerId:
          description: Ledger whose transactions the binding applies to.
          type: string
        limitsAction:
          description: >-
            Instruction for the policy's limits; INHERIT leaves it to the next
            binding or the fallback.
          enum:
            - ENFORCE
            - ADVISORY
            - AUDIT
            - 'OFF'
            - INHERIT
          type: string
        policyId:
          description: Policy the binding instructs.
          type: string
        position:
          description: >-
            Order among the policy's bindings in the ledger, 1 first; omitted or
            0 appends.
          format: int64
          type: integer
        rulesAction:
          description: >-
            Instruction for the policy's rules; INHERIT leaves it to the next
            binding or the fallback.
          enum:
            - ENFORCE
            - ADVISORY
            - AUDIT
            - 'OFF'
            - INHERIT
          type: string
        selector:
          $ref: '#/components/schemas/BindingSelector'
          description: >-
            Scheme the binding matches, compared without case; {} matches every
            transaction of the ledger. Any key other than scheme is refused.
      required:
        - ledgerId
        - policyId
        - selector
        - rulesAction
        - limitsAction
      type: object
    BindingResponse:
      additionalProperties: false
      properties:
        bindingId:
          type: string
        createdAt:
          format: date-time
          type: string
        ledgerId:
          type: string
        limitsAction:
          enum:
            - ENFORCE
            - ADVISORY
            - AUDIT
            - 'OFF'
            - INHERIT
          type: string
        policyId:
          type: string
        position:
          format: int64
          type: integer
        rulesAction:
          enum:
            - ENFORCE
            - ADVISORY
            - AUDIT
            - 'OFF'
            - INHERIT
          type: string
        selector:
          $ref: '#/components/schemas/BindingSelector'
        updatedAt:
          format: date-time
          type: string
      required:
        - bindingId
        - ledgerId
        - policyId
        - position
        - selector
        - rulesAction
        - limitsAction
        - createdAt
        - updatedAt
      type: object
    Error:
      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
    BindingSelector:
      additionalProperties: false
      properties:
        scheme:
          type: string
      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
    ApiKeyAuth:
      description: Static API key presented in the X-API-Key header.
      in: header
      name: X-API-Key
      type: apiKey

````

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