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

# Create a deal

> Creates a deal: what your organization charges a payer for, how it is paid and when.

The deal belongs to your organization alone — there is no contract to create first. Send each party by its `id` and `entityType`: a `CUSTOMER` is one of your organization's customers, an `ORGANIZATION` is a Portão 3 organization (send its `wallet` to use another than its default one). The document, name, e-mail, phone and address are filled in from the customer or the organization, and each organization's wallet is resolved for you; a payer whose phone is missing, or is not a valid phone number, is created without one.

The invoices, the payment-method rules and the response are those of the Billing API's `Create a deal`, which this route calls once the parties are completed; its errors (such as `WALLET_NOT_ACTIVE`, `PARTY_REALM_ORG_NOT_FOUND` or `BILLING_P2P_NOT_ENABLED`) reach you unchanged, with `origin: BILLING`. Any member of the organization, or an admin of the realm, can create one. Answers the deal it created.


## OpenAPI

````yaml /api-reference/platform.openapi.json post /realms/{realmId}/organizations/{organizationId}/deals
openapi: 3.0.3
info:
  title: Platform
  version: 1.0.0
  description: >-
    Portão 3 platform 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=68 copied:manual=6 unknown=53.
servers:
  - url: https://api.platform.v2.portao3.com.br/
    description: production
  - url: https://api.platform.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Wallets
  - name: Cards
  - name: PIX
  - name: PIX Keys (DICT)
  - name: Boleto
  - name: Transfers
  - name: Scheduled Payments
  - name: Transactions & Statements
  - name: Invoices
  - name: Contracts & Deals
  - name: Billing
  - name: Notifications
  - name: Users
  - name: Vehicles
paths:
  /realms/{realmId}/organizations/{organizationId}/deals:
    post:
      tags:
        - Contracts & Deals
      summary: Create a deal
      description: >-
        Creates a deal: what your organization charges a payer for, how it is
        paid and when.
      operationId: postRealmsByRealmIdOrganizationsByOrganizationIdDeals
      parameters:
        - name: realmId
          in: path
          required: true
          schema:
            type: string
        - name: organizationId
          in: path
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  description:
                    type: string
                  realm:
                    type: string
                  organization:
                    type: string
                  contract:
                    type: string
                  chargeType:
                    type: string
                    enum:
                      - SINGLE
                      - RECURRENT
                      - SUBSCRIPTION
                  status:
                    type: string
                    enum:
                      - OPEN
                      - CANCELED
                      - TERMINATED
                      - EXPIRED
                      - REVOKED
                  startAt:
                    type: string
                    format: date-time
                  endAt:
                    type: string
                    format: date-time
                    nullable: true
                  products:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        identifier:
                          type: string
                        description:
                          type: string
                        price:
                          type: number
                        type:
                          type: string
                          enum:
                            - RECURRENT
                            - ONE_TIME
                            - ON_EVENT
                        chargeMethod:
                          type: string
                          enum:
                            - INSTANT
                            - LATER
                        billingRule:
                          type: object
                          properties:
                            id:
                              type: string
                            name:
                              type: string
                            calculationMethod:
                              type: string
                              enum:
                                - UNIT
                                - PERCENTAGE
                            dataSource:
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - DATABASE
                                    - API
                                collection:
                                  type: string
                                filter:
                                  type: object
                                field:
                                  type: string
                                aggregate:
                                  type: string
                              required:
                                - type
                          required:
                            - id
                            - name
                            - calculationMethod
                            - dataSource
                        idProduct:
                          type: string
                      required:
                        - id
                        - identifier
                        - price
                        - type
                        - chargeMethod
                  paymentMethods:
                    type: array
                    items:
                      type: string
                      enum:
                        - BANK_SLIP
                        - PIX_INITIATION
                        - PIX_AUTOMATIC
                        - PIX
                        - P2P
                  secondaryPaymentMethods:
                    type: array
                    items:
                      type: string
                      enum:
                        - BANK_SLIP
                        - PIX_INITIATION
                        - PIX_AUTOMATIC
                        - PIX
                        - P2P
                  creditParties:
                    type: array
                    items:
                      type: object
                      properties:
                        document:
                          type: string
                        name:
                          type: string
                        email:
                          type: string
                        unit:
                          type: string
                          enum:
                            - PERCENTAGE
                        amount:
                          type: number
                        account:
                          type: object
                          properties:
                            email:
                              type: string
                            bank:
                              type: string
                              enum:
                                - P3
                            type:
                              type: string
                              enum:
                                - WALLET
                            identifier:
                              type: object
                              properties:
                                realm:
                                  type: string
                                organization:
                                  type: string
                                account:
                                  type: string
                                wallet:
                                  type: string
                              required:
                                - realm
                                - organization
                                - account
                                - wallet
                          required:
                            - bank
                            - identifier
                            - type
                      required:
                        - document
                        - name
                        - email
                        - unit
                        - amount
                        - account
                  debitParties:
                    type: array
                    items:
                      type: object
                      properties:
                        document:
                          type: string
                        name:
                          type: string
                        email:
                          type: string
                        phone:
                          type: string
                          description: >-
                            Phone of the payer, in E.164 format (`+`, the
                            country code and the number, digits only). Absent
                            when the deal has none.
                        unit:
                          type: string
                          enum:
                            - PERCENTAGE
                        amount:
                          type: number
                        account:
                          type: object
                          properties:
                            email:
                              type: string
                            bank:
                              type: string
                              enum:
                                - P3
                            type:
                              type: string
                              enum:
                                - WALLET
                            identifier:
                              type: object
                              properties:
                                realm:
                                  type: string
                                organization:
                                  type: string
                                account:
                                  type: string
                                wallet:
                                  type: string
                              required:
                                - realm
                                - organization
                                - account
                                - wallet
                          required:
                            - bank
                            - type
                        address:
                          type: object
                          properties:
                            street:
                              type: string
                            number:
                              type: string
                            complement:
                              type: string
                            neighborhood:
                              type: string
                            city:
                              type: string
                            state:
                              type: string
                            postalCode:
                              type: string
                          required:
                            - city
                            - neighborhood
                            - number
                            - postalCode
                            - state
                            - street
                      required:
                        - document
                        - name
                        - email
                        - unit
                        - amount
                        - address
                  fine:
                    type: object
                    properties:
                      amountType:
                        type: string
                        enum:
                          - FIXED_VALUE
                          - PERCENT
                      amount:
                        type: number
                    required:
                      - amountType
                      - amount
                  interest:
                    type: object
                    properties:
                      amount:
                        type: number
                      amountType:
                        type: string
                        enum:
                          - AMOUNT_CALENDAR_DAYS
                          - AMOUNT_WORKING_DAYS
                          - PERCENT_POINT_PER_DAY_CALENDAR_DAYS
                          - PERCENT_POINT_PER_DAY_WORKING_DAYS
                    required:
                      - amount
                      - amountType
                  discount:
                    type: object
                    properties:
                      amount:
                        type: number
                      amountType:
                        type: string
                        enum:
                          - AMOUNT_PER_ANTECIPATION
                          - PERCENT_PER_ANTECIPATION
                    required:
                      - amount
                      - amountType
                  closingAt:
                    type: string
                  firstChargeDate:
                    type: string
                    format: date-time
                  numberOfInstallments:
                    type: number
                  paymentUrl:
                    type: string
                  paymentLinkValidity:
                    type: string
                    format: date-time
                    nullable: true
                  dueAt:
                    type: string
                  settings:
                    type: object
                    properties:
                      createAllInvoicesOnStart:
                        type: boolean
                      disableOpenStatus:
                        type: boolean
                      callBackUrlForPaymentProvider:
                        type: object
                        properties:
                          success:
                            type: string
                          pending:
                            type: string
                          error:
                            type: string
                      invoiceNameType:
                        type: string
                        enum:
                          - DEAL_DESCRIPTION
                      paymentLinkId:
                        type: string
                    required:
                      - createAllInvoicesOnStart
                      - disableOpenStatus
                  createdBy:
                    type: string
                  updatedBy:
                    type: string
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                  externalCard:
                    type: object
                    properties:
                      id:
                        type: string
                      token:
                        type: string
                      lastFourDigits:
                        type: string
                    required:
                      - id
                      - token
                      - lastFourDigits
                required:
                  - id
                  - realm
                  - organization
                  - chargeType
                  - status
                  - startAt
                  - products
                  - paymentMethods
                  - creditParties
                  - debitParties
                  - closingAt
                  - firstChargeDate
                  - numberOfInstallments
                  - dueAt
                  - createdBy
                  - updatedBy
                  - createdAt
                  - updatedAt
        '400':
          description: >-
            `INVALID_PARTY_ENTITY_TYPE` — A receiver has `entityType`
            `CUSTOMER`: only organizations can receive.
          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:
                      - INVALID_PARTY_ENTITY_TYPE
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - PLATFORM
                    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: INVALID_PARTY_ENTITY_TYPE
                origin: PLATFORM
                message: Invalid party entity type
        '403':
          description: >-
            `FORBIDDEN_BILLING` — You are not a member of the organization nor
            an admin of the realm.
          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:
                      - FORBIDDEN_BILLING
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - PLATFORM
                    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: FORBIDDEN_BILLING
                origin: PLATFORM
                message: You do not have permission to perform this action on billing
        '422':
          description: >-
            `BAD_REQUEST` — The body is invalid — a missing field, a party `id`
            that is not a valid ID, more than one payer, a `firstChargeDate` in
            the past or breaking the PIX rules; `fields` lists each one.
          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:
                      - PLATFORM
                    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: PLATFORM
                message: >-
                  Bad Request: Your request is invalid or incomplete. Please
                  make sure you are requesting with the right fields.
                fields:
                  - field: id
                    message: 'Invalid input: expected string, received undefined'
                    code: ID_REQUIRED

````

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