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

# Criação de oportunidade

> Adiciona nova oportunidade



## OpenAPI

````yaml /api-reference/oportunidades.yaml post /opportunity
openapi: 3.0.4
info:
  title: API de Oportunidades
  description: API de integração de Oportunidades.
  contact:
    email: ti@fretatech.com.br
  version: 1.0.0
servers:
  - url: https://fretatech.com.br/api
security: []
tags:
  - name: Oportunidades
    description: Operações com oportunidades
  - name: Origens de Oportunidades
    description: Operações com origens de oportunidades
paths:
  /opportunity:
    post:
      tags:
        - Oportunidades
      summary: Criação de oportunidade
      description: Adiciona nova oportunidade
      operationId: createOpportunity
      requestBody:
        description: Adiciona nova oportunidade
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpportunityRequest'
          application/xml:
            schema:
              $ref: '#/components/schemas/OpportunityRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/OpportunityRequest'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpportunityResponse'
            application/xml:
              schema:
                $ref: '#/components/schemas/OpportunityResponse'
        '400':
          description: Invalid input
        '422':
          description: Validation exception
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    OpportunityRequest:
      type: object
      properties:
        source:
          type: string
          example: primeira
          description: Fonte da oportunidade
        external_id:
          type: string
          example: abc123
          nullable: true
        description:
          type: string
          nullable: true
          example: a
        customer:
          $ref: '#/components/schemas/Customer'
        fields:
          type: array
          items:
            $ref: '#/components/schemas/Field'
      required:
        - source
        - customer
        - fields
      xml:
        name: opportunityRequest
    OpportunityResponse:
      type: object
      properties:
        msg:
          type: string
          example: Oportunidade criada com sucesso
        opportunity:
          $ref: '#/components/schemas/Opportunity'
      xml:
        name: opportunityResponse
    Error:
      type: object
      properties:
        msg:
          type: string
          example: Erro interno no servidor
        error:
          type: string
          example: Internal Server Error
      xml:
        name: error
    Customer:
      type: object
      properties:
        name:
          type: string
          example: Maria da Silva
        email:
          type: string
          format: email
          example: email@email.com
        phone:
          type: string
          nullable: true
          example: null
      xml:
        name: customer
    Field:
      type: object
      properties:
        label:
          type: string
          example: Data de ida
        value:
          type: string
          example: 20/05/2026
      xml:
        name: field
    Opportunity:
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 12
          nullable: true
        external_id:
          type: string
          example: abc123
          nullable: true
        description:
          type: string
          nullable: true
          example: a
        source:
          type: string
          example: primeira
        customer:
          $ref: '#/components/schemas/Customer'
        fields:
          type: array
          items:
            $ref: '#/components/schemas/Field'
      xml:
        name: opportunity
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````