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

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# Créer des règles

> Crée une ou plusieurs règles de ciblage qui déterminent quels paiements refusés déclenchent une campagne.

Crée une ou plusieurs règles pour une campagne. Toutes les règles actives doivent être satisfaites pour qu'un paiement déclenche la campagne (logique AND).

Consultez la [référence des opérateurs conditionnels](https://docs.y.uno/fr/reference/communications-campaigns.md#conditional-operators-reference) pour plus d'informations sur leur utilisation.


## OpenAPI

````yaml openapi/fr/communications-campaigns/create-rules.json POST /campaigns/{campaign_id}/rules
openapi: 3.0.0
info:
  version: 1.0.0
  title: Communications Campaigns
servers:
  - url: https://api-sandbox.y.uno/v1
    description: Sandbox
  - url: https://api.y.uno/v1
    description: Production (US)
security:
  - public-api-key: []
    private-secret-key: []
paths:
  /campaigns/{campaign_id}/rules:
    post:
      operationId: post_campaigns-campaign-id-rules
      parameters:
        - in: path
          name: campaign_id
          schema:
            type: string
          required: true
          description: L'identifiant de la campagne (UUID).
      requestBody:
        content:
          application/json:
            schema:
              type: array
              description: >-
                Tableau d'objets règle. Envoyez le tableau comme corps de la
                requête, sans objet englobant.
              items:
                type: object
                properties:
                  rule_type:
                    type: string
                    description: >-
                      Type de règle (voir la [référence des types de
                      règles](/fr/reference/communications-campaigns#rule-types-reference))
                  values:
                    type: array
                    items:
                      type: string
                    description: >-
                      Tableau de valeurs de type chaîne à comparer. Non
                      obligatoire pour `UNIQUE_BY_USER`.
                  conditional:
                    type: string
                    description: >-
                      Opérateur de comparaison. Non obligatoire pour
                      `USER_COMMS_PER_DAY` ni pour `UNIQUE_BY_USER`. Voir la
                      [référence des opérateurs
                      conditionnels](/fr/reference/communications-campaigns#conditional-operators-reference).
                  metadata_key:
                    type: string
                    description: >-
                      Obligatoire lorsque `rule_type` vaut `METADATA`. Le nom du
                      champ de métadonnées à évaluer.
                required:
                  - rule_type
            examples:
              Basic declined payment recovery:
                summary: Basic declined payment recovery
                value:
                  - rule_type: PAYMENT_STATUS
                    values:
                      - DECLINED
                    conditional: EQUAL
                  - rule_type: PAYMENT_METHOD
                    values:
                      - CARD
                    conditional: EQUAL
              High-value transaction recovery via phone call:
                summary: High-value transaction recovery via phone call
                value:
                  - rule_type: PAYMENT_STATUS
                    values:
                      - DECLINED
                    conditional: EQUAL
                  - rule_type: AMOUNT_AND_CURRENCY
                    values:
                      - '500'
                      - USD
                    conditional: GREATER_THAN
                  - rule_type: USER_COMMS_PER_DAY
                    values:
                      - '1'
              Provider-specific recovery with amount range:
                summary: Provider-specific recovery with amount range
                value:
                  - rule_type: PAYMENT_STATUS
                    values:
                      - DECLINED
                    conditional: EQUAL
                  - rule_type: PROVIDER
                    values:
                      - stripe
                      - adyen
                    conditional: ONE_OF
                  - rule_type: AMOUNT
                    values:
                      - '10000'
                      - '500000'
                    conditional: BETWEEN
                  - rule_type: CURRENCY
                    values:
                      - COP
                    conditional: EQUAL
              Metadata-based segmentation:
                summary: Metadata-based segmentation
                value:
                  - rule_type: PAYMENT_STATUS
                    values:
                      - DECLINED
                    conditional: EQUAL
                  - rule_type: METADATA
                    metadata_key: vertical
                    values:
                      - restaurant
                      - grocery
                    conditional: ONE_OF
                  - rule_type: METADATA
                    metadata_key: customer_tier
                    values:
                      - premium
                      - gold
                    conditional: ONE_OF
                  - rule_type: UNIQUE_BY_USER
              Exclude specific response codes:
                summary: Exclude specific response codes
                value:
                  - rule_type: PAYMENT_STATUS
                    values:
                      - DECLINED
                    conditional: EQUAL
                  - rule_type: ISO_RESPONSE_CODE
                    values:
                      - '14'
                      - '43'
                      - '59'
                    conditional: NOT_ONE_OF
      responses:
        '201':
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          example: f1e2d3c4-b5a6-7890-abcd-ef1234567890
                        rule_type:
                          type: string
                          example: PAYMENT_STATUS
                        values:
                          type: array
                          items:
                            type: string
                          example:
                            - DECLINED
                        conditional:
                          type: string
                          example: EQUAL
                        metadata_key:
                          type: string
                          nullable: true
                          example: null
                        status:
                          type: string
                          example: ACTIVE
                        created_at:
                          type: string
                          example: '2025-07-01T12:05:00Z'
                        updated_at:
                          type: string
                          example: '2025-07-01T12:05:00Z'
              examples:
                Created:
                  summary: Created
                  value:
                    data:
                      - id: f1e2d3c4-b5a6-7890-abcd-ef1234567890
                        rule_type: PAYMENT_STATUS
                        values:
                          - DECLINED
                        conditional: EQUAL
                        metadata_key: null
                        status: ACTIVE
                        created_at: '2025-07-01T12:05:00Z'
                        updated_at: '2025-07-01T12:05:00Z'
                      - id: a9b8c7d6-e5f4-3210-abcd-ef1234567890
                        rule_type: CURRENCY
                        values:
                          - COP
                        conditional: EQUAL
                        metadata_key: null
                        status: ACTIVE
                        created_at: '2025-07-01T12:05:00Z'
                        updated_at: '2025-07-01T12:05:00Z'
                      - id: 11223344-5566-7788-99aa-bbccddeeff00
                        rule_type: AMOUNT
                        values:
                          - '50000'
                        conditional: GREATER_THAN
                        metadata_key: null
                        status: ACTIVE
                        created_at: '2025-07-01T12:05:00Z'
                        updated_at: '2025-07-01T12:05:00Z'
          description: Créé
        '404':
          description: Introuvable. La campagne n'existe pas pour ce compte.
          content:
            application/json:
              examples:
                Not Found:
                  value:
                    code: NOT_FOUND
                    messages:
                      - Not Found
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: NOT_FOUND
                  messages:
                    type: array
                    items:
                      type: string
                      example: Not Found
components:
  securitySchemes:
    public-api-key:
      type: apiKey
      in: header
      name: public-api-key
    private-secret-key:
      type: apiKey
      in: header
      name: private-secret-key

````

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