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

# Contrata um PayPerUse

<ParamField header="Accept" type="string" initialValue="application/json" required>
  Cabeçalho que indica o tipo de conteúdo aceito na resposta. Deve ser sempre `application/json`.
</ParamField>


## OpenAPI

````yaml POST /payperuse/takeout
openapi: 3.0.3
info:
  title: PayPerUse Unified API
  description: >
    API para contratação e gerenciamento de seguros viagem para dispositivos
    móveis.


    Esta API permite cotar planos, contratar seguros, processar pagamentos e
    gerenciar seguros viagem.


    Observação: Utilize sempre os cabeçalhos `Content-Type` e `Accept` como
    `application/json`
  version: 1.0.0
servers:
  - url: https://homolog.clubfix.com.br/webservice
    description: Ambiente de Homologação
  - url: https://clubfix.com.br/webservice
    description: Ambiente de Produção
security:
  - bearerAuth: []
tags:
  - name: Autenticação
    description: Endpoints para autenticação e obtenção de tokens
  - name: Cotação
    description: Endpoints para cotação de planos de seguro viagem
  - name: Contratação
    description: Endpoints para contratação de seguros viagem
  - name: Pagamento
    description: Endpoints para processamento de pagamentos
  - name: Anexos
    description: Endpoints para anexar documentos
  - name: Seguros
    description: Endpoints para consulta e gerenciamento de seguros
paths:
  /payperuse/takeout:
    post:
      tags:
        - Contratação
      summary: Contrata o PayperUse
      operationId: takeoutInsurance
      parameters:
        - name: Accept
          in: header
          required: true
          schema:
            type: string
            default: application/json
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TakeoutRequest'
            example:
              maxima: 10000
              starts_at: '2025-12-20'
              ends_at: '2025-12-31'
              origin: Curitiba - PR
              destination: São Paulo - SP
              insured_id: 7
              beneficiary_id: 8
              insured_device:
                main_serial_number: IMEI-PRIMARY-123456789012345
                secondary_serial_number: IMEI-SECONDARY-123456789012345
              beneficiary_device:
                main_serial_number: IMEI-PRIMARY-987654321098765
                secondary_serial_number: IMEI-SECONDARY-987654321098765
              plan_id: '1'
      responses:
        '201':
          description: Seguro contratado com sucesso
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Insurance'
              example:
                id: 14
                days: 12
                starts_at: '2025-12-20'
                ends_at: '2025-12-31'
                cancel_limit_date: '2025-12-19'
                maxima: 10000
                amount: 90
                origin: Curitiba - PR
                local: null
                created_at: '2025-12-19T20:06:26.000000Z'
                status:
                  status: pending
                  created_at: '2025-12-19T20:06:26.000000Z'
                ticket:
                  link: >-
                    http://localhost:8000/partnership/payperuse/events/bilhetes/6022a54610f94d05ab73905057a8be73
                  expires_at: '2025-12-19 17:16:00'
                ticket_number: '11015420250171'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    TakeoutRequest:
      type: object
      required:
        - maxima
        - starts_at
        - ends_at
        - origin
        - destination
        - insured_id
        - beneficiary_id
        - insured_device
        - beneficiary_device
        - plan_id
      properties:
        maxima:
          type: integer
          description: Corresponde à importância máxima segurada
          example: 10000
        starts_at:
          type: string
          format: date
          description: Data de início da vigência
          example: '2025-12-20'
        ends_at:
          type: string
          format: date
          description: Data de fim da vigência
          example: '2025-12-31'
        origin:
          type: string
          description: Origem da viagem no formato "CIDADE-UF"
          example: Curitiba - PR
        destination:
          type: string
          description: >-
            Destino da viagem no formato "CIDADE-UF" (nacional) ou país
            (internacional)
          example: São Paulo - SP
        insured_id:
          type: integer
          description: ID do segurado principal
          example: 7
        beneficiary_id:
          type: integer
          description: ID do beneficiário
          example: 8
        insured_device:
          $ref: '#/components/schemas/Device'
        beneficiary_device:
          $ref: '#/components/schemas/Device'
        plan_id:
          type: string
          description: ID do plano selecionado
          example: '1'
        distance:
          type: integer
          description: Distância da viagem em km (opcional)
          example: 120
        distance_unit:
          type: string
          description: Unidade de distância (opcional)
          example: km
        reference:
          type: string
          description: >-
            Referência do vôo ou identificação do seguro (opcional, mas
            recomendado)
        observations:
          type: string
          description: Observações sobre a contratação (opcional)
        store_id:
          type: integer
          description: ID da loja (opcional)
          example: 10
    Insurance:
      type: object
      properties:
        id:
          type: integer
          example: 14
        days:
          type: integer
          description: Número de dias de vigência
          example: 12
        starts_at:
          type: string
          format: date
          example: '2025-12-20'
        ends_at:
          type: string
          format: date
          example: '2025-12-31'
        cancel_limit_date:
          type: string
          format: date
          description: Data limite para cancelamento
          example: '2025-12-19'
        maxima:
          type: integer
          example: 10000
        amount:
          type: number
          format: float
          example: 90
        origin:
          type: string
          example: Curitiba - PR
        local:
          type: string
          nullable: true
          example: null
        created_at:
          type: string
          format: date-time
          example: '2025-12-19T20:06:26.000000Z'
        status:
          $ref: '#/components/schemas/InsuranceStatus'
        ticket:
          $ref: '#/components/schemas/Ticket'
          nullable: true
        ticket_number:
          type: string
          example: '11015420250171'
    Device:
      type: object
      properties:
        main_serial_number:
          type: string
          description: IMEI principal do dispositivo
          example: IMEI-PRIMARY-123456789012345
        secondary_serial_number:
          type: string
          description: IMEI secundário do dispositivo (opcional)
          example: IMEI-SECONDARY-123456789012345
        model_id:
          type: integer
          description: ID do modelo do dispositivo (opcional)
          example: 789
    InsuranceStatus:
      type: object
      properties:
        status:
          type: string
          example: pending
        created_at:
          type: string
          format: date-time
          example: '2025-12-19T20:06:26.000000Z'
    Ticket:
      type: object
      properties:
        link:
          type: string
          format: uri
          description: Link para impressão do bilhete
          example: >-
            http://localhost:8000/partnership/payperuse/events/bilhetes/6022a54610f94d05ab73905057a8be73
        expires_at:
          type: string
          format: date-time
          description: Data de expiração do link
          example: '2025-12-19 17:16:00'
    ValidationError:
      type: object
      properties:
        message:
          type: string
          example: The given data was invalid.
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          example:
            credit_card:
              - validation.required_if
            credit_card.number:
              - validation.required_if
            credit_card.expirate_at:
              - validation.required_if
            credit_card.cvv:
              - validation.required_if
  responses:
    Unauthorized:
      description: Não autorizado. Token inválido ou ausente.
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                example: Unauthenticated.
    ValidationError:
      description: Erro de validação nos dados fornecidos
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
    ServerError:
      description: Erro interno do servidor
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                example: Internal server error.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Token de autenticação obtido através do endpoint de autenticação

````